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


Java TimeValue.timeValueMinutes方法代碼示例

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


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

示例1: deleteAll

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public void deleteAll() {
    Client client = getConnection().getClient();

    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setPostFilter(QueryBuilders.matchAllQuery())
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();
    do {
       Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToHttpSourceTest)
                .map(HttpSourceTest::getUrl)
                .forEach(this::delete);
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:27,代碼來源:EsHttpSourceTestOperations.java

示例2: deleteAll

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public void deleteAll() {
    Client client = getConnection().getClient();

    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setPostFilter(QueryBuilders.matchAllQuery())
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();
    do {
       Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToNamedQuery)
                .forEach(this::delete);
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:26,代碼來源:EsNamedQueryOperations.java

示例3: deleteAll

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public void deleteAll() {
    Client client = getConnection().getClient();

    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setPostFilter(QueryBuilders.matchAllQuery())
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();
    do {
       Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToHttpSource)
                .map(HttpSource::getUrl)
                .forEach(this::delete);
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:27,代碼來源:EsHttpSourceOperations.java

示例4: getTimeValue

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
/**
 * Returns TimeValue based on the given interval
 * Interval can be in minutes, seconds, mili seconds
 */
public static TimeValue getTimeValue(String interval, String defaultValue) {
    TimeValue timeValue = null;
    String timeInterval = interval != null ? interval : defaultValue;
    logger.trace("Time interval is [{}] ", timeInterval);
    if (timeInterval != null) {
        Integer time = Integer.valueOf(timeInterval.substring(0, timeInterval.length() - 1));
        String unit = timeInterval.substring(timeInterval.length() - 1);
        UnitEnum unitEnum = UnitEnum.fromString(unit);
        switch (unitEnum) {
            case MINUTE:
                timeValue = TimeValue.timeValueMinutes(time);
                break;
            case SECOND:
                timeValue = TimeValue.timeValueSeconds(time);
                break;
            case MILI_SECOND:
                timeValue = TimeValue.timeValueMillis(time);
                break;
            default:
                logger.error("Unit is incorrect, please check the Time Value unit: " + unit);
        }
    }
    return timeValue;
}
 
開發者ID:cognitree,項目名稱:flume-elasticsearch-sink,代碼行數:29,代碼來源:Util.java

示例5: all

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public List<NamedQuery> all() {
    Client client = getConnection().getClient();
    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setQuery(QueryBuilders.matchAllQuery())
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();

    List<NamedQuery> result = Lists.newArrayList();
    do {
        result.addAll(Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToNamedQuery)
                .collect(Collectors.toList()));
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
    return result;
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:28,代碼來源:EsNamedQueryOperations.java

示例6: all

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public List<HttpSourceTest> all() {
    BoolQueryBuilder filter = QueryBuilders.boolQuery()
            .must(QueryBuilders.existsQuery("source_url"));


    Client client = getConnection().getClient();
    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setPostFilter(filter)
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();

    List<HttpSourceTest> result = Lists.newArrayList();
    do {
        result.addAll(Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToHttpSourceTest)
                .collect(Collectors.toList()));
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
    return result;
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:32,代碼來源:EsHttpSourceTestOperations.java

示例7: all

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public List<HttpSource> all() {
    BoolQueryBuilder filter = QueryBuilders.boolQuery()
            .must(QueryBuilders.existsQuery("url"))
            .must(QueryBuilders.existsQuery("name"));


    Client client = getConnection().getClient();
    TimeValue keepAlive = TimeValue.timeValueMinutes(10);
    SearchResponse response = client.prepareSearch(getIndex())
            .setTypes(getType())
            .setPostFilter(filter)
            .setSize(100)
            .setScroll(keepAlive)
            .setFetchSource(true)
            .setExplain(false)
            .execute()
            .actionGet();

    List<HttpSource> result = Lists.newArrayList();
    do {
        result.addAll(Arrays.stream(response.getHits().getHits())
                .map(SearchHit::getSource)
                .filter(Objects::nonNull)
                .map(this::mapToHttpSource)
                .collect(Collectors.toList()));
        response = client.prepareSearchScroll(response.getScrollId())
                .setScroll(keepAlive)
                .execute()
                .actionGet();
    } while (response.getHits().getHits().length != 0);
    return result;
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:33,代碼來源:EsHttpSourceOperations.java

示例8: expectedTimeToHeal

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Override
public TimeValue expectedTimeToHeal() {
    return TimeValue.timeValueMinutes(0);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:BlockClusterStateProcessing.java

示例9: setupListeners

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Before
public void setupListeners() throws Exception {
    // Setup dependencies of the listeners
    maxListeners = randomIntBetween(1, 1000);
    listeners = new RefreshListeners(
            () -> maxListeners,
            () -> engine.refresh("too-many-listeners"),
            // Immediately run listeners rather than adding them to the listener thread pool like IndexShard does to simplify the test.
            Runnable::run,
            logger
            );

    // Now setup the InternalEngine which is much more complicated because we aren't mocking anything
    threadPool = new TestThreadPool(getTestName());
    IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index", Settings.EMPTY);
    ShardId shardId = new ShardId(new Index("index", "_na_"), 1);
    Directory directory = newDirectory();
    DirectoryService directoryService = new DirectoryService(shardId, indexSettings) {
        @Override
        public Directory newDirectory() throws IOException {
            return directory;
        }
    };
    store = new Store(shardId, indexSettings, directoryService, new DummyShardLock(shardId));
    IndexWriterConfig iwc = newIndexWriterConfig();
    TranslogConfig translogConfig = new TranslogConfig(shardId, createTempDir("translog"), indexSettings,
            BigArrays.NON_RECYCLING_INSTANCE);
    Engine.EventListener eventListener = new Engine.EventListener() {
        @Override
        public void onFailedEngine(String reason, @Nullable Exception e) {
            // we don't need to notify anybody in this test
        }
    };
    TranslogHandler translogHandler = new TranslogHandler(xContentRegistry(), shardId.getIndexName(), logger);
    EngineConfig config = new EngineConfig(EngineConfig.OpenMode.CREATE_INDEX_AND_TRANSLOG, shardId, threadPool, indexSettings, null,
            store, new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy()), newMergePolicy(), iwc.getAnalyzer(),
            iwc.getSimilarity(), new CodecService(null, logger), eventListener, translogHandler,
            IndexSearcher.getDefaultQueryCache(), IndexSearcher.getDefaultQueryCachingPolicy(), translogConfig,
            TimeValue.timeValueMinutes(5), listeners, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP);
    engine = new InternalEngine(config);
    listeners.setTranslog(engine.getTranslog());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:43,代碼來源:RefreshListenersTests.java

示例10: defaultValue

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Override
public TimeValue defaultValue() {
    return TimeValue.timeValueMinutes(30);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:CrateTableSettings.java


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