Search in sources :

Example 1 with NodeService

use of org.opensearch.node.NodeService in project OpenSearch by opensearch-project.

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(() -> {
                    CircuitBreaker reqBreaker = breakerService.getBreaker(CircuitBreaker.REQUEST);
                    assertThat("Request breaker not reset to 0 on node: " + name, reqBreaker.getUsed(), equalTo(0L));
                });
            } catch (Exception e) {
                throw new AssertionError("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, 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.opensearch.indices.fielddata.cache.IndicesFieldDataCache) NodeStats(org.opensearch.action.admin.cluster.node.stats.NodeStats) CircuitBreaker(org.opensearch.common.breaker.CircuitBreaker) CommonStatsFlags(org.opensearch.action.admin.indices.stats.CommonStatsFlags) NodeService(org.opensearch.node.NodeService) IndicesService(org.opensearch.indices.IndicesService) HierarchyCircuitBreakerService(org.opensearch.indices.breaker.HierarchyCircuitBreakerService) CircuitBreakerService(org.opensearch.indices.breaker.CircuitBreakerService) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) NodeValidationException(org.opensearch.node.NodeValidationException) ExecutionException(java.util.concurrent.ExecutionException) ShardLockObtainFailedException(org.opensearch.env.ShardLockObtainFailedException)

Aggregations

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