Search in sources :

Example 16 with NoneCircuitBreakerService

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

the class TermsAggregatorTests method testMixLongAndDouble.

public void testMixLongAndDouble() throws Exception {
    for (TermsAggregatorFactory.ExecutionMode executionMode : TermsAggregatorFactory.ExecutionMode.values()) {
        TermsAggregationBuilder aggregationBuilder = new TermsAggregationBuilder("_name", ValueType.LONG).executionHint(executionMode.toString()).field("number").order(Terms.Order.term(true));
        List<InternalAggregation> aggs = new ArrayList<>();
        int numLongs = randomIntBetween(1, 3);
        for (int i = 0; i < numLongs; i++) {
            final Directory dir;
            try (IndexReader reader = createIndexWithLongs()) {
                dir = ((DirectoryReader) reader).directory();
                IndexSearcher searcher = new IndexSearcher(reader);
                MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
                fieldType.setName("number");
                fieldType.setHasDocValues(true);
                aggs.add(buildInternalAggregation(aggregationBuilder, fieldType, searcher));
            }
            dir.close();
        }
        int numDoubles = randomIntBetween(1, 3);
        for (int i = 0; i < numDoubles; i++) {
            final Directory dir;
            try (IndexReader reader = createIndexWithDoubles()) {
                dir = ((DirectoryReader) reader).directory();
                IndexSearcher searcher = new IndexSearcher(reader);
                MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
                fieldType.setName("number");
                fieldType.setHasDocValues(true);
                aggs.add(buildInternalAggregation(aggregationBuilder, fieldType, searcher));
            }
            dir.close();
        }
        InternalAggregation.ReduceContext ctx = new InternalAggregation.ReduceContext(new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService()), null, true);
        for (InternalAggregation internalAgg : aggs) {
            InternalAggregation mergedAggs = internalAgg.doReduce(aggs, ctx);
            assertTrue(mergedAggs instanceof DoubleTerms);
            long expected = numLongs + numDoubles;
            List<Terms.Bucket> buckets = ((DoubleTerms) mergedAggs).getBuckets();
            assertEquals(4, buckets.size());
            assertEquals("1.0", buckets.get(0).getKeyAsString());
            assertEquals(expected, buckets.get(0).getDocCount());
            assertEquals("10.0", buckets.get(1).getKeyAsString());
            assertEquals(expected * 2, buckets.get(1).getDocCount());
            assertEquals("100.0", buckets.get(2).getKeyAsString());
            assertEquals(expected * 2, buckets.get(2).getDocCount());
            assertEquals("1000.0", buckets.get(3).getKeyAsString());
            assertEquals(expected, buckets.get(3).getDocCount());
        }
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) ArrayList(java.util.ArrayList) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) InternalAggregation(org.elasticsearch.search.aggregations.InternalAggregation) IndexReader(org.apache.lucene.index.IndexReader) MappedFieldType(org.elasticsearch.index.mapper.MappedFieldType) Directory(org.apache.lucene.store.Directory) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 17 with NoneCircuitBreakerService

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

the class NettyTransportMultiPortTests method startTransport.

private TcpTransport<?> startTransport(Settings settings, ThreadPool threadPool) {
    BigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
    TcpTransport<?> transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), bigArrays, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService());
    transport.start();
    assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
    return transport;
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) BigArrays(org.elasticsearch.common.util.BigArrays) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 18 with NoneCircuitBreakerService

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

the class Netty4HttpChannelTests method setup.

