Java Code Examples for org.elasticsearch.node.settings.NodeSettingsService#addListener()

The following examples show how to use org.elasticsearch.node.settings.NodeSettingsService#addListener() . 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: StatsTables.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public StatsTables(Settings settings, NodeSettingsService nodeSettingsService) {
    int operationsLogSize = CrateSettings.STATS_OPERATIONS_LOG_SIZE.extract(settings);
    int jobsLogSize = CrateSettings.STATS_JOBS_LOG_SIZE.extract(settings);
    boolean isEnabled = CrateSettings.STATS_ENABLED.extract(settings);

    if (isEnabled) {
        setJobsLog(jobsLogSize);
        setOperationsLog(operationsLogSize);
    } else {
        setJobsLog(0);
        setOperationsLog(0);
    }

    lastOperationsLogSize = operationsLogSize;
    lastJobsLogSize = jobsLogSize;
    lastIsEnabled = isEnabled;

    nodeSettingsService.addListener(listener);
    jobsLogIterableGetter = new JobsLogIterableGetter();
    jobsIterableGetter = new JobsIterableGetter();
    operationsIterableGetter = new OperationsIterableGetter();
    operationsLogIterableGetter = new OperationsLogIterableGetter();
}
 
Example 2
Source File: CrateCircuitBreakerService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public CrateCircuitBreakerService(Settings settings,
                                  NodeSettingsService nodeSettingsService,
                                  CircuitBreakerService esCircuitBreakerService) {
    super(settings);
    this.esCircuitBreakerService = esCircuitBreakerService;

    long memoryLimit = settings.getAsMemory(
            QUERY_CIRCUIT_BREAKER_LIMIT_SETTING,
            DEFAULT_QUERY_CIRCUIT_BREAKER_LIMIT).bytes();
    double overhead = settings.getAsDouble(
            QUERY_CIRCUIT_BREAKER_OVERHEAD_SETTING,
            DEFAULT_QUERY_CIRCUIT_BREAKER_OVERHEAD_CONSTANT);

    queryBreakerSettings = new BreakerSettings(QUERY, memoryLimit, overhead,
            CircuitBreaker.Type.parseValue(
                    settings.get(QUERY_CIRCUIT_BREAKER_TYPE_SETTING,
                    DEFAULT_QUERY_CIRCUIT_BREAKER_TYPE)));

    registerBreaker(queryBreakerSettings);
    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 3
Source File: FilterAllocationDecider.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public FilterAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    Map<String, String> requireMap = settings.getByPrefix(CLUSTER_ROUTING_REQUIRE_GROUP).getAsMap();
    if (requireMap.isEmpty()) {
        clusterRequireFilters = null;
    } else {
        clusterRequireFilters = DiscoveryNodeFilters.buildFromKeyValue(AND, requireMap);
    }
    Map<String, String> includeMap = settings.getByPrefix(CLUSTER_ROUTING_INCLUDE_GROUP).getAsMap();
    if (includeMap.isEmpty()) {
        clusterIncludeFilters = null;
    } else {
        clusterIncludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, includeMap);
    }
    Map<String, String> excludeMap = settings.getByPrefix(CLUSTER_ROUTING_EXCLUDE_GROUP).getAsMap();
    if (excludeMap.isEmpty()) {
        clusterExcludeFilters = null;
    } else {
        clusterExcludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, excludeMap);
    }
    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 4
Source File: AwarenessAllocationDecider.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public AwarenessAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    this.awarenessAttributes = settings.getAsArray(CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTES);

    forcedAwarenessAttributes = Maps.newHashMap();
    Map<String, Settings> forceGroups = settings.getGroups(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP);
    for (Map.Entry<String, Settings> entry : forceGroups.entrySet()) {
        String[] aValues = entry.getValue().getAsArray("values");
        if (aValues.length > 0) {
            forcedAwarenessAttributes.put(entry.getKey(), aValues);
        }
    }

    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 5
Source File: ThreadPool.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void setNodeSettingsService(NodeSettingsService nodeSettingsService) {
    if(settingsListenerIsSet) {
        throw new IllegalStateException("the node settings listener was set more then once");
    }
    nodeSettingsService.addListener(new ApplySettings());
    settingsListenerIsSet = true;
}
 
Example 6
Source File: EnableAllocationDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public EnableAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    this.enableAllocation = Allocation.parse(settings.get(CLUSTER_ROUTING_ALLOCATION_ENABLE,
            this.settings.get(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.ALL.name())));
    this.enableRebalance = Rebalance.parse(settings.get(CLUSTER_ROUTING_REBALANCE_ENABLE,
            this.settings.get(CLUSTER_ROUTING_ALLOCATION_ENABLE, Rebalance.ALL.name())));
    nodeSettingsService.addListener(this);
}
 
