当前位置: 首页>>代码示例>>Java>>正文


Java TimeValue.millis方法代码示例

本文整理汇总了Java中org.elasticsearch.common.unit.TimeValue.millis方法的典型用法代码示例。如果您正苦于以下问题:Java TimeValue.millis方法的具体用法?Java TimeValue.millis怎么用?Java TimeValue.millis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.unit.TimeValue的用法示例。


在下文中一共展示了TimeValue.millis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRefreshSettings

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的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;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:DiscoverySettings.java

示例2: DefaultSearchContext

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget,
                            Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard,
                            ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
                            BigArrays bigArrays, Counter timeEstimateCounter, ParseFieldMatcher parseFieldMatcher,
                            TimeValue timeout
) {
    super(parseFieldMatcher, request);
    this.id = id;
    this.request = request;
    this.searchType = request.searchType();
    this.shardTarget = shardTarget;
    this.engineSearcher = engineSearcher;
    this.scriptService = scriptService;
    this.pageCacheRecycler = pageCacheRecycler;
    // SearchContexts use a BigArrays that can circuit break
    this.bigArrays = bigArrays.withCircuitBreaking();
    this.dfsResult = new DfsSearchResult(id, shardTarget);
    this.queryResult = new QuerySearchResult(id, shardTarget);
    this.fetchResult = new FetchSearchResult(id, shardTarget);
    this.indexShard = indexShard;
    this.indexService = indexService;
    this.searcher = new ContextIndexSearcher(engineSearcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
    this.timeEstimateCounter = timeEstimateCounter;
    this.timeoutInMillis = timeout.millis();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:DefaultSearchContext.java

示例3: setConnectTimeout

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
/**
 * Sets a connect timeout for this connection profile
 */
public void setConnectTimeout(TimeValue connectTimeout) {
    if (connectTimeout.millis() < 0) {
        throw new IllegalArgumentException("connectTimeout must be non-negative but was: " + connectTimeout);
    }
    this.connectTimeout = connectTimeout;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ConnectionProfile.java

示例4: setHandshakeTimeout

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
/**
 * Sets a handshake timeout for this connection profile
 */
public void setHandshakeTimeout(TimeValue handshakeTimeout) {
    if (handshakeTimeout.millis() < 0) {
        throw new IllegalArgumentException("handshakeTimeout must be non-negative but was: " + handshakeTimeout);
    }
    this.handshakeTimeout = handshakeTimeout;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ConnectionProfile.java

示例5: parseTimeValue

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public static TimeValue parseTimeValue(String s, TimeValue minValue, String key) {
    TimeValue timeValue = TimeValue.parseTimeValue(s, null, key);
    if (timeValue.millis() < minValue.millis()) {
        throw new IllegalArgumentException("Failed to parse value [" + s + "] for setting [" + key + "] must be >= " + minValue);
    }
    return timeValue;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:Setting.java

示例6: timeSetting

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public static Setting<TimeValue> timeSetting(String key, Function<Settings, TimeValue> defaultValue, TimeValue minValue,
                                             Property... properties) {
    return new Setting<>(key, (s) -> defaultValue.apply(s).getStringRep(), (s) -> {
        TimeValue timeValue = TimeValue.parseTimeValue(s, null, key);
        if (timeValue.millis() < minValue.millis()) {
            throw new IllegalArgumentException("Failed to parse value [" + s + "] for setting [" + key + "] must be >= " + minValue);
        }
        return timeValue;
    }, properties);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Setting.java

示例7: waitForNoBlocksOnNode

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public Set<ClusterBlock> waitForNoBlocksOnNode(TimeValue timeout, Client nodeClient) throws InterruptedException {
    long start = System.currentTimeMillis();
    Set<ClusterBlock> blocks;
    do {
        blocks = nodeClient.admin().cluster().prepareState().setLocal(true).execute().actionGet()
                .getState().blocks().global(ClusterBlockLevel.METADATA_WRITE);
    }
    while (!blocks.isEmpty() && (System.currentTimeMillis() - start) < timeout.millis());
    return blocks;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RecoverAfterNodesIT.java

示例8: waitForBlock

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public void waitForBlock(String node, String repository, TimeValue timeout) throws InterruptedException {
    long start = System.currentTimeMillis();
    RepositoriesService repositoriesService = internalCluster().getInstance(RepositoriesService.class, node);
    MockRepository mockRepository = (MockRepository) repositoriesService.repository(repository);
    while (System.currentTimeMillis() - start < timeout.millis()) {
        if (mockRepository.blocked()) {
            return;
        }
        Thread.sleep(100);
    }
    fail("Timeout!!!");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:AbstractSnapshotIntegTestCase.java

示例9: waitForCompletion

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public SnapshotInfo waitForCompletion(String repository, String snapshotName, TimeValue timeout) throws InterruptedException {
    long start = System.currentTimeMillis();
    while (System.currentTimeMillis() - start < timeout.millis()) {
        List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots(repository).setSnapshots(snapshotName).get().getSnapshots();
        assertThat(snapshotInfos.size(), equalTo(1));
        if (snapshotInfos.get(0).state().completed()) {
            // Make sure that snapshot clean up operations are finished
            ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get();
            SnapshotsInProgress snapshotsInProgress = stateResponse.getState().custom(SnapshotsInProgress.TYPE);
            if (snapshotsInProgress == null) {
                return snapshotInfos.get(0);
            } else {
                boolean found = false;
                for (SnapshotsInProgress.Entry entry : snapshotsInProgress.entries()) {
                    final Snapshot curr = entry.snapshot();
                    if (curr.getRepository().equals(repository) && curr.getSnapshotId().getName().equals(snapshotName)) {
                        found = true;
                        break;
                    }
                }
                if (found == false) {
                    return snapshotInfos.get(0);
                }
            }
        }
        Thread.sleep(100);
    }
    fail("Timeout!!!");
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:AbstractSnapshotIntegTestCase.java

示例10: OsService

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:OsService.java

示例11: ProcessService

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
@Inject
public ProcessService(Settings settings, ProcessProbe probe) {
    super(settings);
    this.probe = probe;

    final TimeValue refreshInterval = settings.getAsTime("monitor.process.refresh_interval", TimeValue.timeValueSeconds(1));
    processStatsCache = new ProcessStatsCache(refreshInterval, probe.processStats());
    this.info = probe.processInfo();
    this.info.refreshInterval = refreshInterval.millis();
    logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:ProcessService.java

示例12: waitForNextChange

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
/**
 * Wait for the next cluster state which satisfies statePredicate
 *
 * @param listener        callback listener
 * @param statePredicate predicate to check whether cluster state changes are relevant and the callback should be called
 * @param timeOutValue    a timeout for waiting. If null the global observer timeout will be used.
 */
public void waitForNextChange(Listener listener, Predicate<ClusterState> statePredicate, @Nullable TimeValue timeOutValue) {
    listener = new ContextPreservingListener(listener, contextHolder.newRestorableContext(false));
    if (observingContext.get() != null) {
        throw new ElasticsearchException("already waiting for a cluster state change");
    }

    Long timeoutTimeLeftMS;
    if (timeOutValue == null) {
        timeOutValue = this.timeOutValue;
        if (timeOutValue != null) {
            long timeSinceStartMS = TimeValue.nsecToMSec(System.nanoTime() - startTimeNS);
            timeoutTimeLeftMS = timeOutValue.millis() - timeSinceStartMS;
            if (timeoutTimeLeftMS <= 0L) {
                // things have timeout while we were busy -> notify
                logger.trace("observer timed out. notifying listener. timeout setting [{}], time since start [{}]", timeOutValue, new TimeValue(timeSinceStartMS));
                // update to latest, in case people want to retry
                timedOut = true;
                lastObservedState.set(new StoredState(clusterService.state()));
                listener.onTimeout(timeOutValue);
                return;
            }
        } else {
            timeoutTimeLeftMS = null;
        }
    } else {
        this.startTimeNS = System.nanoTime();
        this.timeOutValue = timeOutValue;
        timeoutTimeLeftMS = timeOutValue.millis();
        timedOut = false;
    }

    // sample a new state. This state maybe *older* than the supplied state if we are called from an applier,
    // which wants to wait for something else to happen
    ClusterState newState = clusterService.state();
    if (lastObservedState.get().isOlderOrDifferentMaster(newState) && statePredicate.test(newState)) {
        // good enough, let's go.
        logger.trace("observer: sampled state accepted by predicate ({})", newState);
        lastObservedState.set(new StoredState(newState));
        listener.onNewClusterState(newState);
    } else {
        logger.trace("observer: sampled state rejected by predicate ({}). adding listener to ClusterService", newState);
        final ObservingContext context = new ObservingContext(listener, statePredicate);
        if (!observingContext.compareAndSet(null, context)) {
            throw new ElasticsearchException("already waiting for a cluster state change");
        }
        clusterService.addTimeoutListener(timeoutTimeLeftMS == null ? null : new TimeValue(timeoutTimeLeftMS), clusterStateListener);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:56,代码来源:ClusterStateObserver.java

示例13: Builder

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public Builder(TimeValue interval) {
    this.unit = null;
    if (interval.millis() < 1)
        throw new IllegalArgumentException("Zero or negative time interval not supported");
    this.interval = interval.millis();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:Rounding.java

示例14: checkDelay

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
private static TimeValue checkDelay(TimeValue delay) {
    if (delay.millis() > Integer.MAX_VALUE) {
        throw new IllegalArgumentException("delay must be <= " + Integer.MAX_VALUE + " ms");
    }
    return delay;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:BackoffPolicy.java

示例15: GoogleCloudStorageRepository

import org.elasticsearch.common.unit.TimeValue; //导入方法依赖的package包/类
public GoogleCloudStorageRepository(RepositoryMetaData metadata, Environment environment,
                                    NamedXContentRegistry namedXContentRegistry,
                                    GoogleCloudStorageService storageService) throws Exception {
    super(metadata, environment.settings(), namedXContentRegistry);

    String bucket = getSetting(BUCKET, metadata);
    String application = getSetting(APPLICATION_NAME, metadata);
    String serviceAccount = getSetting(SERVICE_ACCOUNT, metadata);

    String basePath = BASE_PATH.get(metadata.settings());
    if (Strings.hasLength(basePath)) {
        BlobPath path = new BlobPath();
        for (String elem : basePath.split("/")) {
            path = path.add(elem);
        }
        this.basePath = path;
    } else {
        this.basePath = BlobPath.cleanPath();
    }

    TimeValue connectTimeout = null;
    TimeValue readTimeout = null;

    TimeValue timeout = HTTP_CONNECT_TIMEOUT.get(metadata.settings());
    if ((timeout != null) && (timeout.millis() != NO_TIMEOUT.millis())) {
        connectTimeout = timeout;
    }

    timeout = HTTP_READ_TIMEOUT.get(metadata.settings());
    if ((timeout != null) && (timeout.millis() != NO_TIMEOUT.millis())) {
        readTimeout = timeout;
    }

    this.compress = getSetting(COMPRESS, metadata);
    this.chunkSize = getSetting(CHUNK_SIZE, metadata);

    logger.debug("using bucket [{}], base_path [{}], chunk_size [{}], compress [{}], application [{}]",
            bucket, basePath, chunkSize, compress, application);

    Storage client = storageService.createClient(serviceAccount, application, connectTimeout, readTimeout);
    this.blobStore = new GoogleCloudStorageBlobStore(settings, bucket, client);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:43,代码来源:GoogleCloudStorageRepository.java


注:本文中的org.elasticsearch.common.unit.TimeValue.millis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。