Search in sources :

Example 1 with NodeService

use of org.elasticsearch.node.NodeService in project elasticsearch by elastic.

the class InternalTestCluster method ensureEstimatedStats.

@Override
public void ensureEstimatedStats() {
    if (size() > 0) {
        // of the breakers
        for (NodeAndClient nodeAndClient : nodes.values()) {
            final IndicesFieldDataCache fdCache = getInstanceFromNode(IndicesService.class, nodeAndClient.node).getIndicesFieldDataCache();
            // Clean up the cache, ensuring that entries' listeners have been called
            fdCache.getCache().refresh();
            final String name = nodeAndClient.name;
            final CircuitBreakerService breakerService = getInstanceFromNode(CircuitBreakerService.class, nodeAndClient.node);
            CircuitBreaker fdBreaker = breakerService.getBreaker(CircuitBreaker.FIELDDATA);
            assertThat("Fielddata breaker not reset to 0 on node: " + name, fdBreaker.getUsed(), equalTo(0L));
            // fail if it never reached 0
            try {
                assertBusy(new Runnable() {

                    @Override
                    public void run() {
                        CircuitBreaker reqBreaker = breakerService.getBreaker(CircuitBreaker.REQUEST);
                        assertThat("Request breaker not reset to 0 on node: " + name, reqBreaker.getUsed(), equalTo(0L));
                    }
                });
            } catch (Exception e) {
                fail("Exception during check for request breaker reset to 0: " + e);
            }
            NodeService nodeService = getInstanceFromNode(NodeService.class, nodeAndClient.node);
            CommonStatsFlags flags = new CommonStatsFlags(Flag.FieldData, Flag.QueryCache, Flag.Segments);
            NodeStats stats = nodeService.stats(flags, false, false, false, false, false, false, false, false, false, false, false);
            assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L));
            assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L));
            assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0L));
        }
    }
}
Also used : IndicesFieldDataCache(org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) CommonStatsFlags(org.elasticsearch.action.admin.indices.stats.CommonStatsFlags) NodeService(org.elasticsearch.node.NodeService) IndicesService(org.elasticsearch.indices.IndicesService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeValidationException(org.elasticsearch.node.NodeValidationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ElasticsearchException(org.elasticsearch.ElasticsearchException) ShardLockObtainFailedException(org.elasticsearch.env.ShardLockObtainFailedException)

Aggregations

IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)1 CommonStatsFlags (org.elasticsearch.action.admin.indices.stats.CommonStatsFlags)1 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)1 ShardLockObtainFailedException (org.elasticsearch.env.ShardLockObtainFailedException)1 IndicesService (org.elasticsearch.indices.IndicesService)1 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)1 HierarchyCircuitBreakerService (org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService)1 IndicesFieldDataCache (org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache)1 NodeService (org.elasticsearch.node.NodeService)1 NodeValidationException (org.elasticsearch.node.NodeValidationException)1