Search in sources :

Example 1 with ChildMemoryCircuitBreaker

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

the class HierarchyCircuitBreakerService method registerBreaker.

/**
     * Allows to register a custom circuit breaker.
     * Warning: Will overwrite any existing custom breaker with the same name.
     */
@Override
public void registerBreaker(BreakerSettings breakerSettings) {
    // Validate the settings
    validateSettings(new BreakerSettings[] { breakerSettings });
    if (breakerSettings.getType() == CircuitBreaker.Type.NOOP) {
        CircuitBreaker breaker = new NoopCircuitBreaker(breakerSettings.getName());
        breakers.put(breakerSettings.getName(), breaker);
    } else {
        CircuitBreaker oldBreaker;
        CircuitBreaker breaker = new ChildMemoryCircuitBreaker(breakerSettings, Loggers.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this, breakerSettings.getName());
        for (; ; ) {
            oldBreaker = breakers.putIfAbsent(breakerSettings.getName(), breaker);
            if (oldBreaker == null) {
                return;
            }
            breaker = new ChildMemoryCircuitBreaker(breakerSettings, (ChildMemoryCircuitBreaker) oldBreaker, Loggers.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this, breakerSettings.getName());
            if (breakers.replace(breakerSettings.getName(), oldBreaker, breaker)) {
                return;
            }
        }
    }
}
Also used : ChildMemoryCircuitBreaker(org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) ChildMemoryCircuitBreaker(org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker)

Example 2 with ChildMemoryCircuitBreaker

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

the class HierarchyCircuitBreakerService method registerBreaker.

/**
 * Allows to register a custom circuit breaker.
 * Warning: Will overwrite any existing custom breaker with the same name.
 */
@Override
public void registerBreaker(BreakerSettings breakerSettings) {
    if (breakerSettings.getType() == CircuitBreaker.Type.NOOP) {
        CircuitBreaker breaker = new NoopCircuitBreaker(breakerSettings.getName());
        breakers.put(breakerSettings.getName(), breaker);
    } else {
        CircuitBreaker oldBreaker;
        CircuitBreaker breaker = new ChildMemoryCircuitBreaker(breakerSettings, LogManager.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this);
        for (; ; ) {
            oldBreaker = breakers.putIfAbsent(breakerSettings.getName(), breaker);
            if (oldBreaker == null) {
                return;
            }
            breaker = new ChildMemoryCircuitBreaker(breakerSettings, (ChildMemoryCircuitBreaker) oldBreaker, LogManager.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this);
            if (breakers.replace(breakerSettings.getName(), oldBreaker, breaker)) {
                return;
            }
        }
    }
}
Also used : ChildMemoryCircuitBreaker(org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) ChildMemoryCircuitBreaker(org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker)

Aggregations

ChildMemoryCircuitBreaker (org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker)2 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)2 NoopCircuitBreaker (org.elasticsearch.common.breaker.NoopCircuitBreaker)2