com.google.cloud.bigtable.grpc
Class BigtableSession
- java.lang.Object
-
- com.google.cloud.bigtable.grpc.BigtableSession
-
- All Implemented Interfaces:
- Closeable, AutoCloseable
public class BigtableSession extends Object implements Closeable
Encapsulates the creation of Bigtable Grpc services.The following functionality is handled by this class:
- Creates Executors
- Creates Channels - netty ChannelImpls, ReconnectingChannel and ChannelPools
- Creates ChannelInterceptors - auth headers, performance interceptors.
- Close anything above that needs to be closed (ExecutorService, ChannelImpls)
- Version:
- $Id: $Id
- Author:
- sduskis
-
-
Constructor Summary
Constructors Constructor and Description BigtableSession(BigtableOptions opts)
Constructor for BigtableSession.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description void
close()
BulkMutation
createBulkMutation(BigtableTableName tableName)
createBulkMutation.IBulkMutation
createBulkMutationWrapper(BigtableTableName tableName)
createBulkMutationWrapper.BulkRead
createBulkRead(BigtableTableName tableName)
createBulkRead.protected io.grpc.ManagedChannel
createChannelPool(ChannelPool.ChannelFactory channelFactory, int count)
Create a newChannelPool
, with auth headers.static io.grpc.ManagedChannel
createChannelPool(String host, BigtableOptions options)
Create a newChannelPool
, with auth headers.static io.grpc.ManagedChannel
createChannelPool(String host, BigtableOptions options, int count)
Create a newChannelPool
, with auth headers.protected io.grpc.ManagedChannel
createChannelPool(String hostString, int count)
Create a newChannelPool
, with auth headers.static BigtableInstanceClient
createInstanceClient(BigtableOptions options)
Create aBigtableInstanceClient
.protected io.grpc.ManagedChannel
createManagedPool(String host, int channelCount)
Create a newChannelPool
, with auth headers, that will be cleaned up when the connection closes.static io.grpc.ManagedChannel
createNettyChannel(String host, BigtableOptions options, io.grpc.ClientInterceptor... interceptors)
createNettyChannel.BigtableClusterName
getClusterName()
Snapshot operations need various aspects of aBigtableClusterName
.BigtableDataClient
getDataClient()
Getter for the fielddataClient
.IBigtableDataClient
getDataClientWrapper()
Getter for the fieldclientWrapper
.BigtableInstanceClient
getInstanceAdminClient()
Getter for the fieldinstanceAdminClient
.BigtableOptions
getOptions()
Getter for the fieldoptions
.BigtableTableAdminClient
getTableAdminClient()
Deprecated.Please usegetTableAdminClientWrapper()
.IBigtableTableAdminClient
getTableAdminClientWrapper()
Initializes bigtableTableAdminClient based on flag to use GCJ adapter, available inBigtableOptions
.protected List<io.grpc.ClientInterceptor>
setupInterceptors()
-
-
-
Constructor Detail
-
BigtableSession
public BigtableSession(BigtableOptions opts) throws IOException
Constructor for BigtableSession.- Parameters:
opts
- aBigtableOptions
object.- Throws:
IOException
- if any.
-
-
Method Detail
-
setupInterceptors
protected List<io.grpc.ClientInterceptor> setupInterceptors() throws IOException
- Throws:
IOException
-
getClusterName
public BigtableClusterName getClusterName() throws IOException
Snapshot operations need various aspects of aBigtableClusterName
. This method gets a clusterId from either a lookup (projectId and instanceId translate to a single clusterId when an instance has only one cluster).- Throws:
IOException
-
getDataClient
public BigtableDataClient getDataClient()
Getter for the fielddataClient
.- Returns:
- a
BigtableDataClient
object.
-
getDataClientWrapper
public IBigtableDataClient getDataClientWrapper()
Getter for the fieldclientWrapper
.- Returns:
- a
IBigtableDataClient
object.
-
createBulkMutation
public BulkMutation createBulkMutation(BigtableTableName tableName)
createBulkMutation.- Parameters:
tableName
- aBigtableTableName
object.- Returns:
- a
BulkMutation
object.
-
createBulkMutationWrapper
public IBulkMutation createBulkMutationWrapper(BigtableTableName tableName)
createBulkMutationWrapper.- Parameters:
tableName
- aBigtableTableName
object.- Returns:
- a
IBigtableDataClient
object.
-
createBulkRead
public BulkRead createBulkRead(BigtableTableName tableName)
createBulkRead.- Parameters:
tableName
- aBigtableTableName
object.- Returns:
- a
BulkRead
object.
-
getTableAdminClient
@Deprecated public BigtableTableAdminClient getTableAdminClient() throws IOException
Deprecated. Please usegetTableAdminClientWrapper()
.Getter for the fieldtableAdminClient
.- Returns:
- a
BigtableTableAdminClient
object. - Throws:
IOException
- if any.
-
getTableAdminClientWrapper
public IBigtableTableAdminClient getTableAdminClientWrapper() throws IOException
Initializes bigtableTableAdminClient based on flag to use GCJ adapter, available inBigtableOptions
.- Returns:
- a
BigtableTableAdminClientWrapper
object. - Throws:
IOException
- if any.
-
getInstanceAdminClient
public BigtableInstanceClient getInstanceAdminClient() throws IOException
Getter for the fieldinstanceAdminClient
.- Returns:
- a
BigtableInstanceClient
object. - Throws:
IOException
- if any.
-
createChannelPool
protected io.grpc.ManagedChannel createChannelPool(String hostString, int count) throws IOException
Create a newChannelPool
, with auth headers.- Parameters:
hostString
- aString
object.- Returns:
- a
ChannelPool
object. - Throws:
IOException
- if any.
-
createChannelPool
protected io.grpc.ManagedChannel createChannelPool(ChannelPool.ChannelFactory channelFactory, int count) throws IOException
Create a newChannelPool
, with auth headers. This method allows users to override the default implementation with their own.- Parameters:
channelFactory
- aChannelPool.ChannelFactory
object.count
- The number of channels in the pool.- Returns:
- a
ChannelPool
object. - Throws:
IOException
- if any.
-
createManagedPool
protected io.grpc.ManagedChannel createManagedPool(String host, int channelCount) throws IOException
Create a newChannelPool
, with auth headers, that will be cleaned up when the connection closes.- Parameters:
host
- aString
object.- Returns:
- a
ChannelPool
object. - Throws:
IOException
- if any.
-
createInstanceClient
public static BigtableInstanceClient createInstanceClient(BigtableOptions options) throws IOException, GeneralSecurityException
Create aBigtableInstanceClient
.BigtableSession
objects assume thatBigtableOptions
have a project and instance. ABigtableInstanceClient
does not require project id or instance id, soBigtableOptions.getDefaultOptions()
may be used if there are no service account credentials settings.- Returns:
- a fully formed
BigtableInstanceClient
- Throws:
IOException
GeneralSecurityException
-
createChannelPool
public static io.grpc.ManagedChannel createChannelPool(String host, BigtableOptions options) throws IOException, GeneralSecurityException
Create a newChannelPool
, with auth headers.- Parameters:
host
- aString
object.options
- aBigtableOptions
object.- Returns:
- a
ChannelPool
object. - Throws:
IOException
- if any.GeneralSecurityException
-
createChannelPool
public static io.grpc.ManagedChannel createChannelPool(String host, BigtableOptions options, int count) throws IOException, GeneralSecurityException
Create a newChannelPool
, with auth headers.- Parameters:
host
- aString
object specifying the host to connect to.options
- aBigtableOptions
object with the credentials, retry and other connection options.count
- an int defining the number of channels to create- Returns:
- a
ChannelPool
object. - Throws:
IOException
- if any.GeneralSecurityException
-
createNettyChannel
public static io.grpc.ManagedChannel createNettyChannel(String host, BigtableOptions options, io.grpc.ClientInterceptor... interceptors) throws SSLException
createNettyChannel.- Parameters:
host
- aString
object.options
- aBigtableOptions
object.- Returns:
- a
ManagedChannel
object. - Throws:
SSLException
- if any.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getOptions
public BigtableOptions getOptions()
Getter for the fieldoptions
.- Returns:
- a
BigtableOptions
object.
-
-