Search in sources :

Example 11 with CircuitBreaker

use of org.elasticsearch.common.breaker.CircuitBreaker in project elasticsearch by elastic.

the class HierarchyCircuitBreakerService method checkParentLimit.

/**
     * Checks whether the parent breaker has been tripped
     */
public void checkParentLimit(String label) throws CircuitBreakingException {
    long totalUsed = 0;
    for (CircuitBreaker breaker : this.breakers.values()) {
        totalUsed += (breaker.getUsed() * breaker.getOverhead());
    }
    long parentLimit = this.parentSettings.getLimit();
    if (totalUsed > parentLimit) {
        this.parentTripCount.incrementAndGet();
        final String message = "[parent] Data too large, data for [" + label + "]" + " would be [" + totalUsed + "/" + new ByteSizeValue(totalUsed) + "]" + ", which is larger than the limit of [" + parentLimit + "/" + new ByteSizeValue(parentLimit) + "]";
        throw new CircuitBreakingException(message, totalUsed, parentLimit);
    }
}
Also used : ChildMemoryCircuitBreaker(org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) CircuitBreakingException(org.elasticsearch.common.breaker.CircuitBreakingException) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 12 with CircuitBreaker

use of org.elasticsearch.common.breaker.CircuitBreaker in project crate by crate.

the class CrateCircuitBreakerServiceTest method testQueryCircuitBreakerRegistration.

@Test
public void testQueryCircuitBreakerRegistration() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, settingsService);
    CrateCircuitBreakerService breakerService = new CrateCircuitBreakerService(Settings.EMPTY, settingsService, esBreakerService);
    CircuitBreaker breaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY);
    assertThat(breaker, notNullValue());
    assertThat(breaker, instanceOf(CircuitBreaker.class));
    assertThat(breaker.getName(), is(CrateCircuitBreakerService.QUERY));
}
Also used : CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 13 with CircuitBreaker

use of org.elasticsearch.common.breaker.CircuitBreaker in project elasticsearch by elastic.

the class ZenFaultDetectionTests method testMasterFaultDetectionNotSizeLimited.

public void testMasterFaultDetectionNotSizeLimited() throws InterruptedException {
    boolean shouldRetry = randomBoolean();
    ClusterName clusterName = new ClusterName(randomAsciiOfLengthBetween(3, 20));
    final Settings settings = Settings.builder().put(FaultDetection.CONNECT_ON_NETWORK_DISCONNECT_SETTING.getKey(), shouldRetry).put(FaultDetection.PING_INTERVAL_SETTING.getKey(), "1s").put("cluster.name", clusterName.value()).build();
    final ClusterState stateNodeA = ClusterState.builder(clusterName).nodes(buildNodesForA(false)).build();
    setState(clusterServiceA, stateNodeA);
    int minExpectedPings = 2;
    PingProbe pingProbeA = new PingProbe(minExpectedPings);
    PingProbe pingProbeB = new PingProbe(minExpectedPings);
    serviceA.addTracer(pingProbeA);
    serviceB.addTracer(pingProbeB);
    MasterFaultDetection masterFDNodeA = new MasterFaultDetection(Settings.builder().put(settingsA).put(settings).build(), threadPool, serviceA, clusterServiceA);
    masterFDNodeA.restart(nodeB, "test");
    final ClusterState stateNodeB = ClusterState.builder(clusterName).nodes(buildNodesForB(true)).build();
    setState(clusterServiceB, stateNodeB);
    MasterFaultDetection masterFDNodeB = new MasterFaultDetection(Settings.builder().put(settingsB).put(settings).build(), threadPool, serviceB, clusterServiceB);
    masterFDNodeB.restart(nodeB, "test");
    // let's do a few pings
    pingProbeA.awaitMinCompletedPings();
    pingProbeB.awaitMinCompletedPings();
    CircuitBreaker inFlightRequestsBreaker = circuitBreakerService.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);
    assertThat(inFlightRequestsBreaker.getTrippedCount(), equalTo(0L));
    assertThat(pingProbeA.completedPings(), greaterThanOrEqualTo(minExpectedPings));
    assertThat(pingProbeB.completedPings(), greaterThanOrEqualTo(minExpectedPings));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) MasterFaultDetection(org.elasticsearch.discovery.zen.MasterFaultDetection) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) ClusterName(org.elasticsearch.cluster.ClusterName) Settings(org.elasticsearch.common.settings.Settings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings)

Example 14 with CircuitBreaker

use of org.elasticsearch.common.breaker.CircuitBreaker 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

CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)14 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)7 HierarchyCircuitBreakerService (org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService)7 Settings (org.elasticsearch.common.settings.Settings)5 NoopCircuitBreaker (org.elasticsearch.common.breaker.NoopCircuitBreaker)4 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)4 CrateUnitTest (io.crate.test.integration.CrateUnitTest)3 ClusterName (org.elasticsearch.cluster.ClusterName)3 ClusterState (org.elasticsearch.cluster.ClusterState)3 ChildMemoryCircuitBreaker (org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker)3 NodeSettingsService (org.elasticsearch.node.settings.NodeSettingsService)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 ElasticsearchException (org.elasticsearch.ElasticsearchException)2 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)2 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 CircuitBreakingException (org.elasticsearch.common.breaker.CircuitBreakingException)2 MasterFaultDetection (org.elasticsearch.discovery.zen.MasterFaultDetection)2