本文整理汇总了Java中org.elasticsearch.common.collect.Lists类的典型用法代码示例。如果您正苦于以下问题:Java Lists类的具体用法?Java Lists怎么用?Java Lists使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lists类属于org.elasticsearch.common.collect包,在下文中一共展示了Lists类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDynamicNodes
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
public List<DiscoveryNode> buildDynamicNodes() {
List<DiscoveryNode> discoNodes = Lists.newArrayList();
if (query == null) {
logger.error("DNS query must not be null. Please set '{}'", DISCOVERY_SRV_QUERY);
return discoNodes;
}
try {
logger.trace("Building dynamic discovery nodes...");
discoNodes = lookupNodes();
if (discoNodes.size() == 0) {
logger.debug("No nodes found");
}
} catch (TextParseException e) {
logger.error("Unable to parse DNS query '{}'", query);
logger.error("DNS lookup exception:", e);
}
logger.debug("Using dynamic discovery nodes {}", discoNodes);
return discoNodes;
}
示例2: lookupNodes
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
protected List<DiscoveryNode> lookupNodes() throws TextParseException {
List<DiscoveryNode> discoNodes = Lists.newArrayList();
for (Record srvRecord : lookupRecords(query, Type.SRV)) {
logger.trace("Found SRV record {}", srvRecord);
for (Record aRecord : lookupRecords(((SRVRecord) srvRecord).getTarget().toString(), Type.A)) {
logger.trace("Found A record {} for SRV record", aRecord, srvRecord);
String address = ((ARecord) aRecord).getAddress().getHostAddress() + ":" + ((SRVRecord) srvRecord).getPort();
try {
for (TransportAddress transportAddress : transportService.addressesFromString(address)) {
logger.trace("adding {}, transport_address {}", address, transportAddress);
discoNodes.add(new DiscoveryNode("#srv-" + address + "-" + transportAddress, transportAddress, version.minimumCompatibilityVersion()));
}
} catch (Exception e) {
logger.warn("failed to add {}, address {}", e, address);
}
}
}
return discoNodes;
}
示例3: testMapAccess
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Test
public void testMapAccess() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).put("l", Lists.newArrayList("2", "1")).map();
vars.put("obj1", obj1);
Object o = se.execute(se.compile("obj1"), vars);
assertThat(o, instanceOf(Map.class));
obj1 = (Map<String, Object>) o;
assertThat((String) obj1.get("prop1"), equalTo("value1"));
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
o = se.execute(se.compile("obj1.l[0]"), vars);
assertThat(((String) o), equalTo("2"));
}
示例4: testAccessListInScript
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Test
public void testAccessListInScript() {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).map();
vars.put("l", Lists.newArrayList("1", "2", "3", obj1));
Object o = se.execute(se.compile("l.length"), vars);
assertThat(((Number) o).intValue(), equalTo(4));
o = se.execute(se.compile("l[0]"), vars);
assertThat(((String) o), equalTo("1"));
o = se.execute(se.compile("l[3]"), vars);
obj1 = (Map<String, Object>) o;
assertThat((String) obj1.get("prop1"), equalTo("value1"));
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
o = se.execute(se.compile("l[3].prop1"), vars);
assertThat(((String) o), equalTo("value1"));
}
示例5: Factory
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
public Factory() {
ArrayList<String> classpath_string = Lists.newArrayList(System.getProperty("java.class.path").split(System.getProperty("path.separator")));
classpath = new ArrayList<>(classpath_string.size());
classpath_string.forEach(cp -> {
File f = new File(cp);
try {
CopyMove.checkExistsCanRead(f);
classpath.add(f.getCanonicalFile());
} catch (Exception e) {
Loggers.Factory.error("Can't access to classpath item: " + cp);
}
});
class_names = new HashMap<>();
absent_class_names = new HashSet<>();
class_constructor = new ConcurrentHashMap<>();
lock = new Object();
}
示例6: analyze
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
/**
* 分词-无法分词则返回空集合
*
* @param analyzer
* @param str
* @return
*/
public static List<String> analyze(String analyzer, String str) {
AnalyzeResponse ar = null;
try {
AnalyzeRequest request = new AnalyzeRequest(str).analyzer(analyzer).index(
getCurrentValidIndex());
ar = ESClient.getClient().admin().indices().analyze(request).actionGet();
} catch (IndexMissingException e) {
if (!reLoad) {
synchronized (AnalyzeHelper.class) {
if (!reLoad) {
reLoad = true;
}
}
}
return analyze(analyzer, str);
}
if (ar == null || ar.getTokens() == null || ar.getTokens().size() < 1) {
return Lists.newArrayList();
}
List<String> analyzeTokens = Lists.newArrayList();
for (AnalyzeToken at : ar.getTokens()) {
analyzeTokens.add(at.getTerm());
}
return analyzeTokens;
}
示例7: newResponse
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Override
protected FlushResponse newResponse(final FlushRequest request, final AtomicReferenceArray nodesResponses) {
final List<NodeFlushResponse> nodes = Lists.<NodeFlushResponse> newArrayList();
for (int i = 0; i < nodesResponses.length(); i++) {
final Object resp = nodesResponses.get(i);
if ((resp instanceof NodeFlushResponse)) {
nodes.add((NodeFlushResponse) resp);
}
}
return new FlushResponse(this.clusterName, nodes.toArray(new NodeFlushResponse[nodes.size()]));
}
示例8: execute
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
String queryString = tridentTuple.getString(0);
String esQuery = QueryBuilders.matchQuery("content", queryString).buildAsBytes().toUtf8();
tridentCollector.emit(new Values(esQuery, Lists.newArrayList(esIndex), Lists.newArrayList("crawl_type")) );
}
示例9: addRootPropertiesAsCamp
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
private void addRootPropertiesAsCamp(PaaSTopologyDeploymentContext deploymentContext, Map<String,Object> result) {
if (applicationService!=null) {
try {
Application app = applicationService.getOrFail(deploymentContext.getDeployment().getSourceId());
if (app!=null) {
result.put("name", app.getName());
if (app.getDescription()!=null) result.put("description", app.getDescription());
List<String> tags = Lists.newArrayList();
for (Tag tag: app.getTags()) {
tags.add(tag.getName()+": "+tag.getValue());
}
if (!tags.isEmpty())
result.put("tags", tags);
// TODO icon, from app.getImageId());
return;
}
log.warn("Application null when deploying "+deploymentContext+"; using less information");
} catch (NotFoundException e) {
// ignore, fall through to below
log.warn("Application instance not found when deploying "+deploymentContext+"; using less information");
}
} else {
log.warn("Application service not available when deploying "+deploymentContext+"; using less information");
}
// no app or app service - use what limited information we have
result.put("name", "A4C: "+deploymentContext.getDeployment().getSourceName());
result.put("description", "Created by Alien4Cloud from application "+deploymentContext.getDeployment().getSourceId());
}
示例10: execute
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
String queryString = tridentTuple.getString(0);
String taskName = tridentTuple.getString(1);
String esQuery = QueryBuilders.matchQuery("content", queryString).buildAsBytes().toUtf8();
tridentCollector.emit(new Values(esQuery, Lists.newArrayList(esIndex), Lists.newArrayList(taskName)) );
}
示例11: getIndexShards
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
private List<IndexShard> getIndexShards(IndicesService indicesService)
{
List<IndexShard> indexShards = Lists.newArrayList();
String[] indices = indicesService.indices().toArray(new String[] {});
for (String indexName : indices) {
IndexService indexService = indicesService.indexServiceSafe(indexName);
for (int shardId : indexService.shardIds()) {
indexShards.add(indexService.shard(shardId));
}
}
return indexShards;
}
示例12: getIndexShards
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
private List<IndexShard> getIndexShards(IndicesService indicesService) {
List<IndexShard> indexShards = Lists.newArrayList();
Iterator<IndexService> indexServiceIterator = indicesService.iterator();
while (indexServiceIterator.hasNext()) {
IndexService indexService = indexServiceIterator.next();
for (int shardId : indexService.shardIds()) {
indexShards.add(indexService.shard(shardId));
}
}
return indexShards;
}
示例13: buildFilters
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
private List<FilterBuilder> buildFilters(IFilterBuilderHelper filterBuilderHelper, String esFieldName, String[] values, FilterValuesStrategy strategy) {
if (strategy == null || FilterValuesStrategy.OR.equals(strategy)) {
return Lists.newArrayList(filterBuilderHelper.buildFilter(esFieldName, values));
}
List<FilterBuilder> valuesFilters = Lists.newArrayList();
for (String value : values) {
valuesFilters.add(filterBuilderHelper.buildFilter(esFieldName, value));
}
return valuesFilters;
}
示例14: buildFacets
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Override
public List<AggregationBuilder> buildFacets() {
TermsBuilder termsBuilder = AggregationBuilders.terms(getEsFieldName()).field(getEsFieldName()).size(size);
MissingBuilder missingBuilder = AggregationBuilders.missing("missing_" + getEsFieldName()).field(getEsFieldName());
// Elastic search has a bug with excludes so don't use it. https://github.com/elastic/elasticsearch/issues/18575
// if (exclude != null) {
// termsBuilder.exclude(exclude);
// }
return Lists.newArrayList(termsBuilder, missingBuilder);
}
示例15: deploy
import org.elasticsearch.common.collect.Lists; //导入依赖的package包/类
@Override
@SneakyThrows
public void deploy(PaaSTopologyDeploymentContext deploymentContext, IPaaSCallback<?> callback) {
log.info("DEPLOY "+deploymentContext+" / "+callback);
knownDeployments.put(deploymentContext.getDeploymentId(), deploymentContext);
String topologyId = deploymentContext.getDeploymentTopology().getId();
Map<String,Object> campYaml = Maps.newLinkedHashMap();
addRootPropertiesAsCamp(deploymentContext, campYaml);
List<Object> svcs = Lists.newArrayList();
Map<String, Object> svc = Maps.newHashMap();
svc.put("type", "alien4cloud_deployment_topology:" + topologyId);
svcs.add(svc);
campYaml.put("services", svcs);
campYaml.put("brooklyn.config", ImmutableMap.of("tosca.deployment.id", deploymentContext.getDeploymentId()));
String locationIds[] = deploymentContext.getDeployment().getLocationIds();
if (locationIds.length > 0) {
campYaml.put("location", locationService.getOrFail(locationIds[0]).getName());
}
try {
useLocalContextClassLoader();
String campYamlString = new ObjectMapper().writeValueAsString(campYaml);
log.info("DEPLOYING: "+campYamlString);
Response result = getNewBrooklynApi().getApplicationApi().createFromYaml( campYamlString );
TaskSummary createAppSummary = BrooklynApi.getEntity(result, TaskSummary.class);
log.info("RESULT: "+result.getEntity());
validate(result);
String entityId = createAppSummary.getEntityId();
deploymentContext.getDeployment().setOrchestratorDeploymentId(entityId);
alienDAO.save(deploymentContext.getDeployment());
// (the result is a 204 creating, whose entity is a TaskSummary
// with an entityId of the entity which is created and id of the task)
deploymentStatuses.put(entityId, Optional.<DeploymentStatus>absent());
// inital entry which will immediately trigger an event in getEventsSince()
} catch (Throwable e) {
log.warn("ERROR DEPLOYING", e);
throw e;
} finally { revertContextClassLoader(); }
if (callback!=null) callback.onSuccess(null);
}