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);
}
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;
}
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());
}
}
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);
}
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;
}
Aggregations