Search in sources :

Example 6 with PluginsService

use of org.elasticsearch.plugins.PluginsService in project elasticsearch by elastic.

the class IndicesRequestIT method assertAllRequestsHaveBeenConsumed.

private static void assertAllRequestsHaveBeenConsumed() {
    Iterable<PluginsService> pluginsServices = internalCluster().getInstances(PluginsService.class);
    for (PluginsService pluginsService : pluginsServices) {
        Set<Map.Entry<String, List<TransportRequest>>> entries = pluginsService.filterPlugins(InterceptingTransportService.TestPlugin.class).stream().findFirst().get().instance.requests.entrySet();
        assertThat(entries, emptyIterable());
    }
}
Also used : PluginsService(org.elasticsearch.plugins.PluginsService) TransportRequest(org.elasticsearch.transport.TransportRequest)

Example 7 with PluginsService

use of org.elasticsearch.plugins.PluginsService in project crate by crate.

the class IndexRecoveryIT method testDoNotInfinitelyWaitForMapping.

@Test
public void testDoNotInfinitelyWaitForMapping() {
    internalCluster().ensureAtLeastNumDataNodes(3);
    execute("CREATE ANALYZER test_analyzer (" + " TOKENIZER standard," + " TOKEN_FILTERS (test_token_filter)" + ")");
    execute("CREATE TABLE test (test_field TEXT INDEX USING FULLTEXT WITH (ANALYZER='test_analyzer'))" + " CLUSTERED INTO 1 SHARDS WITH (number_of_replicas = 0)");
    int numDocs = between(1, 10);
    var args = new Object[numDocs][];
    for (int i = 0; i < numDocs; i++) {
        args[i] = new Object[] { Integer.toString(i) };
    }
    execute("INSERT INTO test (test_field) VALUES (?)", args);
    Semaphore recoveryBlocked = new Semaphore(1);
    for (DiscoveryNode node : clusterService().state().nodes()) {
        MockTransportService transportService = (MockTransportService) internalCluster().getInstance(TransportService.class, node.getName());
        transportService.addSendBehavior((connection, requestId, action, request, options) -> {
            if (action.equals(PeerRecoverySourceService.Actions.START_RECOVERY)) {
                if (recoveryBlocked.tryAcquire()) {
                    PluginsService pluginService = internalCluster().getInstance(PluginsService.class, node.getName());
                    for (TestAnalysisPlugin plugin : pluginService.filterPlugins(TestAnalysisPlugin.class)) {
                        plugin.throwParsingError.set(true);
                    }
                }
            }
            connection.sendRequest(requestId, action, request, options);
        });
    }
    execute("ALTER TABLE test SET (number_of_replicas = 1)");
    ensureGreen();
    refresh();
    var searchResponse = execute("SELECT COUNT(*) FROM test");
    assertThat((long) searchResponse.rows()[0][0], is((long) numDocs));
}
Also used : PluginsService(org.elasticsearch.plugins.PluginsService) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) MockTransportService(org.elasticsearch.test.transport.MockTransportService) TransportService(org.elasticsearch.transport.TransportService) MockTransportService(org.elasticsearch.test.transport.MockTransportService) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test)

Aggregations

PluginsService (org.elasticsearch.plugins.PluginsService)7 ArrayList (java.util.ArrayList)3 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 Settings (org.elasticsearch.common.settings.Settings)2 TransportRequest (org.elasticsearch.transport.TransportRequest)2 TransportService (org.elasticsearch.transport.TransportService)2 Test (org.junit.Test)2 Closeable (java.io.Closeable)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Semaphore (java.util.concurrent.Semaphore)1 TimeUnit (java.util.concurrent.TimeUnit)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 IOUtils (org.apache.lucene.util.IOUtils)1 Action (org.elasticsearch.action.Action)1