Search in sources :

Example 26 with NoneCircuitBreakerService

use of org.elasticsearch.indices.breaker.NoneCircuitBreakerService in project elasticsearch by elastic.

the class DynamicMappingDisabledTests method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder().put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false).build();
    clusterService = createClusterService(threadPool);
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(settings, Collections.emptyList()));
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ShardStateAction shardStateAction = new ShardStateAction(settings, clusterService, transportService, null, null, threadPool);
    ActionFilters actionFilters = new ActionFilters(Collections.emptySet());
    IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
    AutoCreateIndex autoCreateIndex = new AutoCreateIndex(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), indexNameExpressionResolver);
    UpdateHelper updateHelper = new UpdateHelper(settings, null);
    TransportShardBulkAction shardBulkAction = new TransportShardBulkAction(settings, transportService, clusterService, indicesService, threadPool, shardStateAction, null, updateHelper, actionFilters, indexNameExpressionResolver);
    transportBulkAction = new TransportBulkAction(settings, threadPool, transportService, clusterService, null, shardBulkAction, null, actionFilters, indexNameExpressionResolver, autoCreateIndex, System::currentTimeMillis);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ESSingleNodeTestCase(org.elasticsearch.test.ESSingleNodeTestCase) UpdateHelper(org.elasticsearch.action.update.UpdateHelper) BeforeClass(org.junit.BeforeClass) BigArrays(org.elasticsearch.common.util.BigArrays) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) TransportBulkAction(org.elasticsearch.action.bulk.TransportBulkAction) ClusterService(org.elasticsearch.cluster.service.ClusterService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TransportShardBulkAction(org.elasticsearch.action.bulk.TransportShardBulkAction) AutoCreateIndex(org.elasticsearch.action.support.AutoCreateIndex) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) IndexRequest(org.elasticsearch.action.index.IndexRequest) NetworkService(org.elasticsearch.common.network.NetworkService) Settings(org.elasticsearch.common.settings.Settings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) After(org.junit.After) ThreadPool(org.elasticsearch.threadpool.ThreadPool) Requests(org.elasticsearch.client.Requests) IndicesService(org.elasticsearch.indices.IndicesService) TransportService(org.elasticsearch.transport.TransportService) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) Transport(org.elasticsearch.transport.Transport) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) TimeUnit(java.util.concurrent.TimeUnit) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) Collections(java.util.Collections) ActionListener(org.elasticsearch.action.ActionListener) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) TransportBulkAction(org.elasticsearch.action.bulk.TransportBulkAction) IndicesService(org.elasticsearch.indices.IndicesService) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) ActionFilters(org.elasticsearch.action.support.ActionFilters) TransportShardBulkAction(org.elasticsearch.action.bulk.TransportShardBulkAction) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) UpdateHelper(org.elasticsearch.action.update.UpdateHelper) TransportService(org.elasticsearch.transport.TransportService) NetworkService(org.elasticsearch.common.network.NetworkService) AutoCreateIndex(org.elasticsearch.action.support.AutoCreateIndex) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Transport(org.elasticsearch.transport.Transport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Settings(org.elasticsearch.common.settings.Settings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 27 with NoneCircuitBreakerService

use of org.elasticsearch.indices.breaker.NoneCircuitBreakerService in project elasticsearch by elastic.

the class InternalAggregationTestCase method testReduceRandom.

public final void testReduceRandom() {
    String name = randomAsciiOfLength(5);
    List<T> inputs = new ArrayList<>();
    List<InternalAggregation> toReduce = new ArrayList<>();
    int toReduceSize = between(1, 200);
    for (int i = 0; i < toReduceSize; i++) {
        T t = randomBoolean() ? createUnmappedInstance(name) : createTestInstance(name);
        inputs.add(t);
        toReduce.add(t);
    }
    ScriptService mockScriptService = mockScriptService();
    MockBigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
    if (randomBoolean() && toReduce.size() > 1) {
        Collections.shuffle(toReduce, random());
        // we leave at least one element in the list
        int r = Math.max(1, randomIntBetween(0, toReduceSize - 2));
        List<InternalAggregation> internalAggregations = toReduce.subList(0, r);
        InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(bigArrays, mockScriptService, false);
        @SuppressWarnings("unchecked") T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
        toReduce = toReduce.subList(r, toReduceSize);
        toReduce.add(reduced);
    }
    InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(bigArrays, mockScriptService, true);
    @SuppressWarnings("unchecked") T reduced = (T) inputs.get(0).reduce(toReduce, context);
    assertReduced(reduced, inputs);
}
Also used : ArrayList(java.util.ArrayList) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) ScriptService(org.elasticsearch.script.ScriptService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 28 with NoneCircuitBreakerService

use of org.elasticsearch.indices.breaker.NoneCircuitBreakerService in project elasticsearch by elastic.

the class TransportServiceHandshakeTests method startServices.

private NetworkHandle startServices(String nodeNameAndId, Settings settings, Version version) {
    MockTcpTransport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(settings, Collections.emptyList()));
    TransportService transportService = new MockTransportService(settings, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, (boundAddress) -> new DiscoveryNode(nodeNameAndId, nodeNameAndId, boundAddress.publishAddress(), emptyMap(), emptySet(), version), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    transportServices.add(transportService);
    return new NetworkHandle(transportService, transportService.getLocalNode());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) MockTransportService(org.elasticsearch.test.transport.MockTransportService) MockTransportService(org.elasticsearch.test.transport.MockTransportService) NetworkService(org.elasticsearch.common.network.NetworkService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 29 with NoneCircuitBreakerService

use of org.elasticsearch.indices.breaker.NoneCircuitBreakerService in project elasticsearch by elastic.

the class MockTransportService method createNewService.

public static MockTransportService createNewService(Settings settings, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
    final Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version);
    return createNewService(settings, transport, version, threadPool, clusterSettings);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) NetworkService(org.elasticsearch.common.network.NetworkService) Transport(org.elasticsearch.transport.Transport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 30 with NoneCircuitBreakerService

use of org.elasticsearch.indices.breaker.NoneCircuitBreakerService in project elasticsearch by elastic.

the class AbstractSimpleTransportTestCase method testTcpHandshake.

public void testTcpHandshake() throws IOException, InterruptedException {
    assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
    TcpTransport originalTransport = (TcpTransport) serviceA.getOriginalTransport();
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    try (MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList())) {

        @Override
        protected String handleRequest(MockChannel mockChannel, String profileName, StreamInput stream, long requestId, int messageLengthBytes, Version version, InetSocketAddress remoteAddress, byte status) throws IOException {
            return super.handleRequest(mockChannel, profileName, stream, requestId, messageLengthBytes, version, remoteAddress, // we flip the isHandshake bit back and act like the handler is not found
            (byte) (status & ~(1 << 3)));
        }
    }) {
        transport.transportServiceAdapter(serviceA.new Adapter());
        transport.start();
        // this acts like a node that doesn't have support for handshakes
        DiscoveryNode node = new DiscoveryNode("TS_TPC", "TS_TPC", transport.boundAddress().publishAddress(), emptyMap(), emptySet(), version0);
        ConnectTransportException exception = expectThrows(ConnectTransportException.class, () -> serviceA.connectToNode(node));
        assertTrue(exception.getCause() instanceof IllegalStateException);
        assertEquals("handshake failed", exception.getCause().getMessage());
    }
    try (TransportService service = buildService("TS_TPC", Version.CURRENT, null);
        TcpTransport.NodeChannels connection = originalTransport.openConnection(new DiscoveryNode("TS_TPC", "TS_TPC", service.boundAddress().publishAddress(), emptyMap(), emptySet(), version0), null)) {
        Version version = originalTransport.executeHandshake(connection.getNode(), connection.channel(TransportRequestOptions.Type.PING), TimeValue.timeValueSeconds(10));
        assertEquals(version, Version.CURRENT);
    }
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) InetSocketAddress(java.net.InetSocketAddress) Version(org.elasticsearch.Version) MockTransportService(org.elasticsearch.test.transport.MockTransportService) StreamInput(org.elasticsearch.common.io.stream.StreamInput) NetworkService(org.elasticsearch.common.network.NetworkService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Aggregations

NoneCircuitBreakerService (org.elasticsearch.indices.breaker.NoneCircuitBreakerService)32 NetworkService (org.elasticsearch.common.network.NetworkService)25 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)22 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)17 MockTransportService (org.elasticsearch.test.transport.MockTransportService)16 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)14 MockTcpTransport (org.elasticsearch.transport.MockTcpTransport)13 Transport (org.elasticsearch.transport.Transport)13 TransportAddress (org.elasticsearch.common.transport.TransportAddress)12 Before (org.junit.Before)12 BigArrays (org.elasticsearch.common.util.BigArrays)11 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)10 ThreadPool (org.elasticsearch.threadpool.ThreadPool)10 TransportService (org.elasticsearch.transport.TransportService)10 Logger (org.apache.logging.log4j.Logger)9 TimeValue (org.elasticsearch.common.unit.TimeValue)9 MockBigArrays (org.elasticsearch.common.util.MockBigArrays)9 IOException (java.io.IOException)8 UnknownHostException (java.net.UnknownHostException)8 ArrayList (java.util.ArrayList)8