Returns the max configured replica count.
When invoked for the first time, this method will fetch the
configuration from a cluster member.

@return the maximum configured replica count
976085
private int getMaxConfiguredReplicaCount() {
        if (maxConfiguredReplicaCount > 0) {
            return maxConfiguredReplicaCount;
        } else {
            final ClientMessage request = PNCounterGetConfiguredReplicaCountCodec.encodeRequest(name);
            final ClientMessage response = invoke(request);
            final PNCounterGetConfiguredReplicaCountCodec.ResponseParameters resultParameters
                    = PNCounterGetConfiguredReplicaCountCodec.decodeResponse(response);
            maxConfiguredReplicaCount = resultParameters.response;
        }
        return maxConfiguredReplicaCount;
    }
1192509
public static clusterinstance[] get(nitro_service service) throws Exception{
		clusterinstance obj = new clusterinstance();
		clusterinstance[] response = (clusterinstance[])obj.get_resources(service);
		return response;
	}
1077382
public ClusterInfo getClusterInfoOrThrow() {
        ClusterInfo clusterInfo = getClusterInfoOrNull();
        if (clusterInfo == null) {
            throw new IllegalArgumentException("Elasticsearch cluster name:[ " + InternalConfigurationOptions.INTERNAL_ES_CLUSTER_NAME +
                    "] not present in configuration");
        }
        return clusterInfo;
    }
626296
private Version getClusterOrNodeVersion() {
        if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
            return node.getClusterService().getClusterVersion();
        } else {
            String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
            return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
                    : node.getVersion().asVersion();
        }
    }
1005559
public synchronized Node masterNode() {
        final ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState();
        final String name = state.nodes().getMasterNode().getName();
        return getNode(name);
    }
