Java源码示例:org.elasticsearch.node.settings.NodeSettingsService
示例1
@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();
}
示例2
@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());
}
示例3
@Inject
public IndicesStore(Settings settings, NodeSettingsService nodeSettingsService, IndicesService indicesService,
ClusterService clusterService, TransportService transportService) {
super(settings);
this.nodeSettingsService = nodeSettingsService;
this.indicesService = indicesService;
this.clusterService = clusterService;
this.transportService = transportService;
transportService.registerRequestHandler(ACTION_SHARD_EXISTS, ShardActiveRequest.class, ThreadPool.Names.SAME, new ShardActiveRequestHandler());
// we don't limit by default (we default to CMS's auto throttle instead):
this.rateLimitingType = settings.get("indices.store.throttle.type", DEFAULT_RATE_LIMITING_TYPE);
rateLimiting.setType(rateLimitingType);
this.rateLimitingThrottle = settings.getAsBytesSize("indices.store.throttle.max_bytes_per_sec", DEFAULT_INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC);
rateLimiting.setMaxRate(rateLimitingThrottle);
this.deleteShardTimeout = settings.getAsTime(INDICES_STORE_DELETE_SHARD_TIMEOUT, new TimeValue(30, TimeUnit.SECONDS));
logger.debug("using indices.store.throttle.type [{}], with index.store.throttle.max_bytes_per_sec [{}]", rateLimitingType, rateLimitingThrottle);
nodeSettingsService.addListener(applySettings);
clusterService.addLast(this);
}
示例4
@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());
}
示例5
@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());
}
示例6
@Override
protected void configure() {
if (pageCacheRecyclerImpl == PageCacheRecycler.class) {
bind(PageCacheRecycler.class).asEagerSingleton();
} else {
bind(PageCacheRecycler.class).to(pageCacheRecyclerImpl).asEagerSingleton();
}
if (bigArraysImpl == BigArrays.class) {
bind(BigArrays.class).asEagerSingleton();
} else {
bind(BigArrays.class).to(bigArraysImpl).asEagerSingleton();
}
bind(Node.class).toInstance(node);
bind(NodeSettingsService.class).asEagerSingleton();
bind(NodeService.class).asEagerSingleton();
}
示例7
@Test
public void testCircuitBreakerAdjustmentOnLongTermsSet() {
HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(
Settings.builder().build(),
new NodeSettingsService(Settings.EMPTY));
CircuitBreaker breaker = hcbs.getBreaker(CircuitBreaker.REQUEST);
assertThat(breaker.getUsed(), is(equalTo(0L)));
LongTermsSet termsSet = new LongTermsSet(8, hcbs.getBreaker(CircuitBreaker.REQUEST));
long usedMem = breaker.getUsed();
assertThat(usedMem, greaterThan(0L));
for (int i = 0; i < 16; i++) {
termsSet.add(i);
}
assertThat(breaker.getUsed(), greaterThan(usedMem));
termsSet.release();
assertThat(breaker.getUsed(), is(equalTo(0L)));
}
示例8
@Test
public void testCircuitBreakerAdjustmentOnIntTermsSet() {
HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(
Settings.builder().build(),
new NodeSettingsService(Settings.EMPTY));
CircuitBreaker breaker = hcbs.getBreaker(CircuitBreaker.REQUEST);
assertThat(breaker.getUsed(), is(equalTo(0L)));
IntegerTermsSet termsSet = new IntegerTermsSet(8, hcbs.getBreaker(CircuitBreaker.REQUEST));
long usedMem = breaker.getUsed();
assertThat(usedMem, greaterThan(0L));
for (int i = 0; i < 16; i++) {
termsSet.add(i);
}
assertThat(breaker.getUsed(), greaterThan(usedMem));
termsSet.release();
assertThat(breaker.getUsed(), is(equalTo(0L)));
}
示例9
@Inject
public TransportDeleteNodeAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, DeleteNodeAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteNodeRequest.class);
}
示例10
@Inject
public TransportAddNodeAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, AddNodeAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, AddNodeRequest.class);
}
示例11
@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();
}
示例12
@Inject
public SrvDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool,
TransportService transportService,
ClusterService clusterService,
NodeSettingsService nodeSettingsService,
ZenPingService pingService,
ElectMasterService electMasterService, DiscoverySettings discoverySettings) {
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService, pingService, electMasterService, discoverySettings);
}
示例13
@Inject
public DecommissionAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
super(settings);
ApplySettings applySettings = new ApplySettings();
applySettings.onRefreshSettings(settings);
nodeSettingsService.addListener(applySettings);
}
示例14
@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);
}
}
示例15
@Inject
public IndicesTTLService(Settings settings, ClusterService clusterService, IndicesService indicesService, NodeSettingsService nodeSettingsService, TransportBulkAction bulkAction) {
super(settings);
this.clusterService = clusterService;
this.indicesService = indicesService;
TimeValue interval = this.settings.getAsTime("indices.ttl.interval", DEFAULT_TTL_INTERVAL);
this.bulkAction = bulkAction;
this.bulkSize = this.settings.getAsInt("indices.ttl.bulk_size", 10000);
this.purgerThread = new PurgerThread(EsExecutors.threadName(settings, "[ttl_expire]"), interval);
nodeSettingsService.addListener(new ApplySettings());
}
示例16
@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);
}
示例17
@Inject
public InternalClusterInfoService(Settings settings, NodeSettingsService nodeSettingsService,
TransportNodesStatsAction transportNodesStatsAction,
TransportIndicesStatsAction transportIndicesStatsAction, ClusterService clusterService,
ThreadPool threadPool) {
super(settings);
this.leastAvailableSpaceUsages = Collections.emptyMap();
this.mostAvailableSpaceUsages = Collections.emptyMap();
this.shardRoutingToDataPath = Collections.emptyMap();
this.shardSizes = Collections.emptyMap();
this.transportNodesStatsAction = transportNodesStatsAction;
this.transportIndicesStatsAction = transportIndicesStatsAction;
this.clusterService = clusterService;
this.threadPool = threadPool;
this.updateFrequency = settings.getAsTime(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL);
this.enabled = settings.getAsBoolean(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true);
this.updateFrequency = settings.getAsTime(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL);
this.fetchTimeout = settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT, DEFAULT_TIMEOUT);
this.enabled = settings.getAsBoolean(
DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
DiskThresholdDecider.DEFAULT_THRESHOLD_ENABLED);
nodeSettingsService.addListener(new ApplySettings());
// Add InternalClusterInfoService to listen for Master changes
this.clusterService.add((LocalNodeMasterListener)this);
// Add to listen for state changes (when nodes are added)
this.clusterService.add((ClusterStateListener)this);
}
示例18
@Inject
public BalancedShardsAllocator(Settings settings, NodeSettingsService nodeSettingsService) {
super(settings);
ApplySettings applySettings = new ApplySettings();
applySettings.onRefreshSettings(settings);
nodeSettingsService.addListener(applySettings);
}
示例19
@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());
}
示例20
@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());
}
示例21
@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));
}
示例22
@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);
}
示例23
@Inject
public ConcurrentRebalanceAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
super(settings);
this.clusterConcurrentRebalance = settings.getAsInt(
CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE,
DEFAULT_CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE);
logger.debug("using [cluster_concurrent_rebalance] with [{}]", clusterConcurrentRebalance);
nodeSettingsService.addListener(new ApplySettings());
}
示例24
@Inject
public ThrottlingAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
super(settings);
this.primariesInitialRecoveries = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES, DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES);
this.concurrentRecoveries = settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_CONCURRENT_RECOVERIES, settings.getAsInt(CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES, DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES));
logger.debug("using node_concurrent_recoveries [{}], node_initial_primaries_recoveries [{}]", concurrentRecoveries, primariesInitialRecoveries);
nodeSettingsService.addListener(new ApplySettings());
}
示例25
@Inject
public InternalClusterService(Settings settings, DiscoveryService discoveryService, OperationRouting operationRouting, TransportService transportService,
NodeSettingsService nodeSettingsService, ThreadPool threadPool, ClusterName clusterName, DiscoveryNodeService discoveryNodeService, Version version) {
super(settings);
this.operationRouting = operationRouting;
this.transportService = transportService;
this.discoveryService = discoveryService;
this.threadPool = threadPool;
this.nodeSettingsService = nodeSettingsService;
this.discoveryNodeService = discoveryNodeService;
this.version = version;
// will be replaced on doStart.
this.clusterState = ClusterState.builder(clusterName).build();
this.nodeSettingsService.setClusterService(this);
this.nodeSettingsService.addListener(new ApplySettings());
this.reconnectInterval = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_RECONNECT_INTERVAL, TimeValue.timeValueSeconds(10));
this.slowTaskLoggingThreshold = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD, TimeValue.timeValueSeconds(30));
localNodeMasterListeners = new LocalNodeMasterListeners(threadPool);
initialBlocks = ClusterBlocks.builder().addGlobalBlock(discoveryService.getNoMasterBlock());
taskManager = transportService.getTaskManager();
this.auditService = new AuditService(nodeSettingsService);
}
示例26
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;
}
示例27
@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);
}
示例28
@Inject
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexRequest.class);
this.deleteIndexService = deleteIndexService;
this.destructiveOperations = destructiveOperations;
}
示例29
@Inject
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
DestructiveOperations destructiveOperations) {
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, OpenIndexRequest.class);
this.indexStateService = indexStateService;
this.destructiveOperations = destructiveOperations;
}
示例30
@Test(expected=CircuitBreakingException.class)
public void testCircuitBreakerOnNewLongTermsSet() {
final int size = 42;
HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(
Settings.builder()
.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, size - 1, ByteSizeUnit.BYTES)
.build(),
new NodeSettingsService(Settings.EMPTY));
LongTermsSet termsSet = new LongTermsSet(size, hcbs.getBreaker(CircuitBreaker.REQUEST));
}