Search in sources :

Example 1 with NoneCircuitBreakerService

use of org.opensearch.indices.breaker.NoneCircuitBreakerService in project OpenSearch by opensearch-project.

the class InternalMatrixStatsTests method testReduceRandom.

@Override
public void testReduceRandom() {
    int numValues = 10000;
    int numShards = randomIntBetween(1, 20);
    int valuesPerShard = (int) Math.floor(numValues / numShards);
    List<Double> aValues = new ArrayList<>();
    List<Double> bValues = new ArrayList<>();
    RunningStats runningStats = new RunningStats();
    List<InternalAggregation> shardResults = new ArrayList<>();
    int valuePerShardCounter = 0;
    for (int i = 0; i < numValues; i++) {
        double valueA = randomDouble();
        aValues.add(valueA);
        double valueB = randomDouble();
        bValues.add(valueB);
        runningStats.add(new String[] { "a", "b" }, new double[] { valueA, valueB });
        if (++valuePerShardCounter == valuesPerShard) {
            shardResults.add(new InternalMatrixStats("_name", 1L, runningStats, null, Collections.emptyMap()));
            runningStats = new RunningStats();
            valuePerShardCounter = 0;
        }
    }
    if (valuePerShardCounter != 0) {
        shardResults.add(new InternalMatrixStats("_name", 1L, runningStats, null, Collections.emptyMap()));
    }
    MultiPassStats multiPassStats = new MultiPassStats("a", "b");
    multiPassStats.computeStats(aValues, bValues);
    ScriptService mockScriptService = mockScriptService();
    MockBigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(Settings.EMPTY), new NoneCircuitBreakerService());
    InternalAggregation.ReduceContext context = InternalAggregation.ReduceContext.forFinalReduction(bigArrays, mockScriptService, b -> {
    }, PipelineTree.EMPTY);
    InternalMatrixStats reduced = (InternalMatrixStats) shardResults.get(0).reduce(shardResults, context);
    multiPassStats.assertNearlyEqual(reduced.getResults());
}
Also used : MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) ArrayList(java.util.ArrayList) MockBigArrays(org.opensearch.common.util.MockBigArrays) InternalAggregation(org.opensearch.search.aggregations.InternalAggregation) ScriptService(org.opensearch.script.ScriptService) NoneCircuitBreakerService(org.opensearch.indices.breaker.NoneCircuitBreakerService)

Example 2 with NoneCircuitBreakerService

use of org.opensearch.indices.breaker.NoneCircuitBreakerService in project OpenSearch by opensearch-project.

the class Netty4SizeHeaderFrameDecoderTests method startThreadPool.

@Before
public void startThreadPool() {
    threadPool = new ThreadPool(settings);
    NetworkService networkService = new NetworkService(Collections.emptyList());
    PageCacheRecycler recycler = new MockPageCacheRecycler(Settings.EMPTY);
    nettyTransport = new Netty4Transport(settings, Version.CURRENT, threadPool, networkService, recycler, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService(), new SharedGroupFactory(settings));
    nettyTransport.start();
    TransportAddress[] boundAddresses = nettyTransport.boundAddress().boundAddresses();
    TransportAddress transportAddress = randomFrom(boundAddresses);
    port = transportAddress.address().getPort();
    host = transportAddress.address().getAddress();
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) PageCacheRecycler(org.opensearch.common.util.PageCacheRecycler) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) TransportAddress(org.opensearch.common.transport.TransportAddress) ThreadPool(org.opensearch.threadpool.ThreadPool) NetworkService(org.opensearch.common.network.NetworkService) SharedGroupFactory(org.opensearch.transport.SharedGroupFactory) NoneCircuitBreakerService(org.opensearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 3 with NoneCircuitBreakerService

use of org.opensearch.indices.breaker.NoneCircuitBreakerService in project OpenSearch by opensearch-project.

the class NettyTransportMultiPortTests method startTransport.

private TcpTransport startTransport(Settings settings, ThreadPool threadPool) {
    PageCacheRecycler recycler = new MockPageCacheRecycler(Settings.EMPTY);
    TcpTransport transport = new Netty4Transport(settings, Version.CURRENT, threadPool, new NetworkService(Collections.emptyList()), recycler, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService(), new SharedGroupFactory(settings));
    transport.start();
    assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
    return transport;
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) PageCacheRecycler(org.opensearch.common.util.PageCacheRecycler) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) TcpTransport(org.opensearch.transport.TcpTransport) NetworkService(org.opensearch.common.network.NetworkService) SharedGroupFactory(org.opensearch.transport.SharedGroupFactory) NoneCircuitBreakerService(org.opensearch.indices.breaker.NoneCircuitBreakerService)

Example 4 with NoneCircuitBreakerService

use of org.opensearch.indices.breaker.NoneCircuitBreakerService in project OpenSearch by opensearch-project.

the class Netty4HttpServerPipeliningTests method setup.

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

Example 5 with NoneCircuitBreakerService

use of org.opensearch.indices.breaker.NoneCircuitBreakerService in project OpenSearch by opensearch-project.

the class SimpleNioTransportTests method build.

@Override
protected Transport build(Settings settings, final Version version, ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    NetworkService networkService = new NetworkService(Collections.emptyList());
    return new NioTransport(settings, version, threadPool, networkService, new MockPageCacheRecycler(settings), namedWriteableRegistry, new NoneCircuitBreakerService(), new NioGroupFactory(settings, logger)) {

        @Override
        public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionProfile profile, ActionListener<Version> listener) {
            if (doHandshake) {
                super.executeHandshake(node, channel, profile, listener);
            } else {
                listener.onResponse(version.minimumCompatibilityVersion());
            }
        }
    };
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockPageCacheRecycler(org.opensearch.common.util.MockPageCacheRecycler) ActionListener(org.opensearch.action.ActionListener) TcpChannel(org.opensearch.transport.TcpChannel) NetworkService(org.opensearch.common.network.NetworkService) ConnectionProfile(org.opensearch.transport.ConnectionProfile) NoneCircuitBreakerService(org.opensearch.indices.breaker.NoneCircuitBreakerService)

Aggregations

NoneCircuitBreakerService (org.opensearch.indices.breaker.NoneCircuitBreakerService)51 MockPageCacheRecycler (org.opensearch.common.util.MockPageCacheRecycler)30 MockBigArrays (org.opensearch.common.util.MockBigArrays)24 NetworkService (org.opensearch.common.network.NetworkService)20 NamedWriteableRegistry (org.opensearch.common.io.stream.NamedWriteableRegistry)15 ArrayList (java.util.ArrayList)14 TestThreadPool (org.opensearch.threadpool.TestThreadPool)14 Before (org.junit.Before)11 MockNioTransport (org.opensearch.transport.nio.MockNioTransport)10 Directory (org.apache.lucene.store.Directory)9 IOException (java.io.IOException)8 ScriptService (org.opensearch.script.ScriptService)8 IndexSearcher (org.apache.lucene.search.IndexSearcher)7 ActionListener (org.opensearch.action.ActionListener)7 InternalAggregation (org.opensearch.search.aggregations.InternalAggregation)7 List (java.util.List)6 IndexReader (org.apache.lucene.index.IndexReader)6 ThreadPool (org.opensearch.threadpool.ThreadPool)6 Collections (java.util.Collections)5 HashSet (java.util.HashSet)5