Java Code Examples for org.elasticsearch.common.settings.Settings#getAsInt()

The following examples show how to use org.elasticsearch.common.settings.Settings#getAsInt() . 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: ShingleTokenFilterFactory.java    From crate with Apache License 2.0 6 votes vote down vote up
public ShingleTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    int maxAllowedShingleDiff = indexSettings.getMaxShingleDiff();
    Integer maxShingleSize = settings.getAsInt("max_shingle_size", ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE);
    Integer minShingleSize = settings.getAsInt("min_shingle_size", ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE);
    Boolean outputUnigrams = settings.getAsBoolean("output_unigrams", true);
    Boolean outputUnigramsIfNoShingles = settings.getAsBoolean("output_unigrams_if_no_shingles", false);

    int shingleDiff = maxShingleSize - minShingleSize + (outputUnigrams ? 1 : 0);
    if (shingleDiff > maxAllowedShingleDiff) {
        deprecationLogger.deprecated("Deprecated big difference between maxShingleSize and minShingleSize in Shingle TokenFilter,"
            + "expected difference must be less than or equal to: [" + maxAllowedShingleDiff + "]");
    }
    String tokenSeparator = settings.get("token_separator", ShingleFilter.DEFAULT_TOKEN_SEPARATOR);
    String fillerToken = settings.get("filler_token", ShingleFilter.DEFAULT_FILLER_TOKEN);
    factory = new Factory("shingle", minShingleSize, maxShingleSize, outputUnigrams, outputUnigramsIfNoShingles, tokenSeparator, fillerToken);
}
 
Example 2
Source File: ThrottlingAllocationDecider.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void onRefreshSettings(Settings settings) {
    int primariesInitialRecoveries = settings.getAsInt(
            CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES,
            ThrottlingAllocationDecider.this.settings.getAsInt(
                    CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES,
                    DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES));
    if (primariesInitialRecoveries != ThrottlingAllocationDecider.this.primariesInitialRecoveries) {
        logger.info("updating [cluster.routing.allocation.node_initial_primaries_recoveries] from [{}] to [{}]", ThrottlingAllocationDecider.this.primariesInitialRecoveries, primariesInitialRecoveries);
        ThrottlingAllocationDecider.this.primariesInitialRecoveries = primariesInitialRecoveries;
    }

    int concurrentRecoveries = settings.getAsInt(
            CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES,
            ThrottlingAllocationDecider.this.settings.getAsInt(
                    CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES,
                    DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES));
    if (concurrentRecoveries != ThrottlingAllocationDecider.this.concurrentRecoveries) {
        logger.info("updating [cluster.routing.allocation.node_concurrent_recoveries] from [{}] to [{}]", ThrottlingAllocationDecider.this.concurrentRecoveries, concurrentRecoveries);
        ThrottlingAllocationDecider.this.concurrentRecoveries = concurrentRecoveries;
    }
}
 
Example 3
Source File: FaultDetection.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public FaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = clusterName;

    this.connectOnNetworkDisconnect = settings.getAsBoolean(SETTING_CONNECT_ON_NETWORK_DISCONNECT, false);
    this.pingInterval = settings.getAsTime(SETTING_PING_INTERVAL, timeValueSeconds(1));
    this.pingRetryTimeout = settings.getAsTime(SETTING_PING_TIMEOUT, timeValueSeconds(30));
    this.pingRetryCount = settings.getAsInt(SETTING_PING_RETRIES, 3);
    this.registerConnectionListener = settings.getAsBoolean(SETTING_REGISTER_CONNECTION_LISTENER, true);

    this.connectionListener = new FDConnectionListener();
    if (registerConnectionListener) {
        transportService.addConnectionListener(connectionListener);
    }
}
 
