use of org.opensearch.indices.breaker.CircuitBreakerService in project OpenSearch by opensearch-project.
the class BroadcastReplicationTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
MockNioTransport transport = new MockNioTransport(Settings.EMPTY, Version.CURRENT, threadPool, new NetworkService(Collections.emptyList()), PageCacheRecycler.NON_RECYCLING_INSTANCE, new NamedWriteableRegistry(Collections.emptyList()), circuitBreakerService);
clusterService = createClusterService(threadPool);
transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null, Collections.emptySet());
transportService.start();
transportService.acceptIncomingRequests();
broadcastReplicationAction = new TestBroadcastReplicationAction(clusterService, transportService, new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), null);
}
use of org.opensearch.indices.breaker.CircuitBreakerService in project OpenSearch by opensearch-project.
the class BitArrayTests method testClearingDoesntAllocate.
public void testClearingDoesntAllocate() {
CircuitBreakerService breaker = mock(CircuitBreakerService.class);
ByteSizeValue max = new ByteSizeValue(1, ByteSizeUnit.KB);
when(breaker.getBreaker(CircuitBreaker.REQUEST)).thenReturn(new NoopCircuitBreaker(CircuitBreaker.REQUEST) {
private long total = 0;
@Override
public double addEstimateBytesAndMaybeBreak(long bytes, String label) throws CircuitBreakingException {
total += bytes;
if (total > max.getBytes()) {
throw new CircuitBreakingException("test error", bytes, max.getBytes(), Durability.TRANSIENT);
}
return total;
}
@Override
public long addWithoutBreaking(long bytes) {
total += bytes;
return total;
}
});
BigArrays bigArrays = new BigArrays(null, breaker, CircuitBreaker.REQUEST, true);
try (BitArray bitArray = new BitArray(1, bigArrays)) {
bitArray.clear(100000000);
}
}
use of org.opensearch.indices.breaker.CircuitBreakerService in project OpenSearch by opensearch-project.
the class NetworkModuleTests method testRegisterTransport.
public void testRegisterTransport() {
Settings settings = Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "custom").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, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
return Collections.singletonMap("custom", custom);
}
};
NetworkModule module = newNetworkModule(settings, plugin);
assertSame(custom, module.getTransportSupplier());
}
use of org.opensearch.indices.breaker.CircuitBreakerService in project OpenSearch by opensearch-project.
the class NetworkModuleTests method testOverrideDefault.
public void testOverrideDefault() {
Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), "default_custom").put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "local").put(NetworkModule.TRANSPORT_TYPE_KEY, "default_custom").build();
// content doesn't matter we check reference equality
Supplier<Transport> customTransport = () -> null;
Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
Supplier<HttpServerTransport> def = FakeHttpTransport::new;
NetworkModule module = newNetworkModule(settings, new NetworkPlugin() {
@Override
public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
return Collections.singletonMap("default_custom", customTransport);
}
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedXContentRegistry xContentRegistry, NetworkService networkService, HttpServerTransport.Dispatcher requestDispatcher, ClusterSettings clusterSettings) {
Map<String, Supplier<HttpServerTransport>> supplierMap = new HashMap<>();
supplierMap.put("custom", custom);
supplierMap.put("default_custom", def);
return supplierMap;
}
});
assertSame(custom, module.getHttpServerTransportSupplier());
assertSame(customTransport, module.getTransportSupplier());
}
use of org.opensearch.indices.breaker.CircuitBreakerService in project OpenSearch by opensearch-project.
the class NetworkModuleTests method testRegisterHttpTransport.
public void testRegisterHttpTransport() {
Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build();
Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
NetworkModule module = newNetworkModule(settings, new NetworkPlugin() {
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedXContentRegistry xContentRegistry, NetworkService networkService, HttpServerTransport.Dispatcher requestDispatcher, ClusterSettings clusterSettings) {
return Collections.singletonMap("custom", custom);
}
});
assertSame(custom, module.getHttpServerTransportSupplier());
settings = Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build();
NetworkModule newModule = newNetworkModule(settings);
expectThrows(IllegalStateException.class, () -> newModule.getHttpServerTransportSupplier());
}
Aggregations