Search in sources :

Example 6 with RestActionListener

use of org.elasticsearch.rest.action.RestActionListener in project elasticsearch by elastic.

the class RestNodesAction method doCatRequest.

@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    final boolean fullId = request.paramAsBoolean("full_id", false);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(true).os(true).process(true).http(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {

                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {

                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
Also used : FieldDataStats(org.elasticsearch.index.fielddata.FieldDataStats) GET(org.elasticsearch.rest.RestRequest.Method.GET) FlushStats(org.elasticsearch.index.flush.FlushStats) Table(org.elasticsearch.common.Table) SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) Strings(org.elasticsearch.common.Strings) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings) IndexingStats(org.elasticsearch.index.shard.IndexingStats) Locale(java.util.Locale) NodesStatsResponse(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) CompletionStats(org.elasticsearch.search.suggest.completion.CompletionStats) NodeIndicesStats(org.elasticsearch.indices.NodeIndicesStats) ScriptStats(org.elasticsearch.script.ScriptStats) MergeStats(org.elasticsearch.index.merge.MergeStats) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) FsInfo(org.elasticsearch.monitor.fs.FsInfo) RestResponse(org.elasticsearch.rest.RestResponse) OsStats(org.elasticsearch.monitor.os.OsStats) RestController(org.elasticsearch.rest.RestController) QueryCacheStats(org.elasticsearch.index.cache.query.QueryCacheStats) Collectors(java.util.stream.Collectors) NodesStatsRequest(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RequestCacheStats(org.elasticsearch.index.cache.request.RequestCacheStats) JvmStats(org.elasticsearch.monitor.jvm.JvmStats) RefreshStats(org.elasticsearch.index.refresh.RefreshStats) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) TransportAddress(org.elasticsearch.common.transport.TransportAddress) ProcessStats(org.elasticsearch.monitor.process.ProcessStats) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) HttpInfo(org.elasticsearch.http.HttpInfo) GetStats(org.elasticsearch.index.get.GetStats) SearchStats(org.elasticsearch.index.search.stats.SearchStats) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NetworkAddress(org.elasticsearch.common.network.NetworkAddress) RestActionListener(org.elasticsearch.rest.action.RestActionListener) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponse(org.elasticsearch.rest.RestResponse) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) RestActionListener(org.elasticsearch.rest.action.RestActionListener) NodesStatsRequest(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest) NodesStatsResponse(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)

Example 7 with RestActionListener

use of org.elasticsearch.rest.action.RestActionListener in project elasticsearch by elastic.

the class RestPluginsAction method doCatRequest.

@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) throws Exception {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().plugins(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {

                @Override
                public RestResponse buildResponse(final NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
Also used : PluginInfo(org.elasticsearch.plugins.PluginInfo) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) GET(org.elasticsearch.rest.RestRequest.Method.GET) RestResponse(org.elasticsearch.rest.RestResponse) Table(org.elasticsearch.common.Table) RestController(org.elasticsearch.rest.RestController) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) Settings(org.elasticsearch.common.settings.Settings) RestRequest(org.elasticsearch.rest.RestRequest) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodeClient(org.elasticsearch.client.node.NodeClient) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) RestActionListener(org.elasticsearch.rest.action.RestActionListener) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)

Example 8 with RestActionListener

use of org.elasticsearch.rest.action.RestActionListener in project elasticsearch by elastic.

the class RestSegmentsAction method doCatRequest.

@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    clusterStateRequest.clear().nodes(true).routingTable(true).indices(indices);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {

        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            final IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest();
            indicesSegmentsRequest.indices(indices);
            client.admin().indices().segments(indicesSegmentsRequest, new RestResponseListener<IndicesSegmentResponse>(channel) {

                @Override
                public RestResponse buildResponse(final IndicesSegmentResponse indicesSegmentResponse) throws Exception {
                    final Map<String, IndexSegments> indicesSegments = indicesSegmentResponse.getIndices();
                    Table tab = buildTable(request, clusterStateResponse, indicesSegments);
                    return RestTable.buildResponse(tab, channel);
                }
            });
        }
    });
}
Also used : IndicesSegmentResponse(org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) GET(org.elasticsearch.rest.RestRequest.Method.GET) IndicesSegmentsRequest(org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest) RestResponse(org.elasticsearch.rest.RestResponse) ShardSegments(org.elasticsearch.action.admin.indices.segments.ShardSegments) Table(org.elasticsearch.common.Table) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) Segment(org.elasticsearch.index.engine.Segment) List(java.util.List) Settings(org.elasticsearch.common.settings.Settings) IndexSegments(org.elasticsearch.action.admin.indices.segments.IndexSegments) Map(java.util.Map) RestRequest(org.elasticsearch.rest.RestRequest) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IndexShardSegments(org.elasticsearch.action.admin.indices.segments.IndexShardSegments) RestActionListener(org.elasticsearch.rest.action.RestActionListener) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) Table(org.elasticsearch.common.Table) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) RestResponseListener(org.elasticsearch.rest.action.RestResponseListener) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) IndicesSegmentResponse(org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse) IndicesSegmentsRequest(org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest) IndexSegments(org.elasticsearch.action.admin.indices.segments.IndexSegments)

Aggregations

ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)8 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)8 NodeClient (org.elasticsearch.client.node.NodeClient)8 Table (org.elasticsearch.common.Table)8 Settings (org.elasticsearch.common.settings.Settings)8 RestController (org.elasticsearch.rest.RestController)8 RestRequest (org.elasticsearch.rest.RestRequest)8 GET (org.elasticsearch.rest.RestRequest.Method.GET)8 RestResponse (org.elasticsearch.rest.RestResponse)8 RestActionListener (org.elasticsearch.rest.action.RestActionListener)8 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)8 Strings (org.elasticsearch.common.Strings)6 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)5 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)5 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)4 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)4 NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)4 Locale (java.util.Locale)3 Map (java.util.Map)3 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)3