Examples of ClusterIndexHealth


Examples of com.dotcms.repackage.org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

    }

        AdminLogger.log(this.getClass(), "clearIndex", "Trying to clear index: " + indexName);

        Map<String, ClusterIndexHealth> map = getClusterHealth();
    ClusterIndexHealth cih = map.get(indexName);
    int shards = cih.getNumberOfShards();
    int replicas = cih.getNumberOfReplicas();

    String alias=getIndexAlias(indexName);

    iapi.delete(indexName);
View Full Code Here

Examples of com.dotcms.repackage.org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

    public  synchronized void updateReplicas (String indexName, int replicas) throws DotDataException {

      AdminLogger.log(this.getClass(), "updateReplicas", "Trying to update replicas to index: " + indexName);
     
      Map<String,ClusterIndexHealth> idxs = getClusterHealth();
    ClusterIndexHealth health = idxs.get( indexName);
    if(health ==null){
      return;
    }
    int curReplicas = health.getNumberOfReplicas();

    if(curReplicas != replicas){


      Map newSettings = new HashMap();
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

        numberOfNodes = in.readVInt();
        numberOfDataNodes = in.readVInt();
        status = ClusterHealthStatus.fromValue(in.readByte());
        int size = in.readVInt();
        for (int i = 0; i < size; i++) {
            ClusterIndexHealth indexHealth = readClusterIndexHealth(in);
            indices.put(indexHealth.index(), indexHealth);
        }
        timedOut = in.readBoolean();
        size = in.readVInt();
        if (size == 0) {
            validationFailures = ImmutableList.of();
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

   
    // First time through, check the replication factor is correct...
    ClusterHealthResponse health =
      _elasticClient.admin().cluster().health(new ClusterHealthRequest(sIndexName)).actionGet();
   
    ClusterIndexHealth indexStatus = health.getIndices().get(sIndexName);
    if ((null != indexStatus) && (1 == indexStatus.getShards().size())) { // 1 shard => this is a "data local" index
           
      int nNumNodes = health.getNumberOfDataNodes();
      Builder localSettings = ImmutableSettings.settingsBuilder();
      if (nNumNodes > 1) {
        localSettings.put("number_of_replicas", nNumNodes - 1); // (ie shard=1 + replicas==num_nodes)
      }
      else {
        localSettings.put("number_of_replicas", 1); // (System doesn't work very well if has no replicas?)       
      }
      UpdateSettingsUtils.updateSettings(_elasticClient.admin().indices(), sIndexName, localSettings.build());
     
      //(Wait for above operation to be completed)
      _elasticClient.admin().cluster().health(new ClusterHealthRequest(sIndexName).waitForYellowStatus()).actionGet();
    }
    else if ((null != indexStatus) && (indexStatus.getNumberOfReplicas() > 1)) { // Multi shard index, just need to check there aren't too many replicas for nodes
     
      int nNumNodes = health.getNumberOfDataNodes();
      int nReplicas = indexStatus.getNumberOfReplicas();
      int nNodesPerReplica = properties.getElasticNodesPerReplica();
      if ((nNumNodes > 0) && (nNodesPerReplica > 0)) {
        int nNewReplicas = (nNumNodes + nNodesPerReplica-1)/nNodesPerReplica;
          // (ie round up)
        int nMaxReplicas = properties.getElasticMaxReplicas();
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

    private Table buildTable(RestRequest request, String[] indices, ClusterHealthResponse health, IndicesStatsResponse stats, MetaData indexMetaDatas) {
        Table table = getTableWithHeader(request);

        for (String index : indices) {
            ClusterIndexHealth indexHealth = health.getIndices().get(index);
            IndexStats indexStats = stats.getIndices().get(index);
            IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(index);
            IndexMetaData.State state = indexMetaData.getState();

            table.startRow();
            table.addCell(state == IndexMetaData.State.OPEN ? (indexHealth == null ? "red*" : indexHealth.getStatus().toString().toLowerCase(Locale.ROOT)) : null);
            table.addCell(state.toString().toLowerCase(Locale.ROOT));
            table.addCell(index);
            table.addCell(indexHealth == null ? null : indexHealth.getNumberOfShards());
            table.addCell(indexHealth == null ? null : indexHealth.getNumberOfReplicas());
            table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getCount());
            table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getDeleted());

            table.addCell(indexStats == null ? null : indexStats.getTotal().getStore().size());
            table.addCell(indexStats == null ? null : indexStats.getPrimaries().getStore().size());
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

        int numberOfReplicas = randomInt(4);
        IndexMetaData indexMetaData = IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas).build();
        ShardCounter counter = new ShardCounter();
        IndexRoutingTable indexRoutingTable = genIndexRoutingTable(indexMetaData, counter);

        ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
        logger.info("index status: {}, expected {}", indexHealth.getStatus(), counter.status());
        assertIndexHealth(indexHealth, counter, indexMetaData);
    }
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

        IndexMetaData indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(2).build();
        ShardCounter counter = new ShardCounter();
        IndexRoutingTable indexRoutingTable = genIndexRoutingTable(indexMetaData, counter);
        indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(3).build();

        ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
        assertThat(indexHealth.getValidationFailures(), Matchers.hasSize(2));

        RoutingTable.Builder routingTable = RoutingTable.builder();
        MetaData.Builder metaData = MetaData.builder();
        metaData.put(indexMetaData, true);
        routingTable.add(indexRoutingTable);
View Full Code Here

Examples of org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth

                IndexMetaData indexMetaData = clusterService.state().metaData().index(indexRoutingTable.index());
                if (indexRoutingTable == null) {
                    continue;
                }

                ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
                switch (indexHealth.getStatus()) {
                    case RED:
                        clusterStatus = ClusterHealthStatus.RED;
                        break;
                    case YELLOW:
                        if (clusterStatus != ClusterHealthStatus.RED) {
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.