/** * Sets a cluster size to a specific size in an instance with a single cluster * @throws InterruptedException if the cluster is in the middle of updating, and an interrupt was * received */ public void setClusterSize(int newSize) throws InterruptedException { setClusterSize(getSingleCluster().getName(), newSize); }
/** * Sets a cluster size to a specific size. * @param clusterId * @param zoneId * @param newSize * @throws InterruptedException if the cluster is in the middle of updating, and an interrupt was * received */ public void setClusterSize(String clusterId, String zoneId, int newSize) throws InterruptedException { setClusterSize(instanceName.toClusterName(clusterId).getClusterName(), newSize); }
@Override public void run() { try { // [START scale_bigtable] double latestValue = getLatestValue().getValue().getDoubleValue(); if (latestValue < CPU_PERCENT_TO_DOWNSCALE) { int clusterSize = clusterUtility.getClusterNodeCount(clusterId, zoneId); if (clusterSize > MIN_NODE_COUNT) { clusterUtility.setClusterSize(clusterId, zoneId, Math.max(clusterSize - SIZE_CHANGE_STEP, MIN_NODE_COUNT)); } } else if (latestValue > CPU_PERCENT_TO_UPSCALE) { int clusterSize = clusterUtility.getClusterNodeCount(clusterId, zoneId); if (clusterSize <= MAX_NODE_COUNT) { clusterUtility.setClusterSize(clusterId, zoneId, Math.min(clusterSize + SIZE_CHANGE_STEP, MAX_NODE_COUNT)); } } // [END scale_bigtable] } catch (Exception e) { e.printStackTrace(); } } };