Example 7
Source File: DiskThresholdDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DiskThresholdDecider(Settings settings, NodeSettingsService nodeSettingsService, ClusterInfoService infoService, Client client) {
    super(settings);
    String lowWatermark = settings.get(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK,
            DEFAULT_LOW_DISK_WATERMARK);
    String highWatermark = settings.get(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK,
            DEFAULT_HIGH_DISK_WATERMARK);

    if (!validWatermarkSetting(lowWatermark, CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK)) {
        throw new ElasticsearchParseException("unable to parse low watermark [{}]", lowWatermark);
    }
    if (!validWatermarkSetting(highWatermark, CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK)) {
        throw new ElasticsearchParseException("unable to parse high watermark [{}]", highWatermark);
    }
    // Watermark is expressed in terms of used data, but we need "free" data watermark
    this.freeDiskThresholdLow = 100.0 - thresholdPercentageFromWatermark(lowWatermark);
    this.freeDiskThresholdHigh = 100.0 - thresholdPercentageFromWatermark(highWatermark);

    this.freeBytesThresholdLow = thresholdBytesFromWatermark(lowWatermark, CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK);
    this.freeBytesThresholdHigh = thresholdBytesFromWatermark(highWatermark, CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK);
    this.includeRelocations = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS,
            DEFAULT_INCLUDE_RELOCATIONS);
    this.rerouteInterval = settings.getAsTime(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL, TimeValue.timeValueSeconds(60));

    this.enabled = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
            DEFAULT_THRESHOLD_ENABLED);
    nodeSettingsService.addListener(new ApplySettings());
    infoService.addListener(new DiskListener(client));
}
 
Example 8
Source File: ClusterRebalanceAllocationDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public ClusterRebalanceAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    String allowRebalance = settings.get(CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "indices_all_active");
    try {
        type = ClusterRebalanceType.parseString(allowRebalance);
    } catch (IllegalStateException e) {
        logger.warn("[{}] has a wrong value {}, defaulting to 'indices_all_active'", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, allowRebalance);
        type = ClusterRebalanceType.INDICES_ALL_ACTIVE;
    }
    logger.debug("using [{}] with [{}]", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, type.toString().toLowerCase(Locale.ROOT));

    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 9
Source File: DisableAllocationDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DisableAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    this.disableNewAllocation = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, false);
    this.disableAllocation = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_DISABLE_ALLOCATION, false);
    this.disableReplicaAllocation = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_DISABLE_REPLICA_ALLOCATION, false);

    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 10
Source File: TransportCloseIndexAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                 ThreadPool threadPool, MetaDataIndexStateService indexStateService,
                                 NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
                                 IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
    super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest.class);
    this.indexStateService = indexStateService;
    this.destructiveOperations = destructiveOperations;
    this.closeIndexEnabled = settings.getAsBoolean(SETTING_CLUSTER_INDICES_CLOSE_ENABLE, true);
    nodeSettingsService.addListener(this);
}
 
Example 11
Source File: DiscoverySettings.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DiscoverySettings(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    nodeSettingsService.addListener(new ApplySettings());
    this.noMasterBlock = parseNoMasterBlock(settings.get(NO_MASTER_BLOCK, DEFAULT_NO_MASTER_BLOCK));
    this.publishTimeout = settings.getAsTime(PUBLISH_TIMEOUT, publishTimeout);
    this.publishDiff = settings.getAsBoolean(PUBLISH_DIFF_ENABLE, DEFAULT_PUBLISH_DIFF_ENABLE);
}
 
Example 12
Source File: DecommissioningService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DecommissioningService(Settings settings,
                              final ClusterService clusterService,
                              NodeSettingsService nodeSettingsService,
                              TransportSQLAction sqlAction,
                              TransportSQLBulkAction sqlBulkAction,
                              final TransportClusterHealthAction healthAction,
                              final TransportClusterUpdateSettingsAction updateSettingsAction) {
    super(settings);
    this.clusterService = clusterService;
    this.sqlAction = sqlAction;
    this.sqlBulkAction = sqlBulkAction;
    this.healthAction = healthAction;
    this.updateSettingsAction = updateSettingsAction;

    ApplySettings applySettings = new ApplySettings();
    applySettings.onRefreshSettings(settings);
    nodeSettingsService.addListener(applySettings);

    clusterService.add(new ClusterStateListener() {
        @Override
        public void clusterChanged(ClusterChangedEvent event) {
            removeRemovedNodes(event);
        }
    });
    try {
        Signal signal = new Signal("USR2");
        Signal.handle(signal, this);
    } catch (IllegalArgumentException e) {
        logger.warn("SIGUSR2 signal not supported on {}.", System.getProperty("os.name"), e);
    }
}
 
