Search in sources :

Example 1 with PluginInfo

use of org.opensearch.plugins.PluginInfo 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 PluginInfo

use of org.opensearch.plugins.PluginInfo in project job-scheduler by opensearch-project.

the class SampleExtensionPluginIT method testPluginsAreInstalled.

public void testPluginsAreInstalled() {
    ClusterHealthRequest request = new ClusterHealthRequest();
    ClusterHealthResponse response = OpenSearchIntegTestCase.client().admin().cluster().health(request).actionGet();
    Assert.assertEquals(ClusterHealthStatus.GREEN, response.getStatus());
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
    nodesInfoRequest.addMetric(NodesInfoRequest.Metric.PLUGINS.metricName());
    NodesInfoResponse nodesInfoResponse = OpenSearchIntegTestCase.client().admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
    List<PluginInfo> pluginInfos = nodesInfoResponse.getNodes().get(0).getInfo(PluginsAndModules.class).getPluginInfos();
    Assert.assertTrue(pluginInfos.stream().anyMatch(pluginInfo -> pluginInfo.getName().equals("opensearch-job-scheduler")));
    Assert.assertTrue(pluginInfos.stream().anyMatch(pluginInfo -> pluginInfo.getName().equals("opensearch-job-scheduler-sample-extension")));
}
Also used : NodesInfoResponse(org.opensearch.action.admin.cluster.node.info.NodesInfoResponse) NodesInfoResponse(org.opensearch.action.admin.cluster.node.info.NodesInfoResponse) List(java.util.List) ClusterHealthResponse(org.opensearch.action.admin.cluster.health.ClusterHealthResponse) NodesInfoRequest(org.opensearch.action.admin.cluster.node.info.NodesInfoRequest) PluginsAndModules(org.opensearch.action.admin.cluster.node.info.PluginsAndModules) PluginInfo(org.opensearch.plugins.PluginInfo) Assert(org.junit.Assert) ClusterHealthRequest(org.opensearch.action.admin.cluster.health.ClusterHealthRequest) OpenSearchIntegTestCase(org.opensearch.test.OpenSearchIntegTestCase) ClusterHealthStatus(org.opensearch.cluster.health.ClusterHealthStatus) ClusterHealthResponse(org.opensearch.action.admin.cluster.health.ClusterHealthResponse) ClusterHealthRequest(org.opensearch.action.admin.cluster.health.ClusterHealthRequest) PluginsAndModules(org.opensearch.action.admin.cluster.node.info.PluginsAndModules) NodesInfoRequest(org.opensearch.action.admin.cluster.node.info.NodesInfoRequest) PluginInfo(org.opensearch.plugins.PluginInfo)

Example 3 with PluginInfo

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

the class PluginsAndModules method toXContent.

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startArray("plugins");
    for (PluginInfo pluginInfo : getPluginInfos()) {
        pluginInfo.toXContent(builder, params);
    }
    builder.endArray();
    // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on)
    builder.startArray("modules");
    for (PluginInfo moduleInfo : getModuleInfos()) {
        moduleInfo.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
Also used : PluginInfo(org.opensearch.plugins.PluginInfo)

Example 4 with PluginInfo

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

the class Spawner method spawnNativeControllers.

/**
 * Spawns the native controllers for each module.
 *
 * @param environment The node environment
 * @param inheritIo   Should the stdout and stderr of the spawned process inherit the
 *                    stdout and stderr of the JVM spawning it?
 * @throws IOException if an I/O error occurs reading the module or spawning a native process
 */
void spawnNativeControllers(final Environment environment, final boolean inheritIo) throws IOException {
    if (!spawned.compareAndSet(false, true)) {
        throw new IllegalStateException("native controllers already spawned");
    }
    if (!Files.exists(environment.modulesFile())) {
        throw new IllegalStateException("modules directory [" + environment.modulesFile() + "] not found");
    }
    /*
         * For each module, attempt to spawn the controller daemon. Silently ignore any module that doesn't include a controller for the
         * correct platform.
         */
    List<Path> paths = PluginsService.findPluginDirs(environment.modulesFile());
    for (final Path modules : paths) {
        final PluginInfo info = PluginInfo.readFromProperties(modules);
        final Path spawnPath = Platforms.nativeControllerPath(modules);
        if (!Files.isRegularFile(spawnPath)) {
            continue;
        }
        if (!info.hasNativeController()) {
            final String message = String.format(Locale.ROOT, "module [%s] does not have permission to fork native controller", modules.getFileName());
            throw new IllegalArgumentException(message);
        }
        final Process process = spawnNativeController(spawnPath, environment.tmpFile(), inheritIo);
        processes.add(process);
    }
}
Also used : Path(java.nio.file.Path) PluginInfo(org.opensearch.plugins.PluginInfo)

Example 5 with PluginInfo

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

the class ClusterStatsNodes method toXContent.

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.COUNT);
    counts.toXContent(builder, params);
    builder.endObject();
    builder.startArray(Fields.VERSIONS);
    for (Version v : versions) {
        builder.value(v.toString());
    }
    builder.endArray();
    builder.startObject(Fields.OS);
    os.toXContent(builder, params);
    builder.endObject();
    builder.startObject(Fields.PROCESS);
    process.toXContent(builder, params);
    builder.endObject();
    builder.startObject(Fields.JVM);
    jvm.toXContent(builder, params);
    builder.endObject();
    builder.field(Fields.FS);
    fs.toXContent(builder, params);
    builder.startArray(Fields.PLUGINS);
    for (PluginInfo pluginInfo : plugins) {
        pluginInfo.toXContent(builder, params);
    }
    builder.endArray();
    builder.startObject(Fields.NETWORK_TYPES);
    networkTypes.toXContent(builder, params);
    builder.endObject();
    discoveryTypes.toXContent(builder, params);
    packagingTypes.toXContent(builder, params);
    ingestStats.toXContent(builder, params);
    return builder;
}
Also used : Version(org.opensearch.Version) PluginInfo(org.opensearch.plugins.PluginInfo)

Aggregations

PluginInfo (org.opensearch.plugins.PluginInfo)6 PluginsAndModules (org.opensearch.action.admin.cluster.node.info.PluginsAndModules)3 NodeInfo (org.opensearch.action.admin.cluster.node.info.NodeInfo)2 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Assert (org.junit.Assert)1 Build (org.opensearch.Build)1 Version (org.opensearch.Version)1 ClusterHealthRequest (org.opensearch.action.admin.cluster.health.ClusterHealthRequest)1 ClusterHealthResponse (org.opensearch.action.admin.cluster.health.ClusterHealthResponse)1 NodesInfoRequest (org.opensearch.action.admin.cluster.node.info.NodesInfoRequest)1 NodesInfoResponse (org.opensearch.action.admin.cluster.node.info.NodesInfoResponse)1 ClusterHealthStatus (org.opensearch.cluster.health.ClusterHealthStatus)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