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