當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。