Examples of ClusterStateResponse


Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

        return stringToJson.stringToJson(builder.string());
    }

    //Just a shortcut to get all the available nodes within the cluster
    public JsonOutput availableNodes() throws Exception {
        ClusterStateResponse response = this.client.admin().cluster().state(new ClusterStateRequest()
                .filterBlocks(true).filterNodes(false).filterMetaData(true)
                .filterRoutingTable(true)).actionGet();

        XContentBuilder builder = JsonXContent.contentBuilder();
        builder.startObject();
        for (DiscoveryNode discoveryNode : response.getState().nodes()) {
            builder.startObject(discoveryNode.id());
            builder.field("name", discoveryNode.name());
            builder.endObject();
        }
        builder.endObject();
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

    /**
     * Retrieves the current indexes and types from elasticsearch
     * @return a set containing the indexes available in the elasticsearch cluster and their types
     */
    protected Set<Index> getIndexes() {
        ClusterStateResponse response = unwrapShellNativeClient().client().admin().cluster().prepareState().setFilterBlocks(true)
                .setFilterRoutingTable(true).setFilterNodes(true).execute().actionGet();

        Set<Index> newIndexes = new HashSet<Index>();
        for (IndexMetaData indexMetaData : response.getState().metaData().indices().values()) {
            logger.trace("Processing index {}", indexMetaData.index());

            Set<String> typeNames = Sets.filter(indexMetaData.mappings().keySet(), new Predicate<String>() {
                @Override
                public boolean apply(String s) {
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

        registry.counter(name("test", "cache-evictions")).inc();
        reportAndRefresh();

        // somehow the cluster state is not immediately updated... need to check
        Thread.sleep(200);
        ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setRoutingTable(false)
                .setLocal(false)
                .setNodes(true)
                .setIndices(indexWithDate)
                .execute().actionGet();

        assertThat(clusterStateResponse.getState().getMetaData().getIndices().containsKey(indexWithDate), is(true));
        IndexMetaData indexMetaData = clusterStateResponse.getState().getMetaData().getIndices().get(indexWithDate);
        assertThat(indexMetaData.getMappings().containsKey("counter"), is(true));
        Map<String, Object> properties = getAsMap(indexMetaData.mapping("counter").sourceAsMap(), "properties");
        Map<String, Object> mapping = getAsMap(properties, "name");
        assertThat(mapping, hasKey("index"));
        assertThat(mapping.get("index").toString(), is("not_analyzed"));
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

    }

    @Override
    public String getPoolUUID(String pool) {
        ClusterStateRequestBuilder builder = client.admin().cluster().prepareState();
        ClusterStateResponse response = builder.execute().actionGet();
        ClusterName name = response.getClusterName();
        return UUID.nameUUIDFromBytes(name.toString().getBytes()).toString().replace("-", "");
    }
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

    public List<String> getBucketsInPool(String pool) {
        if("default".equals(pool)) {
            List<String> bucketNameList = new ArrayList<String>();

            ClusterStateRequestBuilder stateBuilder = client.admin().cluster().prepareState();
            ClusterStateResponse response = stateBuilder.execute().actionGet();
            ImmutableOpenMap<String, IndexMetaData> indices = response.getState().getMetaData().getIndices();
            for (ObjectCursor<String> index : indices.keys()) {
                bucketNameList.add(index.value);
                IndexMetaData indexMetaData = indices.get(index.value);
                ImmutableOpenMap<String, AliasMetaData> aliases = indexMetaData.aliases();
                for(ObjectCursor<String> alias : aliases.keys()) {
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

      }//TESTED
    }
   
    if (deleteOldAliases) {
      // Remove all old aliases (unless we already have them)
      ClusterStateResponse retVal = customIndex.getRawClient().admin().cluster().prepareState()
          .setIndices(customIndex.getIndexName())
          .setRoutingTable(false).setNodes(false).setListenerThreaded(false).get();
 
      for (IndexMetaData indexMetadata: retVal.getState().getMetaData()) {
        Iterator<String> aliasIt = indexMetadata.aliases().keysIt();
        while (aliasIt.hasNext()) {
          String alias = aliasIt.next();
          if (!alias.equals(customIndex.getIndexName()) && !aliasSet.contains(alias)) {
            customIndex.removeAlias(alias);         
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

     
      // check the main index has the "collection" alias - if not then rebuild everything

      if (!bPingMainIndexFailed && (null == _aliasInfo)) {
        ElasticSearchManager docIndex = ElasticSearchManager.getIndex(DocumentPojoIndexMap.globalDocumentIndex_);
        ClusterStateResponse clusterState = docIndex.getRawClient().admin().cluster().state(new ClusterStateRequest()).actionGet();
        _aliasInfo = CrossVersionImmutableMapOfImmutableMaps.getAliases(clusterState.getState().getMetaData());
        if (!_aliasInfo.containsKey(DocumentPojoIndexMap.globalDocumentIndexCollection_)) {
          bRebuildDocsIndex = true;
        }
      } //TESTED
     
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

        // (just something that's guaranteed to exist)

      String stashedIndex = "recs_" + communityId.toString();
      String liveIndicesPrefix = "recs_t_" + communityId.toString();
     
      ClusterStateResponse clusterState = indexMgr.getRawClient().admin().cluster().state(new ClusterStateRequest()).actionGet();
      String indices[] = clusterState.getState().getMetaData().getConcreteAllOpenIndices();
      for (String index: indices) {
        if (index.startsWith(stashedIndex) || index.startsWith(liveIndicesPrefix)) {
          ElasticSearchManager.getIndex(index).deleteMe();
        }
      }//TESTED
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

   
    // 2] Get all the elasticsearch indexes that can time out:   
    // (https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetIndicesAliasesAction.java)
   
    ElasticSearchManager indexMgr = ElasticSearchManager.getIndex(DUMMY_INDEX);
    ClusterStateResponse retVal = indexMgr.getRawClient().admin().cluster().prepareState()
        .setIndices("recs_t_*")
        .setRoutingTable(false).setNodes(false).setListenerThreaded(false).get();

    long now = new Date().getTime();
   
    for (IndexMetaData indexMetadata: retVal.getState().getMetaData()) {
      String index = indexMetadata.index();

      //DEBUG
      //System.out.println("INDEX = " + index);
     
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.state.ClusterStateResponse

      // Stashed index
     
      ArrayList<String> indices = new ArrayList<String>();
     
      String stashedIndex = "recs_" + commIdStr;
      ClusterStateResponse retVal = indexMgr.getRawClient().admin().cluster().prepareState()
          .setIndices(stashedIndex)
          .setRoutingTable(false).setNodes(false).setListenerThreaded(false).get();
     
      if (!retVal.getState().getMetaData().getIndices().isEmpty()) {
        indices.add(stashedIndex);
      } // (else doesn't exist...)
     
      // Live indexes:
     
      String indexPattern = new StringBuffer("recs_t_").append(commIdStr).append("*").toString();
      retVal = indexMgr.getRawClient().admin().cluster().prepareState()
          .setIndices(indexPattern)
          .setRoutingTable(false).setNodes(false).setListenerThreaded(false).get();

      for (IndexMetaData indexMetadata: retVal.getState().getMetaData()) {
        //DEBUG
        //System.out.println("INDEX=" + indexMetadata.index());
        indices.add(indexMetadata.index());           
      }
      deleteSourceKeyRecords(indexMgr, indices.toArray(new String[0]), testInfo.sourceKey);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.