1049156
public java.util.List<String> getMemberClusters() {
        if (memberClusters == null) {
            memberClusters = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return memberClusters;
    }
912879
public long getNodesCount() throws RepositoryException
   {
      try
      {
         ResultSet countNodes = findNodesCount();
         try
         {
            if (countNodes.next())
            {
               return countNodes.getLong(1);
            }
            else
            {
               throw new SQLException("ResultSet has't records.");
            }
         }
         finally
         {
            JDBCUtils.freeResources(countNodes, null, null);
         }
      }
      catch (SQLException e)
      {
         throw new RepositoryException("Can not calculate nodes count", e);
      }
   }
279825
public ClusterNode getRunnableNode(RequestedNode requestedNode,
                                     LocalityLevel maxLevel,
                                     ResourceType type,
                                     Set<String> excluded) {
    ClusterNode node = null;
    RunnableIndices r = typeToIndices.get(type);

    // find host local
    node = r.getRunnableNodeForHost(requestedNode);

    if (maxLevel == LocalityLevel.NODE || node != null) {
      return node;
    }
    node = r.getRunnableNodeForRack(requestedNode, excluded);

    if (maxLevel == LocalityLevel.RACK || node != null) {
      return node;
    }

    // find any node
    node = r.getRunnableNodeForAny(excluded);

    return node;
  }
1299895
private int getInitialPartitionCount() throws IllegalAccessException
    {
        AppointerState currentState = m_state.get();
        if (currentState != AppointerState.INIT && currentState != AppointerState.CLUSTER_START) {
            throw new IllegalAccessException("Getting cached partition count after cluster " +
                    "startup");
        }
        return m_initialPartitionCount;
    }
167235
public long allocNew() throws IOException {

        int i;
        int entryIndex = -1;

        for (i = lastAllocatedCluster; i < lastClusterIndex; i++) {
            if (isFreeCluster(i)) {
                entryIndex = i;
                break;
            }
        }
        
        if (entryIndex < 0) {
            for (i = FIRST_CLUSTER; i < lastAllocatedCluster; i++) {
                if (isFreeCluster(i)) {
                    entryIndex = i;
                    break;
                }
            }
        }
        
        if (entryIndex < 0) {
            throw new IOException(
                    "FAT Full (" + (lastClusterIndex - FIRST_CLUSTER)
                    + ", " + i + ")"); //NOI18N
        }
        
        entries[entryIndex] = fatType.getEofMarker();
        lastAllocatedCluster = entryIndex % lastClusterIndex;
        if (lastAllocatedCluster < FIRST_CLUSTER)
            lastAllocatedCluster = FIRST_CLUSTER;
        
        return entryIndex;
    }
848642
int calculateReplicationFactor(List<HostToken> allHostTokens) {
        Map<Long, Integer> groups = new HashMap<>();

        Set<HostToken> uniqueHostTokens = new HashSet<>(allHostTokens);

        String dataCenter = cpConfig.getLocalDataCenter();
        if (dataCenter == null) {
            dataCenter = localRack.substring(0, localRack.length() - 1);
        }

        for (HostToken hostToken: uniqueHostTokens) {
        	if (hostToken.getHost().getRack().contains(dataCenter)) {
				Long token = hostToken.getToken();
				if (groups.containsKey(token)) {
					int current = groups.get(token);
					groups.put(token, current + 1);
				} else {
					groups.put(token, 1);
				}
			}
        }

        Set<Integer> uniqueCounts = new HashSet<>(groups.values());

        if (uniqueCounts.size() > 1) {
            throw new RuntimeException("Invalid configuration - replication factor cannot be asymmetric");
        }

        int rf = uniqueCounts.toArray(new Integer[uniqueCounts.size()])[0];

        if (rf > 3) {
            logger.warn("Replication Factor is high: " + uniqueHostTokens);
        }

        return rf;
    }
1217112
private String getRegistrationRequestEntity() throws FileNotFoundException {
        // update the registration request with the max concurrent sessions/vms
        final GridNodeConfiguration gnc =
                GridNodeConfiguration.loadFromJSON(SeLionGridConstants.NODE_SAUCE_CONFIG_FILE);

        // get the max concurrent vm's allowed for the account from sauce labs
        final SauceLabsRestApi restApi;
        try {
            restApi = new SauceLabsRestApi();
        } catch (GridConfigurationException e) {
            throw e;
        }

        final int maxConcurrent = restApi.getMaxConcurrency();
        if (maxConcurrent != -1) {
            // update max sessions
            gnc.maxSession = maxConcurrent;

            // update browser max instances for all saucelabs "browser" types
            for (MutableCapabilities caps : gnc.capabilities) {
                if (caps.getBrowserName().equals(SAUCELABS_BROWSER_NAME)) {
                    caps.setCapability(MAX_INSTANCES_CONFIG_PROPERTY, maxConcurrent);
                }
            }
        }

        // ensure the proxy host, port, id is set for http://ondemand.saucelabs.com:80
        if (StringUtils.isBlank(gnc.host)) {
            gnc.host = PROXY_HOST;
        }
        if (StringUtils.isBlank(gnc.id)) {
            gnc.id = PROXY_ID;
        }
        if (gnc.port == null || gnc.port < 0) {
            gnc.port = PROXY_PORT;
        }

        return new RegistrationRequest(gnc, SeLionSauceProxy.class.getSimpleName(),
                "SeLion Grid Virtual Sauce Proxy").toJson().toString();
    }
660300
@Override
    public void scale(final String applicationName, final int replicas) {
        final DeploymentConfig deploymentConfig = getClient()
            .deploymentConfigs()
            .inNamespace(this.namespace)
            .withName(applicationName)
            .scale(replicas);
        final int availableReplicas = deploymentConfig.getStatus().getAvailableReplicas();
        log.info(String.format("Scaling replicas from %d to %d for application %s.", availableReplicas, replicas, applicationName));
        awaitApplicationReadinessOrFail(applicationName);
    }
532275
public long getRangeTo() {
		final long limit = (liveUpdated ? database.getStorage().getClusterDataRange(current.clusterId)[1] : lastClusterPosition) + 1;
		if (rangeTo > -1)
			return Math.min(rangeTo, limit);
		return limit;
	}
5558
public long getDoneSaving(Configuration conf) {
    try {
      DFSClient dfs = ((DistributedFileSystem)FileSystem.get(conf)).getClient();
      Counters raidedCounters = stateToSourceCounters.get(RaidState.RAIDED);
      Counters shouldRaidCounters =
          stateToSourceCounters.get(RaidState.NOT_RAIDED_BUT_SHOULD);
      long physical = estimatedDoneSourceSize + estimatedDoneParitySize;
      long logical = raidedCounters.getNumLogical() +
          shouldRaidCounters.getNumLogical();
      return logical * dfs.getDefaultReplication() - physical;
    } catch (Exception e) {
      return -1;
    }
  }
1152564
public Integer getMaxPoolSize()
   {
      if (childNode.getTextValueForPatternName("max-pool-size") != null && !childNode.getTextValueForPatternName("max-pool-size").equals("null")) {
         return Integer.valueOf(childNode.getTextValueForPatternName("max-pool-size"));
      }
      return null;
   }
1100554
protected MemberId next() {
    // If a connection was already established then use that connection.
    if (currentNode != null) {
      return currentNode;
    }

    if (!selector.hasNext()) {
      if (selector.leader() != null) {
        selector.reset(null, selector.members());
        this.currentNode = selector.next();
        this.selectionId++;
        return currentNode;
      } else {
        log.debug("Failed to connect to the cluster");
        selector.reset();
        return null;
      }
    } else {
      this.currentNode = selector.next();
      this.selectionId++;
      return currentNode;
    }
  }