use of org.elasticsearch.indices.breaker.CircuitBreakerService in project elasticsearch by elastic.
the class NetworkModuleTests method testRegisterTransport.
public void testRegisterTransport() {
Settings settings = Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "custom").put(NetworkModule.HTTP_ENABLED.getKey(), false).build();
// content doesn't matter we check reference equality
Supplier<Transport> custom = () -> null;
NetworkPlugin plugin = new NetworkPlugin() {
@Override
public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
return Collections.singletonMap("custom", custom);
}
};
NetworkModule module = newNetworkModule(settings, false, plugin);
assertFalse(module.isTransportClient());
assertFalse(module.isHttpEnabled());
assertSame(custom, module.getTransportSupplier());
// check it works with transport only as well
module = newNetworkModule(settings, true, plugin);
assertSame(custom, module.getTransportSupplier());
assertTrue(module.isTransportClient());
assertFalse(module.isHttpEnabled());
}
use of org.elasticsearch.indices.breaker.CircuitBreakerService in project elasticsearch by elastic.
the class BroadcastReplicationTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService, new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(Settings.EMPTY, Collections.emptyList()));
clusterService = createClusterService(threadPool);
transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
transportService.start();
transportService.acceptIncomingRequests();
broadcastReplicationAction = new TestBroadcastReplicationAction(Settings.EMPTY, threadPool, clusterService, transportService, new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY), null);
}
use of org.elasticsearch.indices.breaker.CircuitBreakerService in project elasticsearch by elastic.
the class CircuitBreakerUnitTests method testRegisterCustomBreaker.
public void testRegisterCustomBreaker() throws Exception {
CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
String customName = "custom";
BreakerSettings settings = new BreakerSettings(customName, 20, 1.0);
service.registerBreaker(settings);
CircuitBreaker breaker = service.getBreaker(customName);
assertThat(breaker, notNullValue());
assertThat(breaker, instanceOf(CircuitBreaker.class));
assertThat(breaker.getName(), is(customName));
}
use of org.elasticsearch.indices.breaker.CircuitBreakerService in project elasticsearch by elastic.
the class CircuitBreakerServiceIT method testCustomCircuitBreakerRegistration.
public void testCustomCircuitBreakerRegistration() throws Exception {
Iterable<CircuitBreakerService> serviceIter = internalCluster().getInstances(CircuitBreakerService.class);
final String breakerName = "customBreaker";
BreakerSettings breakerSettings = new BreakerSettings(breakerName, 8, 1.03);
CircuitBreaker breaker = null;
for (CircuitBreakerService s : serviceIter) {
s.registerBreaker(breakerSettings);
breaker = s.getBreaker(breakerSettings.getName());
}
if (breaker != null) {
try {
breaker.addEstimateBytesAndMaybeBreak(16, "test");
} catch (CircuitBreakingException e) {
// ignore, we forced a circuit break
}
}
NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().clear().setBreaker(true).get();
int breaks = 0;
for (NodeStats stat : stats.getNodes()) {
CircuitBreakerStats breakerStats = stat.getBreaker().getStats(breakerName);
breaks += breakerStats.getTrippedCount();
}
assertThat(breaks, greaterThanOrEqualTo(1));
}
use of org.elasticsearch.indices.breaker.CircuitBreakerService 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));
}
Aggregations