/** * Gets the current number of nodes allocated to the cluster. * @param clusterId * @param zoneId * @return the serveNode count of the cluster. */ public int getClusterNodeCount(String clusterId, String zoneId) { return getCluster(clusterId, zoneId).getServeNodes(); }
/** * Gets the serve node count of the cluster. * @param clusterId * @param zoneId * @return the {@link Cluster#getServeNodes()} of the clusterId. * @deprecated Use {@link #getCluster(String, String)} or {@link #getSingleCluster()} and then * call {@link Cluster#getServeNodes()}. */ @Deprecated public int getClusterSize(String clusterId, String zoneId) { Cluster cluster = getCluster(clusterId, zoneId); String message = String.format("Cluster %s/%s was not found.", clusterId, zoneId); Preconditions.checkNotNull(cluster, message); return cluster.getServeNodes(); }
/** * @return The instance id associated with the given project, zone and cluster. We expect instance * and cluster to have one-to-one relationship. * * @throws IllegalStateException if the cluster is not found */ public static String lookupInstanceId(String projectId, String clusterId, String zoneId) throws IOException { BigtableClusterUtilities utils; try { utils = BigtableClusterUtilities.forAllInstances(projectId); } catch (GeneralSecurityException e) { throw new RuntimeException("Could not initialize BigtableClusterUtilities", e); } try { Cluster cluster = utils.getCluster(clusterId, zoneId); return new BigtableClusterName(cluster.getName()).getInstanceId(); } finally { try { utils.close(); } catch (Exception e) { logger.warn("Error closing BigtableClusterUtilities: ", e); } } }