Class BigtableChangeStreamAccessor
java.lang.Object
org.apache.beam.sdk.io.gcp.bigtable.changestreams.dao.BigtableChangeStreamAccessor
- All Implemented Interfaces:
AutoCloseable
This is probably a temporary solution to what is a bigger migration from
cloud-bigtable-client-core to java-bigtable.
This class creates and maintains the lifecycle java-bigtable clients to interact with Cloud Bigtable. This class creates singletons of data and admin clients for each project/instance/table/app profile. Per workers, there should only be 1 instance of the client for each table/app profile. This ensures we're not creating many/excessive connections with the backend and the jobs on the same machine shares the same sets of connections.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()com.google.cloud.bigtable.data.v2.BigtableDataClientcom.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClientstatic BigtableChangeStreamAccessorgetOrCreate(@NonNull BigtableConfig bigtableConfig) Create a BigtableAccess if it doesn't exist and store it in the cache for faster access.com.google.cloud.bigtable.admin.v2.BigtableTableAdminClientstatic voidsetReadChangeStreamTimeout(Duration timeout)
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
setReadChangeStreamTimeout
-
getOrCreate
public static BigtableChangeStreamAccessor getOrCreate(@NonNull BigtableConfig bigtableConfig) throws IOException Create a BigtableAccess if it doesn't exist and store it in the cache for faster access. If it does exist, just return it.- Parameters:
bigtableConfig- config that contains all the parameters to connect to a Cloud Bigtable instance- Returns:
- data and admin clients connected to the Cloud Bigtable instance
- Throws:
IOException- if the connection fails
-
getDataClient
public com.google.cloud.bigtable.data.v2.BigtableDataClient getDataClient() -
getTableAdminClient
public com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient getTableAdminClient() -
getInstanceAdminClient
public com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient getInstanceAdminClient()
-