Example 13
Source File: ClusterSettingsExpression.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public ClusterSettingsExpression(Settings settings, NodeSettingsService nodeSettingsService, ClusterService clusterService) {
    this.clusterService = clusterService;
    setDefaultValues(CrateSettings.SETTINGS);
    ApplySettings applySettings = new ApplySettings(settings, values);

    nodeSettingsService.addListener(applySettings);
    addChildImplementations();
}
 
Example 14
Source File: AuditService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public AuditService(NodeSettingsService nodeSettingsService) {
    nodeSettingsService.addListener(new ApplySettings());
    auditLog = new AuditLog();
}
 
Example 15
Source File: TransportService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject(optional = true)
public void setDynamicSettings(NodeSettingsService nodeSettingsService) {
    nodeSettingsService.addListener(settingsListener);
}
 
Example 16
Source File: MappingUpdatedAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public MappingUpdatedAction(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    this.dynamicMappingUpdateTimeout = settings.getAsTime(INDICES_MAPPING_DYNAMIC_TIMEOUT, DEFAULT_ADDITIONAL_MAPPING_CHANGE_TIME);
    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 17
Source File: HierarchyCircuitBreakerService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public HierarchyCircuitBreakerService(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);

    // This uses the old InternalCircuitBreakerService.CIRCUIT_BREAKER_MAX_BYTES_SETTING
    // setting to keep backwards compatibility with 1.3, it can be safely
    // removed when compatibility with 1.3 is no longer needed
    String compatibilityFielddataLimitDefault = DEFAULT_FIELDDATA_BREAKER_LIMIT;
    ByteSizeValue compatibilityFielddataLimit = settings.getAsMemory(OLD_CIRCUIT_BREAKER_MAX_BYTES_SETTING, null);
    if (compatibilityFielddataLimit != null) {
        compatibilityFielddataLimitDefault = compatibilityFielddataLimit.toString();
    }

    // This uses the old InternalCircuitBreakerService.CIRCUIT_BREAKER_OVERHEAD_SETTING
    // setting to keep backwards compatibility with 1.3, it can be safely
    // removed when compatibility with 1.3 is no longer needed
    double compatibilityFielddataOverheadDefault = DEFAULT_FIELDDATA_OVERHEAD_CONSTANT;
    Double compatibilityFielddataOverhead = settings.getAsDouble(OLD_CIRCUIT_BREAKER_OVERHEAD_SETTING, null);
    if (compatibilityFielddataOverhead != null) {
        compatibilityFielddataOverheadDefault = compatibilityFielddataOverhead;
    }

    this.fielddataSettings = new BreakerSettings(CircuitBreaker.FIELDDATA,
            settings.getAsMemory(FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, compatibilityFielddataLimitDefault).bytes(),
            settings.getAsDouble(FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, compatibilityFielddataOverheadDefault),
            CircuitBreaker.Type.parseValue(settings.get(FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING, DEFAULT_BREAKER_TYPE))
    );

    this.requestSettings = new BreakerSettings(CircuitBreaker.REQUEST,
            settings.getAsMemory(REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, DEFAULT_REQUEST_BREAKER_LIMIT).bytes(),
            settings.getAsDouble(REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, 1.0),
            CircuitBreaker.Type.parseValue(settings.get(REQUEST_CIRCUIT_BREAKER_TYPE_SETTING, DEFAULT_BREAKER_TYPE))
    );

    this.parentSettings = new BreakerSettings(CircuitBreaker.PARENT,
            settings.getAsMemory(TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, DEFAULT_TOTAL_CIRCUIT_BREAKER_LIMIT).bytes(), 1.0, CircuitBreaker.Type.PARENT);
    if (logger.isTraceEnabled()) {
        logger.trace("parent circuit breaker with settings {}", this.parentSettings);
    }

    registerBreaker(this.requestSettings);
    registerBreaker(this.fielddataSettings);

    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 18
Source File: ShardsLimitAllocationDecider.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public ShardsLimitAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    this.clusterShardLimit = settings.getAsInt(CLUSTER_TOTAL_SHARDS_PER_NODE, DEFAULT_SHARD_LIMIT);
    nodeSettingsService.addListener(new ApplySettings());
}
 
Example 19
Source File: DestructiveOperations.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public DestructiveOperations(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    destructiveRequiresName = settings.getAsBoolean(DestructiveOperations.REQUIRES_NAME, DEFAULT_REQUIRES_NAME);
    nodeSettingsService.addListener(this);
}
 
Example 20
Source File: SnapshotInProgressAllocationDecider.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public SnapshotInProgressAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    enableRelocation = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED, enableRelocation);
    nodeSettingsService.addListener(new ApplySettings());
}