Example 4
Source File: GraphiteService.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Inject public GraphiteService(Settings settings, ClusterService clusterService, IndicesService indicesService,
                               NodeService nodeService) {
    super(settings);
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.nodeService = nodeService;
    graphiteRefreshInternal = settings.getAsTime("metrics.graphite.every", TimeValue.timeValueMinutes(1));
    graphiteHost = settings.get("metrics.graphite.host");
    graphitePort = settings.getAsInt("metrics.graphite.port", 2003);
    graphitePrefix = settings.get("metrics.graphite.prefix", "elasticsearch" + "." + settings.get("cluster.name"));
    String graphiteInclusionRegexString = settings.get("metrics.graphite.include");
    if (graphiteInclusionRegexString != null) {
        graphiteInclusionRegex = Pattern.compile(graphiteInclusionRegexString);
    }
    String graphiteExclusionRegexString = settings.get("metrics.graphite.exclude");
    if (graphiteExclusionRegexString != null) {
        graphiteExclusionRegex = Pattern.compile(graphiteExclusionRegexString);
    }
}
 
Example 5
Source File: ConcurrentRebalanceAllocationDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void onRefreshSettings(Settings settings) {
    int clusterConcurrentRebalance = settings.getAsInt(
            CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE,
            ConcurrentRebalanceAllocationDecider.this.settings.getAsInt(
                    CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE,
                    DEFAULT_CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE));
    if (clusterConcurrentRebalance != ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance) {
        logger.info("updating [cluster.routing.allocation.cluster_concurrent_rebalance] from [{}], to [{}]", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance, clusterConcurrentRebalance);
        ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance = clusterConcurrentRebalance;
    }
}
 
Example 6
Source File: TruncateTokenFilterFactory.java    From crate with Apache License 2.0 5 votes vote down vote up
TruncateTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    this.length = settings.getAsInt("length", -1);
    if (length <= 0) {
        throw new IllegalArgumentException("length parameter must be provided");
    }
}
 
Example 7
Source File: EsExecutors.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the number of processors available but at most <tt>32</tt>.
 */
public static int boundedNumberOfProcessors(Settings settings) {
    /* This relates to issues where machines with large number of cores
     * ie. >= 48 create too many threads and run into OOM see #3478
     * We just use an 32 core upper-bound here to not stress the system
     * too much with too many created threads */
    int defaultValue = Math.min(32, Runtime.getRuntime().availableProcessors());
    try {
        defaultValue = Integer.parseInt(System.getProperty(DEFAULT_SYSPROP));
    } catch (Throwable ignored) {}
    return settings.getAsInt(PROCESSORS, defaultValue);
}
 
Example 8
Source File: IndicesRequestCache.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public IndicesRequestCache(Settings settings, ClusterService clusterService, ThreadPool threadPool) {
    super(settings);
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.cleanInterval = settings.getAsTime(INDICES_CACHE_REQUEST_CLEAN_INTERVAL, TimeValue.timeValueSeconds(60));

    String size = settings.get(INDICES_CACHE_QUERY_SIZE);
    if (size == null) {
        size = settings.get(DEPRECATED_INDICES_CACHE_QUERY_SIZE);
        if (size != null) {
            deprecationLogger.deprecated("The [" + DEPRECATED_INDICES_CACHE_QUERY_SIZE
                    + "] settings is now deprecated, use [" + INDICES_CACHE_QUERY_SIZE + "] instead");
        }
    }
    if (size == null) {
        // this cache can be very small yet still be very effective
        size = "1%";
    }
    this.size = size;

    this.expire = settings.getAsTime(INDICES_CACHE_QUERY_EXPIRE, null);
    // defaults to 4, but this is a busy map for all indices, increase it a bit by default
    this.concurrencyLevel =  settings.getAsInt(INDICES_CACHE_QUERY_CONCURRENCY_LEVEL, 16);
    if (concurrencyLevel <= 0) {
        throw new IllegalArgumentException("concurrency_level must be > 0 but was: " + concurrencyLevel);
    }
    buildCache();

    this.reaper = new Reaper();
    threadPool.schedule(cleanInterval, ThreadPool.Names.SAME, reaper);
}
 
