0
val connection = BigtableConfiguration.connect(projectID, instanceID)
val admin = connection.getAdmin
Try {
  admin.tableExists(TableName.valueOf(tableName)) match {
    case true => connection.getTable(TableName.valueOf(tableName))
    case false => throw new IllegalStateException("The requested table do not exist.")
  }
}

This code can check if the table exists for a valid project ID and instance ID. Otherwise it will error out. Is there any way to check if the project ID and instance ID are valid using bigtable HBase API? I couldn't find a method to do that.

mmziyad
  • 298
  • 1
  • 4
  • 16

1 Answers1

1

There's a class called BigtableClusterUtilities that will allow you to get back a cluster for a projectId and instanceId. You can call getClusters() to check to make sure that there is indeed a cluster for that projectId and instanceId.

Solomon Duskis
  • 2,691
  • 16
  • 12
  • This still doesn't help to check if the project ID and instance ID are valid or not. Any call to `BigtableClusterUtilities` with invalid projectID ends up in a `RuntimeException`. – mmziyad Oct 18 '17 at 10:22
  • Can you please create an issue here with the details of the exception: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/issues? – Solomon Duskis Oct 18 '17 at 14:42