Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法使用JavaAPI获取安装在ElasticSearch上的插件列表?_Java_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Java,elasticsearch" /> elasticsearch,Java,elasticsearch" />

有没有办法使用JavaAPI获取安装在ElasticSearch上的插件列表?

有没有办法使用JavaAPI获取安装在ElasticSearch上的插件列表?,java,elasticsearch,Java,elasticsearch,我希望通过编程获得安装在ElasticSearch集群上的插件列表。虽然没有使用RESTAPI(我已经找到)实现这一点的具体方法,但我能够使用rest接口提出解决方案;但是,我想知道是否有一种方法可以使用JavaAPI实现这一点。应该可以这样做: import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.node.

我希望通过编程获得安装在ElasticSearch集群上的插件列表。虽然没有使用RESTAPI(我已经找到)实现这一点的具体方法,但我能够使用rest接口提出解决方案;但是,我想知道是否有一种方法可以使用JavaAPI实现这一点。

应该可以这样做:

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.action.admin.cluster.node.info.PluginInfo;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

...

        Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "es160").build();
        final Client client = new TransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300));

        NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
        for (PluginInfo pluginInfo : nodesInfoResponse.getNodes()[0].getPlugins().getInfos()) {
            System.out.println(pluginInfo.getName());            
        }
...
这正是我所需要的;经过测试,效果良好。谢谢@Andrei