Example 9
Source File: NGramTokenizerFactory.java    From crate with Apache License 2.0 5 votes vote down vote up
NGramTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    int maxAllowedNgramDiff = indexSettings.getMaxNgramDiff();
    this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
    this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
    int ngramDiff = maxGram - minGram;
    if (ngramDiff > maxAllowedNgramDiff) {
        deprecationLogger.deprecated("Deprecated big difference between max_gram and min_gram in NGram Tokenizer,"
            + "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]");
    }
    this.matcher = parseTokenChars(settings.getAsList("token_chars"));
}
 
Example 10
Source File: FingerprintAnalyzerProvider.java    From crate with Apache License 2.0 5 votes vote down vote up
FingerprintAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);

    char separator = parseSeparator(settings);
    int maxOutputSize = settings.getAsInt(MAX_OUTPUT_SIZE.getPreferredName(),DEFAULT_MAX_OUTPUT_SIZE);
    CharArraySet stopWords = Analysis.parseStopWords(env, settings, DEFAULT_STOP_WORDS);

    this.analyzer = new FingerprintAnalyzer(stopWords, separator, maxOutputSize);
}
 
Example 11
Source File: DefaultRequestHandler.java    From elasticsearch-taste with Apache License 2.0 5 votes vote down vote up
public DefaultRequestHandler(final Settings settings, final Client client, final ThreadPool pool) {
    this.settings = settings;
    this.client = client;
    this.pool = pool;
    maxRetryCount = settings.getAsInt("taste.rest.retry", 20);
    logger = Loggers.getLogger(getClass(), settings);
    indexCreationLock = new ReentrantLock();
}
 
Example 12
Source File: MinHashTokenFilterFactory.java    From elasticsearch-minhash with Apache License 2.0 5 votes vote down vote up
public MinHashTokenFilterFactory(final IndexSettings indexSettings, final Environment environment, final String name, final Settings settings) {
    super(indexSettings, name, settings);

    hashBit = settings.getAsInt("bit", 1);
    final int numOfHash = settings.getAsInt("size", 128);
    final int seed = settings.getAsInt("seed", 0);

    hashFunctions = MinHash.createHashFunctions(seed, numOfHash);

    if (logger.isDebugEnabled()) {
        logger.debug("Index:{} -> {}-bit minhash with {} murmur3({}) functions.", indexSettings.getIndex(), hashBit, numOfHash, seed);
    }
}
 
Example 13
Source File: MergeSchedulerConfig.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public MergeSchedulerConfig(Settings indexSettings) {
    maxThreadCount = indexSettings.getAsInt(MAX_THREAD_COUNT, Math.max(1, Math.min(4, EsExecutors.boundedNumberOfProcessors(indexSettings) / 2)));
    maxMergeCount = indexSettings.getAsInt(MAX_MERGE_COUNT, maxThreadCount + 5);
    this.autoThrottle = indexSettings.getAsBoolean(AUTO_THROTTLE, true);
    notifyOnMergeFailure = indexSettings.getAsBoolean(NOTIFY_ON_MERGE_FAILURE, true);
}
 
Example 14
Source File: ClassicTokenizerFactory.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public ClassicTokenizerFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH);
}
 
Example 15
Source File: PriorityComparator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
private int priority(Settings settings) {
    return settings.getAsInt(IndexMetaData.SETTING_PRIORITY, 1);
}
 
Example 16
Source File: EdgeNGramTokenizerFactory.java    From crate with Apache License 2.0 4 votes vote down vote up
EdgeNGramTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
    this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
    this.matcher = parseTokenChars(settings.getAsList("token_chars"));
}
 
Example 17
Source File: ClassicTokenizerFactory.java    From crate with Apache License 2.0 4 votes vote down vote up
ClassicTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH);
}
 
Example 18
Source File: WhitespaceTokenizerFactory.java    From crate with Apache License 2.0 4 votes vote down vote up
WhitespaceTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    maxTokenLength = settings.getAsInt(MAX_TOKEN_LENGTH, StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH);
}
 
