當前位置: 首頁>>代碼示例>>Java>>正文


Java TimeValue.getNanos方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.unit.TimeValue.getNanos方法的典型用法代碼示例。如果您正苦於以下問題:Java TimeValue.getNanos方法的具體用法?Java TimeValue.getNanos怎麽用?Java TimeValue.getNanos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.unit.TimeValue的用法示例。


在下文中一共展示了TimeValue.getNanos方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setExpireAfterAccess

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
/**
 * Sets the amount of time before an entry in the cache expires after it was last accessed.
 *
 * @param expireAfterAccess The amount of time before an entry expires after it was last accessed. Must not be {@code null} and must
 *                          be greater than 0.
 */
public CacheBuilder<K, V> setExpireAfterAccess(TimeValue expireAfterAccess) {
    Objects.requireNonNull(expireAfterAccess);
    final long expireAfterAccessNanos = expireAfterAccess.getNanos();
    if (expireAfterAccessNanos <= 0) {
        throw new IllegalArgumentException("expireAfterAccess <= 0");
    }
    this.expireAfterAccessNanos = expireAfterAccessNanos;
    return this;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,代碼來源:CacheBuilder.java

示例2: setExpireAfterWrite

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
/**
 * Sets the amount of time before an entry in the cache expires after it was written.
 *
 * @param expireAfterWrite The amount of time before an entry expires after it was written. Must not be {@code null} and must be
 *                         greater than 0.
 */
public CacheBuilder<K, V> setExpireAfterWrite(TimeValue expireAfterWrite) {
    Objects.requireNonNull(expireAfterWrite);
    final long expireAfterWriteNanos = expireAfterWrite.getNanos();
    if (expireAfterWriteNanos <= 0) {
        throw new IllegalArgumentException("expireAfterWrite <= 0");
    }
    this.expireAfterWriteNanos = expireAfterWriteNanos;
    return this;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,代碼來源:CacheBuilder.java

示例3: ScriptService

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public ScriptService(Settings settings, Environment env,
                     ResourceWatcherService resourceWatcherService, ScriptEngineRegistry scriptEngineRegistry,
                     ScriptContextRegistry scriptContextRegistry, ScriptSettings scriptSettings) throws IOException {
    super(settings);
    Objects.requireNonNull(scriptEngineRegistry);
    Objects.requireNonNull(scriptContextRegistry);
    Objects.requireNonNull(scriptSettings);
    if (Strings.hasLength(settings.get(DISABLE_DYNAMIC_SCRIPTING_SETTING))) {
        throw new IllegalArgumentException(DISABLE_DYNAMIC_SCRIPTING_SETTING + " is not a supported setting, replace with fine-grained script settings. \n" +
                "Dynamic scripts can be enabled for all languages and all operations by replacing `script.disable_dynamic: false` with `script.inline: true` and `script.stored: true` in elasticsearch.yml");
    }

    this.scriptEngines = scriptEngineRegistry.getRegisteredLanguages().values();
    this.scriptContextRegistry = scriptContextRegistry;
    int cacheMaxSize = SCRIPT_CACHE_SIZE_SETTING.get(settings);

    CacheBuilder<CacheKey, CompiledScript> cacheBuilder = CacheBuilder.builder();
    if (cacheMaxSize >= 0) {
        cacheBuilder.setMaximumWeight(cacheMaxSize);
    }

    TimeValue cacheExpire = SCRIPT_CACHE_EXPIRE_SETTING.get(settings);
    if (cacheExpire.getNanos() != 0) {
        cacheBuilder.setExpireAfterAccess(cacheExpire);
    }

    logger.debug("using script cache with max_size [{}], expire [{}]", cacheMaxSize, cacheExpire);
    this.cache = cacheBuilder.removalListener(new ScriptCacheRemovalListener()).build();

    Map<String, ScriptEngineService> enginesByLangBuilder = new HashMap<>();
    Map<String, ScriptEngineService> enginesByExtBuilder = new HashMap<>();
    for (ScriptEngineService scriptEngine : scriptEngines) {
        String language = scriptEngineRegistry.getLanguage(scriptEngine.getClass());
        enginesByLangBuilder.put(language, scriptEngine);
        enginesByExtBuilder.put(scriptEngine.getExtension(), scriptEngine);
    }
    this.scriptEnginesByLang = unmodifiableMap(enginesByLangBuilder);
    this.scriptEnginesByExt = unmodifiableMap(enginesByExtBuilder);

    this.scriptModes = new ScriptModes(scriptSettings, settings);

    // add file watcher for static scripts
    scriptsDirectory = env.scriptsFile();
    if (logger.isTraceEnabled()) {
        logger.trace("Using scripts directory [{}] ", scriptsDirectory);
    }
    FileWatcher fileWatcher = new FileWatcher(scriptsDirectory);
    fileWatcher.addListener(new ScriptChangesListener());

    if (SCRIPT_AUTO_RELOAD_ENABLED_SETTING.get(settings)) {
        // automatic reload is enabled - register scripts
        resourceWatcherService.add(fileWatcher);
    } else {
        // automatic reload is disable just load scripts once
        fileWatcher.init();
    }

    this.lastInlineCompileTime = System.nanoTime();
    this.setMaxCompilationsPerMinute(SCRIPT_MAX_COMPILATIONS_PER_MINUTE.get(settings));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:61,代碼來源:ScriptService.java


注:本文中的org.elasticsearch.common.unit.TimeValue.getNanos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。