本文整理汇总了Java中org.elasticsearch.common.collect.Lists.newArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java Lists.newArrayList方法的具体用法?Java Lists.newArrayList怎么用?Java Lists.newArrayList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.collect.Lists
的用法示例。
在下文中一共展示了Lists.newArrayList方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例4: 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;
}
示例5: 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()]));
}
示例6: 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());
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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);
}
示例12: targetNodes
import org.elasticsearch.common.collect.Lists; //导入方法依赖的package包/类
public List<InetSocketTransportAddress> targetNodes() {
if (targetNodes == null) {
targetNodes = Lists.newArrayList();
}
return targetNodes;
}