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


Java IndexStats类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.indices.stats.IndexStats的典型用法代码示例。如果您正苦于以下问题:Java IndexStats类的具体用法?Java IndexStats怎么用?Java IndexStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: preCreateIndex

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
void preCreateIndex(Client client, IndexMetadata indexMetadata, DateTime dateTime) throws UnsupportedAutoIndexException {
    logger.info("Pre-creating indices for {}*", indexMetadata.getIndexName());

    IndicesStatsResponse indicesStatsResponse = getIndicesStatsResponse(client);
    Map<String, IndexStats> indexStatsMap = indicesStatsResponse.getIndices();

    if (indexStatsMap == null || indexStatsMap.isEmpty()) {
        logger.info("No existing indices, no need to pre-create");
        return;
    }

    indexStatsMap.keySet().stream().filter(indexName -> indexMetadata.getIndexNameFilter().filter(indexName) &&
            indexMetadata.getIndexNameFilter().getNamePart(indexName).equalsIgnoreCase(indexMetadata.getIndexName()))
            .findFirst().ifPresent(indexName -> {
        try {
            createIndex(client, IndexUtils.getIndexNameToPreCreate(indexMetadata, dateTime));
        } catch (UnsupportedAutoIndexException e) {
            logger.error("Invalid index metadata: " + indexMetadata.toString(), e);
        }
    });
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:22,代码来源:ElasticsearchIndexManager.java

示例2: testRunIndexManagement_NotActionable_NoIndex

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
@Test
public void testRunIndexManagement_NotActionable_NoIndex() throws Exception {
    String serializedIndexMetadata = "[{\"retentionType\": \"yearly\", \"retentionPeriod\": 20}]";
    when(config.getIndexMetadata()).thenReturn(serializedIndexMetadata);

    Map<String, IndexStats> indexStats = new HashMap<>();
    indexStats.put("nf_errors_log2018", new IndexStats("nf_errors_log2018", new ShardStats[]{}));

    IndicesStatsResponse indicesStatsResponse = mock(IndicesStatsResponse.class);
    when(indicesStatsResponse.getIndices()).thenReturn(indexStats);

    doReturn(indicesStatsResponse).when(elasticsearchIndexManager).getIndicesStatsResponse(elasticsearchClient);

    elasticsearchIndexManager.runIndexManagement();

    verify(elasticsearchIndexManager, times(0)).checkIndexRetention(any(Client.class), anySet(), any(IndexMetadata.class), any(DateTime.class));
    verify(elasticsearchIndexManager, times(0)).preCreateIndex(any(Client.class), any(IndexMetadata.class), any(DateTime.class));
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:19,代码来源:TestElasticsearchIndexManager.java

示例3: testRunIndexManagement_NotActionable_NoRetentionPeriod

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
@Test
public void testRunIndexManagement_NotActionable_NoRetentionPeriod() throws Exception {
    String serializedIndexMetadata = "[{\"retentionType\": \"yearly\", \"indexName\": \"nf_errors_log\"}]";
    when(config.getIndexMetadata()).thenReturn(serializedIndexMetadata);

    Map<String, IndexStats> indexStats = new HashMap<>();
    indexStats.put("nf_errors_log2018", new IndexStats("nf_errors_log2018", new ShardStats[]{}));

    IndicesStatsResponse indicesStatsResponse = mock(IndicesStatsResponse.class);
    when(indicesStatsResponse.getIndices()).thenReturn(indexStats);

    doReturn(indicesStatsResponse).when(elasticsearchIndexManager).getIndicesStatsResponse(elasticsearchClient);

    elasticsearchIndexManager.runIndexManagement();

    verify(elasticsearchIndexManager, times(0)).checkIndexRetention(any(Client.class), anySet(), any(IndexMetadata.class), any(DateTime.class));
    verify(elasticsearchIndexManager, times(0)).preCreateIndex(any(Client.class), any(IndexMetadata.class), any(DateTime.class));
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:19,代码来源:TestElasticsearchIndexManager.java

示例4: testCheckIndexRetention_Overlapping

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
@Test
public void testCheckIndexRetention_Overlapping() throws Exception {
    String serializedIndexMetadata = "[{\"preCreate\": false, \"retentionType\": \"hourly\", \"retentionPeriod\": 2, \"indexName\": \"nf_errors_log\"}," +
            "{\"preCreate\": false, \"retentionType\": \"yearly\", \"retentionPeriod\": 3, \"indexName\": \"nf_errors_log201712\"}]";
    List<IndexMetadata> indexMetadataList = IndexUtils.parseIndexMetadata(serializedIndexMetadata);

    Map<String, IndexStats> indexStats = new HashMap<>();
    indexStats.put("nf_errors_log2017121110", new IndexStats("nf_errors_log2017121110", new ShardStats[]{}));
    indexStats.put("nf_errors_log2017121111", new IndexStats("nf_errors_log2017121111", new ShardStats[]{}));
    indexStats.put("nf_errors_log2017121112", new IndexStats("nf_errors_log2017121112", new ShardStats[]{}));
    indexStats.put("nf_errors_log2017121113", new IndexStats("nf_errors_log2017121113", new ShardStats[]{}));
    indexStats.put("nf_errors_log2017121114", new IndexStats("nf_errors_log2017121114", new ShardStats[]{}));

    IndicesStatsResponse indicesStatsResponse = mock(IndicesStatsResponse.class);
    when(indicesStatsResponse.getIndices()).thenReturn(indexStats);

    doReturn(indicesStatsResponse).when(elasticsearchIndexManager).getIndicesStatsResponse(elasticsearchClient);

    elasticsearchIndexManager.runIndexManagement(elasticsearchClient, indexMetadataList, new DateTime("2017-12-11T13:30Z"));

    verify(elasticsearchIndexManager, times(2)).checkIndexRetention(any(Client.class), anySet(), any(IndexMetadata.class), any(DateTime.class));
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:23,代码来源:TestElasticsearchIndexManager.java

示例5: assertCumulativeQueryCacheStats

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
private void assertCumulativeQueryCacheStats(IndicesStatsResponse response) {
    assertAllSuccessful(response);
    QueryCacheStats total = response.getTotal().queryCache;
    QueryCacheStats indexTotal = new QueryCacheStats();
    QueryCacheStats shardTotal = new QueryCacheStats();
    for (IndexStats indexStats : response.getIndices().values()) {
        indexTotal.add(indexStats.getTotal().queryCache);
        for (ShardStats shardStats : response.getShards()) {
            shardTotal.add(shardStats.getStats().queryCache);
        }
    }
    assertEquals(total, indexTotal);
    assertEquals(total, shardTotal);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:IndexStatsIT.java

示例6: logIndexStats

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
private void logIndexStats(Map<String, IndexStats> indexStatsMap) {
  for (IndexStats stat : indexStatsMap.values()) {
    String indexKey = "esindex_" + stat.getIndex();
    Stats.setGauge(StatsUtil.getStatsName(indexKey, "primaryDocCount"),
        stat.getPrimaries().getDocs().getCount());
    Stats.setGauge(StatsUtil.getStatsName(indexKey, "totalDocCount"),
        stat.getTotal().getDocs().getCount());
    Stats.setGauge(StatsUtil.getStatsName(indexKey, "shardsCount"),
        stat.getShards().length);
    Stats.setGauge(StatsUtil.getStatsName(indexKey, "primaryStoreSizeMB"),
        stat.getPrimaries().getStore().getSize().getMbFrac());
    Stats.setGauge(StatsUtil.getStatsName(indexKey, "totalStoreSizeMB"),
        stat.getTotal().getStore().getSize().getMbFrac());
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:16,代码来源:ElasticSearchHealthCheckJob.java

示例7: getAllIndicesStats

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
/**
 * Gets the all indices stats.
 *
 * @return the all indices stats
 */
public Map<String, IndexStats> getAllIndicesStats() {
	IndicesStatsRequestBuilder indicesStatsRequestBuilder =
			admin().indices().prepareStats().all();
	return JMElastricsearchUtil.logExcuteAndReturn("getAllIndicesStats",
			indicesStatsRequestBuilder,
			indicesStatsRequestBuilder.execute()).getIndices();
}
 
开发者ID:JM-Lab,项目名称:utils-elasticsearch,代码行数:13,代码来源:JMElasticsearchClient.java

示例8: runIndexManagement

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
void runIndexManagement(Client esTransportClient, List<IndexMetadata> indexMetadataList, DateTime dateTime) {
    // Find all the indices
    IndicesStatsResponse indicesStatsResponse = getIndicesStatsResponse(esTransportClient);
    Map<String, IndexStats> indexStatsMap = indicesStatsResponse.getIndices();

    if (indexStatsMap == null || indexStatsMap.isEmpty()) {
        logger.info("Cluster is empty, no indices found");
        return;
    }

    for (IndexMetadata indexMetadata : indexMetadataList) {
        if (!indexMetadata.isActionable()) {
            logger.warn(String.format("Index metadata %s is not actionable, skipping", indexMetadata));
            continue;
        }

        try {
            checkIndexRetention(esTransportClient, indexStatsMap.keySet(), indexMetadata, dateTime);

            if (indexMetadata.isPreCreate()) {
                preCreateIndex(esTransportClient, indexMetadata, dateTime);
            }
        } catch (Exception e) {
            logger.error("Caught an exception while building index metadata information from configuration property");
            return;
        }
    }
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:29,代码来源:ElasticsearchIndexManager.java

示例9: testRunIndexManagement

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
@Test
public void testRunIndexManagement() throws Exception {
    String serializedIndexMetadata = "[{\"retentionType\": \"yearly\", \"retentionPeriod\": 3, \"indexName\": \"nf_errors_log\"}]";
    when(config.getIndexMetadata()).thenReturn(serializedIndexMetadata);

    Map<String, IndexStats> indexStats = new HashMap<>();
    indexStats.put("nf_errors_log2018", new IndexStats("nf_errors_log2018", new ShardStats[]{}));
    indexStats.put("nf_errors_log2017", new IndexStats("nf_errors_log2017", new ShardStats[]{}));
    indexStats.put("nf_errors_log2016", new IndexStats("nf_errors_log2016", new ShardStats[]{}));
    indexStats.put("nf_errors_log2015", new IndexStats("nf_errors_log2015", new ShardStats[]{}));
    indexStats.put("nf_errors_log2014", new IndexStats("nf_errors_log2014", new ShardStats[]{}));
    indexStats.put("nf_errors_log2013", new IndexStats("nf_errors_log2013", new ShardStats[]{}));
    indexStats.put("nf_errors_log2012", new IndexStats("nf_errors_log2012", new ShardStats[]{}));

    IndicesStatsResponse indicesStatsResponse = mock(IndicesStatsResponse.class);
    when(indicesStatsResponse.getIndices()).thenReturn(indexStats);

    doReturn(indicesStatsResponse).when(elasticsearchIndexManager).getIndicesStatsResponse(elasticsearchClient);

    elasticsearchIndexManager.runIndexManagement();

    verify(elasticsearchIndexManager, times(1)).checkIndexRetention(any(Client.class), anySet(), any(IndexMetadata.class), any(DateTime.class));

    verify(elasticsearchIndexManager, times(1)).deleteIndices(any(Client.class), eq("nf_errors_log2012"), eq(AUTO_CREATE_INDEX_TIMEOUT));
    verify(elasticsearchIndexManager, times(1)).deleteIndices(any(Client.class), eq("nf_errors_log2013"), eq(AUTO_CREATE_INDEX_TIMEOUT));

    verify(elasticsearchIndexManager, times(0)).preCreateIndex(any(Client.class), any(IndexMetadata.class), any(DateTime.class));
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:29,代码来源:TestElasticsearchIndexManager.java

示例10: check

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
/**
 * Perform a check of the number of documents in the Elasticsearch indices.
 *
 * @return if the Elasticsearch indices contain the minimal number of documents, a healthy
 *         {@link com.codahale.metrics.health.HealthCheck.Result}; otherwise, an unhealthy
 *         {@link com.codahale.metrics.health.HealthCheck.Result} with a descriptive error message or exception
 * @throws Exception if there is an unhandled error during the health check; this will result in
 *                   a failed health check
 */
@Override
protected Result check() throws Exception {
    final IndicesStatsResponse indicesStatsResponse = client.admin().indices().prepareStats(indices).get();

    final List<String> indexDetails = new ArrayList<String>(indices.length);
    boolean healthy = true;

    for (IndexStats indexStats : indicesStatsResponse.getIndices().values()) {
        long documentCount = indexStats.getPrimaries().getDocs().getCount();

        if (documentCount < documentThreshold) {
            healthy = false;
            indexDetails.add(String.format("%s (%d)", indexStats.getIndex(), documentCount));
        } else {
            indexDetails.add(String.format("%s (%d!)", indexStats.getIndex(), documentCount));
        }
    }

    final String resultDetails = String.format("Last stats: %s", indexDetails);

    if (healthy) {
        return Result.healthy(resultDetails);
    } else {
        return Result.unhealthy(resultDetails);
    }
}
 
开发者ID:dropwizard,项目名称:dropwizard-elasticsearch,代码行数:36,代码来源:EsIndexDocsHealthCheck.java

示例11: testSyncedFlushWithConcurrentIndexing

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
public void testSyncedFlushWithConcurrentIndexing() throws Exception {

        internalCluster().ensureAtLeastNumDataNodes(3);
        createIndex("test");

        client().admin().indices().prepareUpdateSettings("test").setSettings(
                Settings.builder().put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB)).put("index.refresh_interval", -1).put("index.number_of_replicas", internalCluster().numDataNodes() - 1))
                .get();
        ensureGreen();
        final AtomicBoolean stop = new AtomicBoolean(false);
        final AtomicInteger numDocs = new AtomicInteger(0);
        Thread indexingThread = new Thread() {
            @Override
            public void run() {
                while (stop.get() == false) {
                    client().prepareIndex().setIndex("test").setType("doc").setSource("{}", XContentType.JSON).get();
                    numDocs.incrementAndGet();
                }
            }
        };
        indexingThread.start();

        IndexStats indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
        for (ShardStats shardStats : indexStats.getShards()) {
            assertNull(shardStats.getCommitStats().getUserData().get(Engine.SYNC_COMMIT_ID));
        }
        logger.info("--> trying sync flush");
        SyncedFlushResponse syncedFlushResult = client().admin().indices().prepareSyncedFlush("test").get();
        logger.info("--> sync flush done");
        stop.set(true);
        indexingThread.join();
        indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
        assertFlushResponseEqualsShardStats(indexStats.getShards(), syncedFlushResult.getShardsResultPerIndex().get("test"));
        refresh();
        assertThat(client().prepareSearch().setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs.get()));
        logger.info("indexed {} docs", client().prepareSearch().setSize(0).get().getHits().getTotalHits());
        logClusterState();
        internalCluster().fullRestart();
        ensureGreen();
        assertThat(client().prepareSearch().setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs.get()));
    }
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:42,代码来源:FlushIT.java

示例12: assertSyncIdsNotNull

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
public static void assertSyncIdsNotNull() {
    IndexStats indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
    for (ShardStats shardStats : indexStats.getShards()) {
        assertNotNull(shardStats.getCommitStats().getUserData().get(Engine.SYNC_COMMIT_ID));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ReusePeerRecoverySharedTest.java

示例13: assertSyncIdsNotNull

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
public void assertSyncIdsNotNull() {
    IndexStats indexStats = client().admin().indices().prepareStats("test").get().getIndex("test");
    for (ShardStats shardStats : indexStats.getShards()) {
        assertNotNull(shardStats.getCommitStats().getUserData().get(Engine.SYNC_COMMIT_ID));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:RecoveryFromGatewayIT.java

示例14: getIndexStats

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
public Map<String, IndexStats> getIndexStats() throws Exception {
  IndicesStatsResponse resp = esClient.admin().indices().prepareStats().all().get();
  return resp.getIndices();
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:5,代码来源:EsInstanceStore.java

示例15: getIndex

import org.elasticsearch.action.admin.indices.stats.IndexStats; //导入依赖的package包/类
public IndexStats getIndex(String index) {
    return getIndices().get(index);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:IndexShardStatsResponse.java


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