org.elasticsearch.common.collect.Lists Java Examples

The following examples show how to use org.elasticsearch.common.collect.Lists. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SrvUnicastHostsProvider.java    From elasticsearch-srv-discovery with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: SrvUnicastHostsProvider.java    From elasticsearch-srv-discovery with MIT License 6 votes vote down vote up
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;
}
 
Example #3
Source File: AnalyzeHelper.java    From es-service-parent with Apache License 2.0 5 votes vote down vote up
/**
 * 分词-无法分词则返回空集合
 * 
 * @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;
}
 
Example #4
Source File: GraphiteService.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 5 votes vote down vote up
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;
}
 
Example #5
Source File: SearchIntoContext.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
public List<InetSocketTransportAddress> targetNodes() {
    if (targetNodes == null) {
        targetNodes = Lists.newArrayList();
    }
    return targetNodes;
}