Search in sources :

Example 11 with PluginsService

use of org.opensearch.plugins.PluginsService in project OpenSearch by opensearch-project.

the class IndexRecoveryIT method testDoNotInfinitelyWaitForMapping.

public void testDoNotInfinitelyWaitForMapping() {
    internalCluster().ensureAtLeastNumDataNodes(3);
    createIndex("test", Settings.builder().put("index.analysis.analyzer.test_analyzer.type", "custom").put("index.analysis.analyzer.test_analyzer.tokenizer", "standard").putList("index.analysis.analyzer.test_analyzer.filter", "test_token_filter").put("index.number_of_replicas", 0).put("index.number_of_shards", 1).build());
    client().admin().indices().preparePutMapping("test").setSource("test_field", "type=text,analyzer=test_analyzer").get();
    int numDocs = between(1, 10);
    for (int i = 0; i < numDocs; i++) {
        client().prepareIndex("test").setId("u" + i).setSource(singletonMap("test_field", Integer.toString(i)), XContentType.JSON).get();
    }
    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);
        });
    }
    client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 1)).get();
    ensureGreen("test");
    client().admin().indices().prepareRefresh("test").get();
    assertHitCount(client().prepareSearch().get(), numDocs);
}
Also used : PluginsService(org.opensearch.plugins.PluginsService) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockTransportService(org.opensearch.test.transport.MockTransportService) TransportService(org.opensearch.transport.TransportService) MockTransportService(org.opensearch.test.transport.MockTransportService) Semaphore(java.util.concurrent.Semaphore)

Example 12 with PluginsService

use of org.opensearch.plugins.PluginsService in project OpenSearch by opensearch-project.

the class IndicesRequestIT method consumeTransportRequests.

private static List<TransportRequest> consumeTransportRequests(String action) {
    List<TransportRequest> requests = new ArrayList<>();
    Iterable<PluginsService> pluginsServices = internalCluster().getInstances(PluginsService.class);
    for (PluginsService pluginsService : pluginsServices) {
        List<TransportRequest> transportRequests = pluginsService.filterPlugins(InterceptingTransportService.TestPlugin.class).stream().findFirst().get().instance.consumeRequests(action);
        if (transportRequests != null) {
            requests.addAll(transportRequests);
        }
    }
    return requests;
}
Also used : PluginsService(org.opensearch.plugins.PluginsService) TransportRequest(org.opensearch.transport.TransportRequest) ArrayList(java.util.ArrayList)

Example 13 with PluginsService

use of org.opensearch.plugins.PluginsService in project OpenSearch by opensearch-project.

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.opensearch.plugins.PluginsService) TransportRequest(org.opensearch.transport.TransportRequest)

Example 14 with PluginsService

use of org.opensearch.plugins.PluginsService in project OpenSearch by opensearch-project.

the class TransportReplicationActionRetryOnClosedNodeIT method getTestPlugin.

private TestPlugin getTestPlugin(String node) {
    PluginsService pluginsService = internalCluster().getInstance(PluginsService.class, node);
    List<TestPlugin> testPlugins = pluginsService.filterPlugins(TestPlugin.class);
    assertThat(testPlugins, Matchers.hasSize(1));
    return testPlugins.get(0);
}
Also used : PluginsService(org.opensearch.plugins.PluginsService)

Example 15 with PluginsService

use of org.opensearch.plugins.PluginsService in project asynchronous-search by opensearch-project.

the class AsynchronousSearchIntegTestCase method initBlockFactory.

protected List<ScriptedBlockPlugin> initBlockFactory() {
    List<ScriptedBlockPlugin> plugins = new ArrayList<>();
    for (PluginsService pluginsService : internalCluster().getDataNodeInstances(PluginsService.class)) {
        plugins.addAll(pluginsService.filterPlugins(ScriptedBlockPlugin.class));
    }
    for (ScriptedBlockPlugin plugin : plugins) {
        plugin.reset();
        plugin.enableBlock();
    }
    return plugins;
}
Also used : PluginsService(org.opensearch.plugins.PluginsService) ArrayList(java.util.ArrayList)

Aggregations

PluginsService (org.opensearch.plugins.PluginsService)15 SecureString (org.opensearch.common.settings.SecureString)6 Environment (org.opensearch.env.Environment)6 AccessControlException (java.security.AccessControlException)5 ArrayList (java.util.ArrayList)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 OpenSearchException (org.opensearch.OpenSearchException)5 NodesReloadSecureSettingsResponse (org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsResponse)5 RemoteTransportException (org.opensearch.transport.RemoteTransportException)5 Map (java.util.Map)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 SecureSettings (org.opensearch.common.settings.SecureSettings)2 TransportRequest (org.opensearch.transport.TransportRequest)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 InputStream (java.io.InputStream)1 Semaphore (java.util.concurrent.Semaphore)1 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)1 MockSecureSettings (org.opensearch.common.settings.MockSecureSettings)1