当前位置: 首页>>代码示例>>Java>>正文


Java ClusterStateResponse类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.state.ClusterStateResponse的典型用法代码示例。如果您正苦于以下问题:Java ClusterStateResponse类的具体用法?Java ClusterStateResponse怎么用?Java ClusterStateResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClusterStateResponse类属于org.elasticsearch.action.admin.cluster.state包,在下文中一共展示了ClusterStateResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getESFields

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
public static List<String> getESFields(String index, String type) {
	List<String> fieldList = new ArrayList<String>();
	boolean indexExist = ESReport.getESClient().admin().indices().prepareExists(index).execute().actionGet().isExists();
	ClusterStateResponse resp = ESReport.getESClient().admin().cluster().prepareState().execute().actionGet();
	boolean typeExist = resp.getState().metaData().index(index).getMappings().containsKey(type);

	if (indexExist && typeExist) {
		ClusterState cs = ESReport.getESClient().admin().cluster().prepareState().setIndices(index).execute().actionGet().getState();
		IndexMetaData imd = cs.getMetaData().index(index);
		MappingMetaData mdd = imd.mapping(type);
		Map<String, Object> map = null;
		try {
			map = mdd.getSourceAsMap();
		} catch (IOException e) {
			e.printStackTrace();
		}
		fieldList = getList("", map);
	}
	return fieldList;
}
 
开发者ID:raghavendar-ts,项目名称:ElasticTab-Elasticsearch-to-Excel-Report,代码行数:21,代码来源:Util.java

示例2: ensureStableCluster

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
protected void ensureStableCluster(int nodeCount, TimeValue timeValue, boolean local, @Nullable String viaNode) {
    if (viaNode == null) {
        viaNode = randomFrom(internalCluster().getNodeNames());
    }
    logger.debug("ensuring cluster is stable with [{}] nodes. access node: [{}]. timeout: [{}]", nodeCount, viaNode, timeValue);
    ClusterHealthResponse clusterHealthResponse = client(viaNode).admin().cluster().prepareHealth()
        .setWaitForEvents(Priority.LANGUID)
        .setWaitForNodes(Integer.toString(nodeCount))
        .setTimeout(timeValue)
        .setLocal(local)
        .setWaitForNoRelocatingShards(true)
        .get();
    if (clusterHealthResponse.isTimedOut()) {
        ClusterStateResponse stateResponse = client(viaNode).admin().cluster().prepareState().get();
        fail("failed to reach a stable cluster of [" + nodeCount + "] nodes. Tried via [" + viaNode + "]. last cluster state:\n"
            + stateResponse.getState());
    }
    assertThat(clusterHealthResponse.isTimedOut(), is(false));
    ensureFullyConnectedCluster();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ESIntegTestCase.java

示例3: doCatRequest

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
    final String matchPattern = request.hasParam("name") ? request.param("name") : null;
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().metaData(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestResponseListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse clusterStateResponse) throws Exception {
            return RestTable.buildResponse(buildTable(request, clusterStateResponse, matchPattern), channel);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:RestTemplatesAction.java

示例4: buildTable

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
private Table buildTable(RestRequest request, ClusterStateResponse clusterStateResponse, String patternString) {
    Table table = getTableWithHeader(request);
    MetaData metadata = clusterStateResponse.getState().metaData();
    for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : metadata.templates()) {
        IndexTemplateMetaData indexData = entry.value;
        if (patternString == null || Regex.simpleMatch(patternString, indexData.name())) {
            table.startRow();
            table.addCell(indexData.name());
            table.addCell("[" + String.join(", ", indexData.patterns()) + "]");
            table.addCell(indexData.getOrder());
            table.addCell(indexData.getVersion());
            table.endRow();
        }
    }
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestTemplatesAction.java

示例5: doCatRequest

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
@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);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:RestSegmentsAction.java

示例6: doCatRequest

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
@Override
public 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).metaData(true).routingTable(true).indices(indices);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest();
            indicesStatsRequest.all();
            indicesStatsRequest.indices(indices);
            client.admin().indices().stats(indicesStatsRequest, new RestResponseListener<IndicesStatsResponse>(channel) {
                @Override
                public RestResponse buildResponse(IndicesStatsResponse indicesStatsResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, indicesStatsResponse), channel);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RestShardsAction.java

示例7: doCatRequest

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
@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) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(false).os(false).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {
                @Override
                public RestResponse buildResponse(NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestNodeAttrsAction.java

示例8: buildTable

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    boolean fullId = req.paramAsBoolean("full_id", false);

    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
            table.startRow();
            table.addCell(node.getName());
            table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            table.addCell(node.getAddress().address().getPort());
            table.addCell(attrEntry.getKey());
            table.addCell(attrEntry.getValue());
            table.endRow();
        }
    }
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestNodeAttrsAction.java

