org.elasticsearch.plugins.PluginInfo Java Examples

The following examples show how to use org.elasticsearch.plugins.PluginInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterStatsNodes.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    counts = Counts.readCounts(in);

    int size = in.readVInt();
    versions = new HashSet<>(size);
    for (; size > 0; size--) {
        versions.add(Version.readVersion(in));
    }

    os = OsStats.readOsStats(in);
    process = ProcessStats.readStats(in);
    jvm = JvmStats.readJvmStats(in);
    fs = FsInfo.Path.readInfoFrom(in);

    size = in.readVInt();
    plugins = new HashSet<>(size);
    for (; size > 0; size--) {
        plugins.add(PluginInfo.readFromStream(in));
    }
}
 
Example #2
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    if (plugins.isEmpty() == false || modules.isEmpty() == false) {
        throw new IllegalStateException("instance is already populated");
    }
    int plugins_size = in.readInt();
    for (int i = 0; i < plugins_size; i++) {
        plugins.add(PluginInfo.readFromStream(in));
    }
    if (in.getVersion().onOrAfter(Version.V_2_2_0)) {
        int modules_size = in.readInt();
        for (int i = 0; i < modules_size; i++) {
            modules.add(PluginInfo.readFromStream(in));
        }
    }
}
 
Example #3
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #4
Source File: Elasticsearch5SearchIndex.java    From vertexium with Apache License 2.0 6 votes vote down vote up
private boolean checkPluginInstalled(Client client) {
    if (config.isForceDisableVertexiumPlugin()) {
        LOGGER.info("Forcing the vertexium plugin off. Running without the server side Vertexium plugin will disable some features.");
        return false;
    }

    NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if ("vertexium".equals(pluginInfo.getName())) {
                return true;
            }
        }
    }
    if (config.isErrorOnMissingVertexiumPlugin()) {
        throw new VertexiumException("Vertexium plugin cannot be found");
    }
    LOGGER.warn("Running without the server side Vertexium plugin will disable some features.");
    return false;
}
 
Example #5
Source File: SirenJoinPluginTest.java    From siren-join with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testPluginLoaded() {
  NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
  assertTrue(nodesInfoResponse.getNodes().length != 0);
  assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos(), notNullValue());
  assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos().size(), not(0));

  boolean pluginFound = false;

  for (PluginInfo pluginInfo : nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos()) {
    if (pluginInfo.getName().equals("SirenJoinPlugin")) {
      pluginFound = true;
      break;
    }
  }

  assertThat(pluginFound, is(true));
}
 
Example #6
Source File: AnalysisOpenKoreanTextPluginTest.java    From elasticsearch-analysis-openkoreantext with Apache License 2.0 5 votes vote down vote up
public void testPluginIsLoaded() {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo node : response.getNodes()) {
        boolean founded = false;
        for (PluginInfo pluginInfo : node.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(AnalysisOpenKoreanTextPlugin.class.getName())) {
                founded = true;
            }
        }
        Assert.assertTrue(founded);
    }
}
 
Example #7
Source File: RestPluginsAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
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.id());

        for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) {
            table.startRow();
            table.addCell(node.id());
            table.addCell(node.name());
            table.addCell(pluginInfo.getName());
            table.addCell(pluginInfo.getVersion());
            String type;
            if (pluginInfo.isSite()) {
                if (pluginInfo.isJvm()) {
                    type = "j/s";
                } else {
                    type = "s";
                }
            } else {
                if (pluginInfo.isJvm()) {
                    type = "j";
                } else {
                    type = "";
                }
            }
            table.addCell(type);
            table.addCell(pluginInfo.getUrl());
            table.addCell(pluginInfo.getDescription());
            table.endRow();
        }
    }

    return table;
}
 
Example #8
Source File: ClusterStatsNodes.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    counts.writeTo(out);
    out.writeVInt(versions.size());
    for (Version v : versions) Version.writeVersion(v, out);
    os.writeTo(out);
    process.writeTo(out);
    jvm.writeTo(out);
    fs.writeTo(out);
    out.writeVInt(plugins.size());
    for (PluginInfo p : plugins) {
        p.writeTo(out);
    }
}
 
Example #9
Source File: ClusterStatsNodes.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@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();
    return builder;
}
 
Example #10
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an ordered list based on plugins name
 */
public List<PluginInfo> getPluginInfos() {
    List<PluginInfo> plugins = new ArrayList<>(this.plugins);
    Collections.sort(plugins, new Comparator<PluginInfo>() {
        @Override
        public int compare(PluginInfo p1, PluginInfo p2) {
            return p1.getName().compareTo(p2.getName());
        }
    });
    return plugins;
}
 
Example #11
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an ordered list based on modules name
 */
public List<PluginInfo> getModuleInfos() {
    List<PluginInfo> modules = new ArrayList<>(this.modules);
    Collections.sort(modules, new Comparator<PluginInfo>() {
        @Override
        public int compare(PluginInfo p1, PluginInfo p2) {
            return p1.getName().compareTo(p2.getName());
        }
    });
    return modules;
}
 
Example #12
Source File: VietnameseAnalysisIntegrationTest.java    From elasticsearch-analysis-vietnamese with Apache License 2.0 5 votes vote down vote up
public void testPluginIsLoaded() throws Exception {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        boolean pluginFound = false;
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(AnalysisVietnamesePlugin.class.getName())) {
                pluginFound = true;
                break;
            }
        }
        assertThat(pluginFound, is(true));
    }
}
 
Example #13
Source File: DecompoundQueryTests.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
public void testPluginIsLoaded() {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        boolean pluginFound = false;
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(BundlePlugin.class.getName())) {
                pluginFound = true;
                break;
            }
        }
        assertThat(pluginFound, is(true));
    }
}
 
Example #14
Source File: ClusterStatsNodes.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public Set<PluginInfo> getPlugins() {
    return plugins;
}
 
Example #15
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public void addPlugin(PluginInfo info) {
    plugins.add(info);
}
 
Example #16
Source File: PluginsAndModules.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public void addModule(PluginInfo info) {
    modules.add(info);
}