Search in sources :

Example 1 with MockPageCacheRecycler

use of org.opensearch.common.util.MockPageCacheRecycler 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 MockPageCacheRecycler

use of org.opensearch.common.util.MockPageCacheRecycler 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 MockPageCacheRecycler

use of org.opensearch.common.util.MockPageCacheRecycler 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 MockPageCacheRecycler

use of org.opensearch.common.util.MockPageCacheRecycler 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 MockPageCacheRecycler

use of org.opensearch.common.util.MockPageCacheRecycler 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

MockPageCacheRecycler (org.opensearch.common.util.MockPageCacheRecycler)31 NoneCircuitBreakerService (org.opensearch.indices.breaker.NoneCircuitBreakerService)30 MockBigArrays (org.opensearch.common.util.MockBigArrays)25 NetworkService (org.opensearch.common.network.NetworkService)11 TestThreadPool (org.opensearch.threadpool.TestThreadPool)9 ArrayList (java.util.ArrayList)8 InternalAggregation (org.opensearch.search.aggregations.InternalAggregation)8 Before (org.junit.Before)7 ScriptService (org.opensearch.script.ScriptService)7 NamedWriteableRegistry (org.opensearch.common.io.stream.NamedWriteableRegistry)5 BigArrays (org.opensearch.common.util.BigArrays)5 MultiBucketConsumerService (org.opensearch.search.aggregations.MultiBucketConsumerService)5 IndexReader (org.apache.lucene.index.IndexReader)4 IndexSearcher (org.apache.lucene.search.IndexSearcher)4 Directory (org.apache.lucene.store.Directory)4 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)3 QueryCachingPolicy (org.apache.lucene.search.QueryCachingPolicy)3 Mockito.anyString (org.mockito.Mockito.anyString)3 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)3 MappedFieldType (org.opensearch.index.mapper.MappedFieldType)3