@Before
public void setup() throws Exception {
    networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
    threadPool = new TestThreadPool("test");
    bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 19 with NoneCircuitBreakerService

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

the class Netty4ScheduledPingTests method testScheduledPing.

public void testScheduledPing() throws Exception {
    ThreadPool threadPool = new TestThreadPool(getClass().getName());
    Settings settings = Settings.builder().put(TcpTransport.PING_SCHEDULE.getKey(), "5ms").put(TransportSettings.PORT.getKey(), 0).put("cluster.name", "test").build();
    CircuitBreakerService circuitBreakerService = new NoneCircuitBreakerService();
    NamedWriteableRegistry registry = new NamedWriteableRegistry(Collections.emptyList());
    final Netty4Transport nettyA = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), BigArrays.NON_RECYCLING_INSTANCE, registry, circuitBreakerService);
    MockTransportService serviceA = new MockTransportService(settings, nettyA, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, null);
    serviceA.start();
    serviceA.acceptIncomingRequests();
    final Netty4Transport nettyB = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), BigArrays.NON_RECYCLING_INSTANCE, registry, circuitBreakerService);
    MockTransportService serviceB = new MockTransportService(settings, nettyB, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, null);
    serviceB.start();
    serviceB.acceptIncomingRequests();
    DiscoveryNode nodeA = serviceA.getLocalDiscoNode();
    DiscoveryNode nodeB = serviceB.getLocalDiscoNode();
    serviceA.connectToNode(nodeB);
    serviceB.connectToNode(nodeA);
    assertBusy(new Runnable() {

        @Override
        public void run() {
            assertThat(nettyA.getPing().getSuccessfulPings(), greaterThan(100L));
            assertThat(nettyB.getPing().getSuccessfulPings(), greaterThan(100L));
        }
    });
    assertThat(nettyA.getPing().getFailedPings(), equalTo(0L));
    assertThat(nettyB.getPing().getFailedPings(), equalTo(0L));
    serviceA.registerRequestHandler("sayHello", TransportRequest.Empty::new, ThreadPool.Names.GENERIC, new TransportRequestHandler<TransportRequest.Empty>() {

        @Override
        public void messageReceived(TransportRequest.Empty request, TransportChannel channel) {
            try {
                channel.sendResponse(TransportResponse.Empty.INSTANCE, TransportResponseOptions.EMPTY);
            } catch (IOException e) {
                logger.error("Unexpected failure", e);
                fail(e.getMessage());
            }
        }
    });
    int rounds = scaledRandomIntBetween(100, 5000);
    for (int i = 0; i < rounds; i++) {
        serviceB.submitRequest(nodeA, "sayHello", TransportRequest.Empty.INSTANCE, TransportRequestOptions.builder().withCompress(randomBoolean()).build(), new TransportResponseHandler<TransportResponse.Empty>() {

            @Override
            public TransportResponse.Empty newInstance() {
                return TransportResponse.Empty.INSTANCE;
            }

            @Override
            public String executor() {
                return ThreadPool.Names.GENERIC;
            }

            @Override
            public void handleResponse(TransportResponse.Empty response) {
            }

            @Override
            public void handleException(TransportException exp) {
                logger.error("Unexpected failure", exp);
                fail("got exception instead of a response: " + exp.getMessage());
            }
        }).txGet();
    }
    assertBusy(() -> {
        assertThat(nettyA.getPing().getSuccessfulPings(), greaterThan(200L));
        assertThat(nettyB.getPing().getSuccessfulPings(), greaterThan(200L));
    });
    assertThat(nettyA.getPing().getFailedPings(), equalTo(0L));
    assertThat(nettyB.getPing().getFailedPings(), equalTo(0L));
    Releasables.close(serviceA, serviceB);
    terminate(threadPool);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) TransportRequest(org.elasticsearch.transport.TransportRequest) MockTransportService(org.elasticsearch.test.transport.MockTransportService) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) IOException(java.io.IOException) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) TransportResponse(org.elasticsearch.transport.TransportResponse) TransportException(org.elasticsearch.transport.TransportException) NetworkService(org.elasticsearch.common.network.NetworkService) TransportChannel(org.elasticsearch.transport.TransportChannel) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Settings(org.elasticsearch.common.settings.Settings) TransportSettings(org.elasticsearch.transport.TransportSettings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 20 with NoneCircuitBreakerService

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

the class BroadcastReplicationTests method beforeClass.

@BeforeClass
public static void beforeClass() {
    threadPool = new TestThreadPool("BroadcastReplicationTests");
    circuitBreakerService = new NoneCircuitBreakerService();
}
Also used : TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) BeforeClass(org.junit.BeforeClass)

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