/** * Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers. * * @param host a {@link String} object. * @param options a {@link BigtableOptions} object. * @return a {@link ChannelPool} object. * @throws IOException if any. * @throws GeneralSecurityException */ public static ManagedChannel createChannelPool(final String host, final BigtableOptions options) throws IOException, GeneralSecurityException { return createChannelPool(host, options, 1); }
/** * Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers. * * @param hostString a {@link java.lang.String} object. * @return a {@link com.google.cloud.bigtable.grpc.io.ChannelPool} object. * @throws java.io.IOException if any. */ protected ManagedChannel createChannelPool(final String hostString, int count) throws IOException { ChannelPool.ChannelFactory channelFactory = new ChannelPool.ChannelFactory() { @Override public ManagedChannel create() throws IOException { return createNettyChannel(hostString, options, clientInterceptors); } }; return createChannelPool(channelFactory, count); }
/** * Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers, that * will be cleaned up when the connection closes. * * @param host a {@link java.lang.String} object. * @return a {@link com.google.cloud.bigtable.grpc.io.ChannelPool} object. * @throws java.io.IOException if any. */ protected ManagedChannel createManagedPool(String host, int channelCount) throws IOException { ManagedChannel channelPool = createChannelPool(host, channelCount); managedChannels.add(channelPool); return channelPool; }
/** * Create a {@link BigtableInstanceClient}. {@link BigtableSession} objects assume that * {@link BigtableOptions} have a project and instance. A {@link BigtableInstanceClient} does not * require project id or instance id, so {@link BigtableOptions#getDefaultOptions()} may be used * if there are no service account credentials settings. * * @return a fully formed {@link BigtableInstanceClient} * @throws IOException * @throws GeneralSecurityException */ public static BigtableInstanceClient createInstanceClient(BigtableOptions options) throws IOException, GeneralSecurityException { return new BigtableInstanceGrpcClient(createChannelPool(options.getAdminHost(), options)); }
/** * Constructor for the utility. Prefer * {@link BigtableClusterUtilities#forInstance(String, String)} or * {@link BigtableClusterUtilities#forAllInstances(String)} rather than this method. * @param options that specify projectId, instanceId, credentials and retry options. * @throws GeneralSecurityException * @throws IOException */ public BigtableClusterUtilities(final BigtableOptions options) throws IOException, GeneralSecurityException { this.instanceName = Preconditions.checkNotNull( options.getInstanceName(), "ProjectId and instanceId have to be set in the options. Use '-' for all instanceIds."); channel = BigtableSession.createChannelPool(options.getAdminHost(), options); client = new BigtableInstanceGrpcClient(channel); }
private ManagedChannel getDataChannelPool() throws IOException { String host = options.getDataHost(); int channelCount = options.getChannelCount(); if (options.useCachedChannel()) { synchronized (BigtableSession.class) { // TODO: Ensure that the host and channelCount are the same. if (cachedDataChannelPool == null) { cachedDataChannelPool = createChannelPool(host, channelCount); } return cachedDataChannelPool; } } return createManagedPool(host, channelCount); }