示例9: buildTable

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
private Table buildTable(RestRequest request, ClusterStateResponse state) {
    Table table = getTableWithHeader(request);
    DiscoveryNodes nodes = state.getState().nodes();

    table.startRow();
    DiscoveryNode master = nodes.get(nodes.getMasterNodeId());
    if (master == null) {
        table.addCell("-");
        table.addCell("-");
        table.addCell("-");
        table.addCell("-");
    } else {
        table.addCell(master.getId());
        table.addCell(master.getHostName());
        table.addCell(master.getHostAddress());
        table.addCell(master.getName());
    }
    table.endRow();

    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestMasterAction.java

示例10: doCatRequest

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
@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);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestPluginsAction.java

示例11: buildTable

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
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());

        for (PluginInfo pluginInfo : info.getPlugins().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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RestPluginsAction.java

示例12: assertNoShardsOn

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
/** wait until none of the nodes have shards allocated on them */
private void assertNoShardsOn(final List<String> nodeList) throws Exception {
    assertBusy(new Runnable() {
        @Override
        public void run() {
            ClusterStateResponse resp = client().admin().cluster().prepareState().get();
            RoutingNodes nodes = resp.getState().getRoutingNodes();
            for (RoutingNode node : nodes) {
                logger.info("--> node {} has {} shards", node.node().getName(), node.numberOfOwningShards());
                if (nodeList.contains(node.node().getName())) {
                    assertThat("no shards on node", node.numberOfOwningShards(), equalTo(0));
                }
            }
        }
    }, 1, TimeUnit.MINUTES);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndexWithShadowReplicasIT.java

示例13: assertShardCountOn

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
/** wait until the node has the specified number of shards allocated on it */
private void assertShardCountOn(final String nodeName, final int shardCount) throws Exception {
    assertBusy(new Runnable() {
        @Override
        public void run() {
            ClusterStateResponse resp = client().admin().cluster().prepareState().get();
            RoutingNodes nodes = resp.getState().getRoutingNodes();
            for (RoutingNode node : nodes) {
                logger.info("--> node {} has {} shards", node.node().getName(), node.numberOfOwningShards());
                if (nodeName.equals(node.node().getName())) {
                    assertThat(node.numberOfOwningShards(), equalTo(shardCount));
                }
            }
        }
    }, 1, TimeUnit.MINUTES);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndexWithShadowReplicasIT.java

示例14: testJustMasterNode

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
public void testJustMasterNode() throws Exception {
    logger.info("--> cleaning nodes");

    logger.info("--> starting 1 master node non data");
    internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());

    logger.info("--> create an index");
    client().admin().indices().prepareCreate("test").setWaitForActiveShards(ActiveShardCount.NONE).execute().actionGet();

    logger.info("--> closing master node");
    internalCluster().closeNonSharedNodes(false);

    logger.info("--> starting 1 master node non data again");
    internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());

    logger.info("--> waiting for test index to be created");
    ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setIndices("test")
        .execute().actionGet();
    assertThat(health.isTimedOut(), equalTo(false));

    logger.info("--> verify we have an index");
    ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setIndices("test").execute().actionGet();
    assertThat(clusterStateResponse.getState().metaData().hasIndex("test"), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:GatewayIndexStateIT.java

示例15: testFilteringByIndexWorks

import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; //导入依赖的package包/类
/**
 * Retrieves the cluster state for the given indices and then checks
 * that the cluster state returns coherent data for both routing table and metadata.
 */
private void testFilteringByIndexWorks(String[] indices, String[] expected) {
    ClusterStateResponse clusterState = client().admin().cluster().prepareState()
                                                                        .clear()
                                                                        .setMetaData(true)
                                                                        .setRoutingTable(true)
                                                                        .setIndices(indices)
                                                                        .get();

    ImmutableOpenMap<String, IndexMetaData> metaData = clusterState.getState().getMetaData().indices();
    assertThat(metaData.size(), is(expected.length));

    RoutingTable routingTable = clusterState.getState().getRoutingTable();
    assertThat(routingTable.indicesRouting().size(), is(expected.length));

    for (String expectedIndex : expected) {
        assertThat(metaData, CollectionAssertions.hasKey(expectedIndex));
        assertThat(routingTable.hasIndex(expectedIndex), is(true));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:SimpleClusterStateIT.java


注:本文中的org.elasticsearch.action.admin.cluster.state.ClusterStateResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。