Example 19
Source File: ZenDiscovery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool,
                    TransportService transportService, final ClusterService clusterService, NodeSettingsService nodeSettingsService,
                    ZenPingService pingService, ElectMasterService electMasterService,
                    DiscoverySettings discoverySettings) {
    super(settings);
    this.clusterName = clusterName;
    this.clusterService = clusterService;
    this.transportService = transportService;
    this.discoverySettings = discoverySettings;
    this.pingService = pingService;
    this.electMaster = electMasterService;
    TimeValue pingTimeout = this.settings.getAsTime("discovery.zen.initial_ping_timeout", timeValueSeconds(3));
    pingTimeout = this.settings.getAsTime("discovery.zen.ping_timeout", pingTimeout);
    pingTimeout = settings.getAsTime("discovery.zen.ping_timeout", pingTimeout);
    this.pingTimeout = settings.getAsTime(SETTING_PING_TIMEOUT, pingTimeout);

    this.joinTimeout = settings.getAsTime(SETTING_JOIN_TIMEOUT, TimeValue.timeValueMillis(this.pingTimeout.millis() * 20));
    this.joinRetryAttempts = settings.getAsInt(SETTING_JOIN_RETRY_ATTEMPTS, 3);
    this.joinRetryDelay = settings.getAsTime(SETTING_JOIN_RETRY_DELAY, TimeValue.timeValueMillis(100));
    this.maxPingsFromAnotherMaster = settings.getAsInt(SETTING_MAX_PINGS_FROM_ANOTHER_MASTER, 3);
    this.sendLeaveRequest = settings.getAsBoolean(SETTING_SEND_LEAVE_REQUEST, true);

    this.masterElectionFilterClientNodes = settings.getAsBoolean(SETTING_MASTER_ELECTION_FILTER_CLIENT, true);
    this.masterElectionFilterDataNodes = settings.getAsBoolean(SETTING_MASTER_ELECTION_FILTER_DATA, false);
    this.masterElectionWaitForJoinsTimeout = settings.getAsTime(SETTING_MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT, TimeValue.timeValueMillis(joinTimeout.millis() / 2));

    if (this.joinRetryAttempts < 1) {
        throw new IllegalArgumentException("'" + SETTING_JOIN_RETRY_ATTEMPTS + "' must be a positive number. got [" + SETTING_JOIN_RETRY_ATTEMPTS + "]");
    }
    if (this.maxPingsFromAnotherMaster < 1) {
        throw new IllegalArgumentException("'" + SETTING_MAX_PINGS_FROM_ANOTHER_MASTER + "' must be a positive number. got [" + this.maxPingsFromAnotherMaster + "]");
    }

    logger.debug("using ping.timeout [{}], join.timeout [{}], master_election.filter_client [{}], master_election.filter_data [{}]", pingTimeout, joinTimeout, masterElectionFilterClientNodes, masterElectionFilterDataNodes);

    nodeSettingsService.addListener(new ApplySettings());

    this.masterFD = new MasterFaultDetection(settings, threadPool, transportService, clusterName, clusterService);
    this.masterFD.addListener(new MasterNodeFailureListener());

    this.nodesFD = new NodesFaultDetection(settings, threadPool, transportService, clusterName);
    this.nodesFD.addListener(new NodeFaultDetectionListener());

    this.publishClusterState = new PublishClusterStateAction(settings, transportService, this, new NewClusterStateListener(), discoverySettings);
    this.pingService.setPingContextProvider(this);
    this.membership = new MembershipAction(settings, clusterService, transportService, this, new MembershipListener());

    this.joinThreadControl = new JoinThreadControl(threadPool);

    transportService.registerRequestHandler(DISCOVERY_REJOIN_ACTION_NAME, RejoinClusterRequest.class, ThreadPool.Names.SAME, new RejoinClusterRequestHandler());
}
 
Example 20
Source File: SortformAnalyzerProvider.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 4 votes vote down vote up
SortformTokenizerFactory(IndexSettings indexSettings, String name, Settings settings) {
    super(indexSettings, name, settings);
    Collator collator = IcuCollationKeyAnalyzerProvider.createCollator(settings);
    factory = new IcuCollationAttributeFactory(collator);
    bufferSize = settings.getAsInt("bufferSize", 256);
}