本文整理匯總了Java中org.elasticsearch.common.settings.Settings.getAsTime方法的典型用法代碼示例。如果您正苦於以下問題:Java Settings.getAsTime方法的具體用法?Java Settings.getAsTime怎麽用?Java Settings.getAsTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.common.settings.Settings
的用法示例。
在下文中一共展示了Settings.getAsTime方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onRefreshSettings
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Override
public void onRefreshSettings(Settings settings) {
TimeValue newPublishTimeout = settings.getAsTime(PUBLISH_TIMEOUT,
DiscoverySettings.this.settings.getAsTime(PUBLISH_TIMEOUT, DEFAULT_PUBLISH_TIMEOUT));
if (newPublishTimeout.millis() != publishTimeout.millis()) {
logger.info("updating [{}] from [{}] to [{}]", PUBLISH_TIMEOUT, publishTimeout, newPublishTimeout);
publishTimeout = newPublishTimeout;
}
String newNoMasterBlockValue = settings.get(NO_MASTER_BLOCK);
if (newNoMasterBlockValue != null) {
ClusterBlock newNoMasterBlock = parseNoMasterBlock(newNoMasterBlockValue);
if (newNoMasterBlock != noMasterBlock) {
noMasterBlock = newNoMasterBlock;
}
}
Boolean newPublishDiff = settings.getAsBoolean(PUBLISH_DIFF_ENABLE,
DiscoverySettings.this.settings.getAsBoolean(PUBLISH_DIFF_ENABLE, DEFAULT_PUBLISH_DIFF_ENABLE));
if (newPublishDiff != publishDiff) {
logger.info("updating [{}] from [{}] to [{}]", PUBLISH_DIFF_ENABLE, publishDiff, newPublishDiff);
publishDiff = newPublishDiff;
}
}
示例2: getValidThreshold
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
private static TimeValue getValidThreshold(Settings settings, String key, String level) {
TimeValue threshold = settings.getAsTime(level, null);
if (threshold == null) {
throw new IllegalArgumentException("missing gc_threshold for [" + getThresholdName(key, level) + "]");
}
if (threshold.nanos() <= 0) {
throw new IllegalArgumentException("invalid gc_threshold [" + threshold + "] for [" + getThresholdName(key, level) + "]");
}
return threshold;
}
示例3: InternalClusterInfoService
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@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);
}
示例4: PublishClusterStateVersionAction
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
public PublishClusterStateVersionAction(Settings settings, ClusterService clusterService, TransportService transportService, ClusterStateOpLog clusterStateOpLog) {
super(settings);
this.clusterService = clusterService;
this.transportService = transportService;
this.clusterStateOpLog = clusterStateOpLog;
this.pullFullClusterStateAction = new PullFullClusterStateAction(settings, clusterService, transportService, clusterStateOpLog);
this.fullStateSyncOps = settings.getAsLong(SETTING_FULL_STATE_SYNC_THRESHOLD, 30L);
this.publishTimeout = settings.getAsTime(PUBLISH_TIMEOUT, publishTimeout);
this.transportService.registerRequestHandler(PUBLISH_VERSION_ACTION_NAME, BytesTransportRequest.class, ThreadPool.Names.GENERIC, new PublishClusterStateVersionRequestHandler());
}
示例5: JoinClusterAction
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
public JoinClusterAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, RoutingService routingService) {
super(settings);
this.pingTimeout = this.settings.getAsTime(SETTING_PING_TIMEOUT, timeValueSeconds(3));
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.transportService = transportService;
this.clusterService = clusterService;
this.threadPool = threadPool;
this.routingService = routingService;
transportService.registerRequestHandler(JOIN_ACTION_NAME, JoinRequest.class, ThreadPool.Names.GENERIC, new JoinRequestRequestHandler());
}
示例6: IndicesFieldDataCache
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Inject
public IndicesFieldDataCache(Settings settings, IndicesFieldDataCacheListener indicesFieldDataCacheListener, ThreadPool threadPool) {
super(settings);
this.threadPool = threadPool;
this.indicesFieldDataCacheListener = indicesFieldDataCacheListener;
final String size = settings.get(INDICES_FIELDDATA_CACHE_SIZE_KEY, "-1");
final long sizeInBytes = settings.getAsMemory(INDICES_FIELDDATA_CACHE_SIZE_KEY, "-1").bytes();
CacheBuilder<Key, Accountable> cacheBuilder = CacheBuilder.newBuilder()
.removalListener(this);
if (sizeInBytes > 0) {
cacheBuilder.maximumWeight(sizeInBytes).weigher(new FieldDataWeigher());
}
// defaults to 4, but this is a busy map for all indices, increase it a bit by default
final int concurrencyLevel = settings.getAsInt(FIELDDATA_CACHE_CONCURRENCY_LEVEL, 16);
if (concurrencyLevel <= 0) {
throw new IllegalArgumentException("concurrency_level must be > 0 but was: " + concurrencyLevel);
}
cacheBuilder.concurrencyLevel(concurrencyLevel);
logger.debug("using size [{}] [{}]", size, new ByteSizeValue(sizeInBytes));
cache = cacheBuilder.build();
this.cleanInterval = settings.getAsTime(FIELDDATA_CLEAN_INTERVAL_SETTING, TimeValue.timeValueMinutes(1));
// Start thread that will manage cleaning the field data cache periodically
threadPool.schedule(this.cleanInterval, ThreadPool.Names.SAME,
new FieldDataCacheCleaner(this.cache, this.logger, this.threadPool, this.cleanInterval));
}
示例7: IndicesRequestCache
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@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);
}
示例8: DiskThresholdDecider
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@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));
}
示例9: OsService
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Inject
public OsService(Settings settings, OsProbe probe) {
super(settings);
this.probe = probe;
TimeValue refreshInterval = settings.getAsTime("monitor.os.refresh_interval", TimeValue.timeValueSeconds(1));
this.info = probe.osInfo();
this.info.refreshInterval = refreshInterval.millis();
this.info.allocatedProcessors = EsExecutors.boundedNumberOfProcessors(settings);
osStatsCache = new OsStatsCache(refreshInterval, probe.osStats());
logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
}
示例10: maybeUpdate
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
private TimeValue maybeUpdate(final TimeValue currentValue, final Settings settings, final String key, TimeValue defaultValue) {
final TimeValue value = settings.getAsTime(key, RecoverySettings.this.settings.getAsTime(key, defaultValue));
if (value.equals(currentValue)) {
return currentValue;
}
logger.info("updating [{}] from [{}] to [{}]", key, currentValue, value);
return value;
}
示例11: onRefreshSettings
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Override
public void onRefreshSettings(Settings settings) {
TimeValue newUpdateFrequency = settings.getAsTime(
INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL,
InternalClusterInfoService.this.settings.getAsTime(
INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL));
// ClusterInfoService is only enabled if the DiskThresholdDecider is enabled
Boolean newEnabled = settings.getAsBoolean(
DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
DiskThresholdDecider.DEFAULT_THRESHOLD_ENABLED);
if (newUpdateFrequency != null && !updateFrequency.equals(newUpdateFrequency)) {
if (newUpdateFrequency.getMillis() < TimeValue.timeValueSeconds(10).getMillis()) {
logger.warn("[{}] set too low [{}] (< 10s)", INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, newUpdateFrequency);
throw new IllegalStateException("Unable to set " + INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL + " less than 10 seconds");
} else {
logger.info("updating [{}] from [{}] to [{}]", INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, updateFrequency, newUpdateFrequency);
InternalClusterInfoService.this.updateFrequency = newUpdateFrequency;
}
}
TimeValue newFetchTimeout = settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT,
InternalClusterInfoService.this.settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT, DEFAULT_TIMEOUT)
);
if (newFetchTimeout != null && !fetchTimeout.equals(newFetchTimeout)) {
logger.info("updating fetch timeout [{}] from [{}] to [{}]", INTERNAL_CLUSTER_INFO_TIMEOUT, fetchTimeout, newFetchTimeout);
InternalClusterInfoService.this.fetchTimeout = newFetchTimeout;
}
// We don't log about enabling it here, because the DiskThresholdDecider will already be logging about enable/disable
if (newEnabled != InternalClusterInfoService.this.enabled) {
InternalClusterInfoService.this.enabled = newEnabled;
}
}
示例12: FsService
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Inject
public FsService(Settings settings, FsProbe probe) throws IOException {
super(settings);
this.probe = probe;
TimeValue refreshInterval = settings.getAsTime("monitor.fs.refresh_interval", TimeValue.timeValueSeconds(10));
fsStatsCache = new FsInfoCache(refreshInterval, probe.stats());
logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
}
示例13: DiscoverySettings
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@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);
}
示例14: DiscoveryService
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Inject
public DiscoveryService(Settings settings, DiscoverySettings discoverySettings, Discovery discovery) {
super(settings);
this.discoverySettings = discoverySettings;
this.discovery = discovery;
this.initialStateTimeout = settings.getAsTime(SETTING_INITIAL_STATE_TIMEOUT, TimeValue.timeValueSeconds(30));
}
示例15: onRefreshSettings
import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
@Override
public void onRefreshSettings(Settings settings) {
final TimeValue maybeNewDefaultSearchTimeout = settings.getAsTime(SearchService.DEFAULT_SEARCH_TIMEOUT,
SearchService.this.settings.getAsTime(DEFAULT_SEARCH_TIMEOUT, NO_TIMEOUT));
if (!maybeNewDefaultSearchTimeout.equals(SearchService.this.defaultSearchTimeout)) {
logger.info("updating [{}] from [{}] to [{}]", SearchService.DEFAULT_SEARCH_TIMEOUT, SearchService.this.defaultSearchTimeout, maybeNewDefaultSearchTimeout);
SearchService.this.defaultSearchTimeout = maybeNewDefaultSearchTimeout;
}
}