/** * Gets the serve node count of an instance with a single cluster. * @return the {@link Cluster#getServeNodes()} of the clusterId. */ public int getClusterSize() { return getSingleCluster().getServeNodes(); }
/** * 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); }
/** * @return The cluster associated with the given project and instance. We expect instance and * cluster to have one-to-one relationship. * @throws IllegalStateException if the cluster is not found or if there are many clusters in this * instance. */ public static Cluster lookupCluster(String projectId, String instanceId) throws IOException { BigtableClusterUtilities utils; try { utils = BigtableClusterUtilities.forInstance(projectId, instanceId); } catch (GeneralSecurityException e) { throw new RuntimeException("Could not initialize BigtableClusterUtilities", e); } try { return utils.getSingleCluster(); } finally { try { utils.close(); } catch (Exception e) { logger.warn("Error closing BigtableClusterUtilities: ", e); } } }
/** * Constructor for the auto-scaler with the minimum required information: project and instance ids. * @param projectId * @param instanceId * @throws GeneralSecurityException * @throws IOException */ public MetricScaler(String projectId, String instanceId) throws GeneralSecurityException, IOException { clusterUtility = BigtableClusterUtilities.forInstance(projectId, instanceId); Cluster cluster = clusterUtility.getSingleCluster(); this.clusterId = new BigtableClusterName(cluster.getName()).getClusterId(); this.zoneId = BigtableClusterUtilities.getZoneId(cluster); // Instantiates a client metricServiceClient = MetricServiceClient.create(); projectName = ProjectName.create(projectId); }