Package org.elasticsearch.action.admin.indices.stats

Examples of org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse


    }

    public IndexStatistics getIndexStats(String index) {
        final IndexStatistics stats = new IndexStatistics();
        try {
            IndicesStatsResponse indicesStatsResponse = c.admin().indices().stats(new IndicesStatsRequest().all()).actionGet();
            IndexStats indexStats = indicesStatsResponse.getIndex(index);

            if (indexStats == null) {
                return null;
            }
            stats.setPrimaries(indexStats.getPrimaries());
View Full Code Here


      newIndexHealth.documentCount = indexStat.getDocumentCount();
      newIndexHealth.lastSync = indexStat.getLastUpdate();

      IndicesStatsRequestBuilder statRequest = searchClient.prepareStats(index.getIndexName())
        .setTypes(index.getIndexType());
      IndicesStatsResponse indicesStatsResponse = statRequest.get();
      newIndexHealth.segmentCount = indicesStatsResponse.getTotal().getSegments().getCount();
      newIndexHealth.pendingDeletion = indicesStatsResponse.getTotal().getDocs().getDeleted();

      builder.put(newIndexHealth.name, newIndexHealth);
    }
    return builder.build();
  }
View Full Code Here

    @Test
    public void testIndicesStats() {
        createIndex("test");
        ensureYellow("test");

        IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats().all().get();
        assertThat(indicesStatsResponse.getIndices().size(), equalTo(1));
        assertThat(indicesStatsResponse.getIndices().containsKey("test"), equalTo(true));
    }
View Full Code Here

    public void testSettingLoadBloomFilterDefaultTrue() throws Exception {
        client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.builder().put("number_of_replicas", 0).put("number_of_shards", 1)).get();
        client().prepareIndex("test", "foo").setSource("field", "foo").get();
        ensureGreen();
        refresh();
        IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
        final long segmentsMemoryWithBloom = stats.getTotal().getSegments().getMemoryInBytes();
        logger.info("segments with bloom: {}", segmentsMemoryWithBloom);

        logger.info("updating the setting to unload bloom filters");
        client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(CodecService.INDEX_CODEC_BLOOM_LOAD, false)).get();
        logger.info("waiting for memory to match without blooms");
        awaitBusy(new Predicate<Object>() {
            public boolean apply(Object o) {
                IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
                long segmentsMemoryWithoutBloom = stats.getTotal().getSegments().getMemoryInBytes();
                logger.info("trying segments without bloom: {}", segmentsMemoryWithoutBloom);
                return segmentsMemoryWithoutBloom == (segmentsMemoryWithBloom - BloomFilter.Factory.DEFAULT.createFilter(1).getSizeInBytes());
            }
        });

        logger.info("updating the setting to load bloom filters");
        client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(CodecService.INDEX_CODEC_BLOOM_LOAD, true)).get();
        logger.info("waiting for memory to match with blooms");
        awaitBusy(new Predicate<Object>() {
            public boolean apply(Object o) {
                IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
                long newSegmentsMemoryWithBloom = stats.getTotal().getSegments().getMemoryInBytes();
                logger.info("trying segments with bloom: {}", newSegmentsMemoryWithBloom);
                return newSegmentsMemoryWithBloom == segmentsMemoryWithBloom;
            }
        });
    }
View Full Code Here

        client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.builder().put("number_of_replicas", 0).put("number_of_shards", 1).put(CodecService.INDEX_CODEC_BLOOM_LOAD, false)).get();
        client().prepareIndex("test", "foo").setSource("field", "foo").get();
        ensureGreen();
        refresh();

        IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
        final long segmentsMemoryWithoutBloom = stats.getTotal().getSegments().getMemoryInBytes();
        logger.info("segments without bloom: {}", segmentsMemoryWithoutBloom);

        logger.info("updating the setting to load bloom filters");
        client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(CodecService.INDEX_CODEC_BLOOM_LOAD, true)).get();
        logger.info("waiting for memory to match with blooms");
        awaitBusy(new Predicate<Object>() {
            public boolean apply(Object o) {
                IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
                long segmentsMemoryWithBloom = stats.getTotal().getSegments().getMemoryInBytes();
                logger.info("trying segments with bloom: {}", segmentsMemoryWithoutBloom);
                return segmentsMemoryWithoutBloom == (segmentsMemoryWithBloom - BloomFilter.Factory.DEFAULT.createFilter(1).getSizeInBytes());
            }
        });

        logger.info("updating the setting to unload bloom filters");
        client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(CodecService.INDEX_CODEC_BLOOM_LOAD, false)).get();
        logger.info("waiting for memory to match without blooms");
        awaitBusy(new Predicate<Object>() {
            public boolean apply(Object o) {
                IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get();
                long newSegmentsMemoryWithoutBloom = stats.getTotal().getSegments().getMemoryInBytes();
                logger.info("trying segments without bloom: {}", newSegmentsMemoryWithoutBloom);
                return newSegmentsMemoryWithoutBloom == segmentsMemoryWithoutBloom;
            }
        });
    }
View Full Code Here

                request.add(Requests.indexRequest("test").type("type1").id(Long.toString(id++)).source(jsonBuilder().startObject().field("l", randomLong()).endObject()));
            }
            BulkResponse response = request.execute().actionGet();
            refresh();
            assertNoFailures(response);
            IndicesStatsResponse stats = client().admin().indices().prepareStats("test").setSegments(true).setMerge(true).get();
            logger.info("index round [{}] - segments {}, total merges {}, current merge {}", i, stats.getPrimaries().getSegments().getCount(), stats.getPrimaries().getMerge().getTotal(), stats.getPrimaries().getMerge().getCurrent());
        }
        final long upperNumberSegments = 2 * numOfShards * 10;
        awaitBusy(new Predicate<Object>() {
            @Override
            public boolean apply(Object input) {
                IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).setMerge(true).get();
                logger.info("numshards {}, segments {}, total merges {}, current merge {}", numOfShards, stats.getPrimaries().getSegments().getCount(), stats.getPrimaries().getMerge().getTotal(), stats.getPrimaries().getMerge().getCurrent());
                long current = stats.getPrimaries().getMerge().getCurrent();
                long count = stats.getPrimaries().getSegments().getCount();
                return count < upperNumberSegments && current == 0;
            }
        });
        IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).setMerge(true).get();
        logger.info("numshards {}, segments {}, total merges {}, current merge {}", numOfShards, stats.getPrimaries().getSegments().getCount(), stats.getPrimaries().getMerge().getTotal(), stats.getPrimaries().getMerge().getCurrent());
        long count = stats.getPrimaries().getSegments().getCount();
        assertThat(count, Matchers.lessThanOrEqualTo(upperNumberSegments));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.