Search in sources :

Example 1 with PluginsAndModules

use of org.opensearch.action.admin.cluster.node.info.PluginsAndModules in project OpenSearch by opensearch-project.

the class RestPluginsAction method buildTable.

private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        if (info == null) {
            continue;
        }
        PluginsAndModules plugins = info.getInfo(PluginsAndModules.class);
        if (plugins == null) {
            continue;
        }
        for (PluginInfo pluginInfo : plugins.getPluginInfos()) {
            table.startRow();
            table.addCell(node.getId());
            table.addCell(node.getName());
            table.addCell(pluginInfo.getName());
            table.addCell(pluginInfo.getVersion());
            table.addCell(pluginInfo.getDescription());
            table.endRow();
        }
    }
    return table;
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) Table(org.opensearch.common.Table) NodeInfo(org.opensearch.action.admin.cluster.node.info.NodeInfo) PluginsAndModules(org.opensearch.action.admin.cluster.node.info.PluginsAndModules) PluginInfo(org.opensearch.plugins.PluginInfo) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes)

Example 2 with PluginsAndModules

use of org.opensearch.action.admin.cluster.node.info.PluginsAndModules in project OpenSearch by opensearch-project.

the class PluginInfoTests method testPluginListSorted.

public void testPluginListSorted() {
    List<PluginInfo> plugins = new ArrayList<>();
    plugins.add(new PluginInfo("c", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass", Collections.emptyList(), randomBoolean()));
    plugins.add(new PluginInfo("b", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass", Collections.emptyList(), randomBoolean()));
    plugins.add(new PluginInfo("e", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass", Collections.emptyList(), randomBoolean()));
    plugins.add(new PluginInfo("a", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass", Collections.emptyList(), randomBoolean()));
    plugins.add(new PluginInfo("d", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass", Collections.emptyList(), randomBoolean()));
    PluginsAndModules pluginsInfo = new PluginsAndModules(plugins, Collections.emptyList());
    final List<PluginInfo> infos = pluginsInfo.getPluginInfos();
    List<String> names = infos.stream().map(PluginInfo::getName).collect(Collectors.toList());
    assertThat(names, contains("a", "b", "c", "d", "e"));
}
Also used : PluginsAndModules(org.opensearch.action.admin.cluster.node.info.PluginsAndModules) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 3 with PluginsAndModules

use of org.opensearch.action.admin.cluster.node.info.PluginsAndModules in project OpenSearch by opensearch-project.

the class NodeInfoStreamingTests method createNodeInfo.

private static NodeInfo createNodeInfo() {
    Build build = Build.CURRENT;
    DiscoveryNode node = new DiscoveryNode("test_node", buildNewFakeTransportAddress(), emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
    Settings settings = randomBoolean() ? null : Settings.builder().put("test", "setting").build();
    OsInfo osInfo = null;
    if (randomBoolean()) {
        int availableProcessors = randomIntBetween(1, 64);
        int allocatedProcessors = randomIntBetween(1, availableProcessors);
        long refreshInterval = randomBoolean() ? -1 : randomNonNegativeLong();
        String name = randomAlphaOfLengthBetween(3, 10);
        String arch = randomAlphaOfLengthBetween(3, 10);
        String version = randomAlphaOfLengthBetween(3, 10);
        osInfo = new OsInfo(refreshInterval, availableProcessors, allocatedProcessors, name, name, arch, version);
    }
    ProcessInfo process = randomBoolean() ? null : new ProcessInfo(randomInt(), randomBoolean(), randomNonNegativeLong());
    JvmInfo jvm = randomBoolean() ? null : JvmInfo.jvmInfo();
    ThreadPoolInfo threadPoolInfo = null;
    if (randomBoolean()) {
        int numThreadPools = randomIntBetween(1, 10);
        List<ThreadPool.Info> threadPoolInfos = new ArrayList<>(numThreadPools);
        for (int i = 0; i < numThreadPools; i++) {
            threadPoolInfos.add(new ThreadPool.Info(randomAlphaOfLengthBetween(3, 10), randomFrom(ThreadPool.ThreadPoolType.values()), randomInt()));
        }
        threadPoolInfo = new ThreadPoolInfo(threadPoolInfos);
    }
    Map<String, BoundTransportAddress> profileAddresses = new HashMap<>();
    BoundTransportAddress dummyBoundTransportAddress = new BoundTransportAddress(new TransportAddress[] { buildNewFakeTransportAddress() }, buildNewFakeTransportAddress());
    profileAddresses.put("test_address", dummyBoundTransportAddress);
    TransportInfo transport = randomBoolean() ? null : new TransportInfo(dummyBoundTransportAddress, profileAddresses);
    HttpInfo httpInfo = randomBoolean() ? null : new HttpInfo(dummyBoundTransportAddress, randomNonNegativeLong());
    PluginsAndModules pluginsAndModules = null;
    if (randomBoolean()) {
        int numPlugins = randomIntBetween(0, 5);
        List<PluginInfo> plugins = new ArrayList<>();
        for (int i = 0; i < numPlugins; i++) {
            String name = randomAlphaOfLengthBetween(3, 10);
            plugins.add(new PluginInfo(name, randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), VersionUtils.randomVersion(random()), "1.8", randomAlphaOfLengthBetween(3, 10), name, Collections.emptyList(), randomBoolean()));
        }
        int numModules = randomIntBetween(0, 5);
        List<PluginInfo> modules = new ArrayList<>();
        for (int i = 0; i < numModules; i++) {
            String name = randomAlphaOfLengthBetween(3, 10);
            modules.add(new PluginInfo(name, randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), VersionUtils.randomVersion(random()), "1.8", randomAlphaOfLengthBetween(3, 10), name, Collections.emptyList(), randomBoolean()));
        }
        pluginsAndModules = new PluginsAndModules(plugins, modules);
    }
    IngestInfo ingestInfo = null;
    if (randomBoolean()) {
        int numProcessors = randomIntBetween(0, 5);
        List<ProcessorInfo> processors = new ArrayList<>(numProcessors);
        for (int i = 0; i < numProcessors; i++) {
            processors.add(new ProcessorInfo(randomAlphaOfLengthBetween(3, 10)));
        }
        ingestInfo = new IngestInfo(processors);
    }
    AggregationInfo aggregationInfo = null;
    if (randomBoolean()) {
        AggregationUsageService.Builder builder = new AggregationUsageService.Builder();
        int numOfAggs = randomIntBetween(0, 10);
        for (int i = 0; i < numOfAggs; i++) {
            String aggName = randomAlphaOfLength(10);
            try {
                if (randomBoolean()) {
                    builder.registerAggregationUsage(aggName);
                } else {
                    int numOfTypes = randomIntBetween(1, 10);
                    for (int j = 0; j < numOfTypes; j++) {
                        builder.registerAggregationUsage(aggName, randomAlphaOfLength(10));
                    }
                }
            } catch (IllegalArgumentException ex) {
            // Ignore duplicate strings
            }
        }
        aggregationInfo = builder.build().info();
    }
    ByteSizeValue indexingBuffer = null;
    if (randomBoolean()) {
        // pick a random long that sometimes exceeds an int:
        indexingBuffer = new ByteSizeValue(random().nextLong() & ((1L << 40) - 1));
    }
    return new NodeInfo(VersionUtils.randomVersion(random()), build, node, settings, osInfo, process, jvm, threadPoolInfo, transport, httpInfo, pluginsAndModules, ingestInfo, aggregationInfo, indexingBuffer);
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) JvmInfo(org.opensearch.monitor.jvm.JvmInfo) ProcessorInfo(org.opensearch.ingest.ProcessorInfo) HashMap(java.util.HashMap) PluginsAndModules(org.opensearch.action.admin.cluster.node.info.PluginsAndModules) XContentFactory.jsonBuilder(org.opensearch.common.xcontent.XContentFactory.jsonBuilder) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) ArrayList(java.util.ArrayList) ThreadPool(org.opensearch.threadpool.ThreadPool) ByteSizeValue(org.opensearch.common.unit.ByteSizeValue) HttpInfo(org.opensearch.http.HttpInfo) OsInfo(org.opensearch.monitor.os.OsInfo) Build(org.opensearch.Build) IngestInfo(org.opensearch.ingest.IngestInfo) PluginInfo(org.opensearch.plugins.PluginInfo) AggregationInfo(org.opensearch.search.aggregations.support.AggregationInfo) Settings(org.opensearch.common.settings.Settings) ThreadPoolInfo(org.opensearch.threadpool.ThreadPoolInfo) TransportInfo(org.opensearch.transport.TransportInfo) ProcessInfo(org.opensearch.monitor.process.ProcessInfo) ProcessorInfo(org.opensearch.ingest.ProcessorInfo) HttpInfo(org.opensearch.http.HttpInfo) PluginInfo(org.opensearch.plugins.PluginInfo) TransportInfo(org.opensearch.transport.TransportInfo) JvmInfo(org.opensearch.monitor.jvm.JvmInfo) IngestInfo(org.opensearch.ingest.IngestInfo) OsInfo(org.opensearch.monitor.os.OsInfo) AggregationInfo(org.opensearch.search.aggregations.support.AggregationInfo) ThreadPoolInfo(org.opensearch.threadpool.ThreadPoolInfo) ProcessInfo(org.opensearch.monitor.process.ProcessInfo) NodeInfo(org.opensearch.action.admin.cluster.node.info.NodeInfo) AggregationUsageService(org.opensearch.search.aggregations.support.AggregationUsageService) NodeInfo(org.opensearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress)

Aggregations

PluginsAndModules (org.opensearch.action.admin.cluster.node.info.PluginsAndModules)3 ArrayList (java.util.ArrayList)2 NodeInfo (org.opensearch.action.admin.cluster.node.info.NodeInfo)2 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)2 PluginInfo (org.opensearch.plugins.PluginInfo)2 HashMap (java.util.HashMap)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Build (org.opensearch.Build)1 DiscoveryNodes (org.opensearch.cluster.node.DiscoveryNodes)1 Table (org.opensearch.common.Table)1 Settings (org.opensearch.common.settings.Settings)1 BoundTransportAddress (org.opensearch.common.transport.BoundTransportAddress)1 ByteSizeValue (org.opensearch.common.unit.ByteSizeValue)1 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)1 XContentFactory.jsonBuilder (org.opensearch.common.xcontent.XContentFactory.jsonBuilder)1 HttpInfo (org.opensearch.http.HttpInfo)1 IngestInfo (org.opensearch.ingest.IngestInfo)1 ProcessorInfo (org.opensearch.ingest.ProcessorInfo)1 JvmInfo (org.opensearch.monitor.jvm.JvmInfo)1 OsInfo (org.opensearch.monitor.os.OsInfo)1