# Class BigtableDataClientFactory (2.79.0)

2.79.0 (latest) 2.78.1 2.77.0 2.74.0 2.73.0 2.72.0 2.71.0 2.70.0 2.68.0 2.67.1 2.66.0 2.65.1 2.63.0 2.62.0 2.61.0 2.60.0 2.59.0 2.58.2 2.56.0 2.54.0 2.52.0 2.51.2 2.49.0 2.46.0 2.45.1 2.44.1 2.43.0 2.42.0 2.40.0 2.39.5 2.37.0 2.35.1 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.1 2.28.0

> [!WARNING]
> **Beta**
>
>
> This library is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1)
> of the Terms of Service. Pre-GA libraries might have limited support,
> and changes to pre-GA libraries might not be compatible with other pre-GA versions.
> For more information, see the
> [launch stage descriptions](https://docs.cloud.google.com/products#product-launch-stages).

    public final class BigtableDataClientFactory implements AutoCloseable

A factory to create multiple [BigtableDataClient](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient) instances that all share the same channel
pool.

This allows multiple client instances to share the same gRPC channel pool, which makes client
creation very cheap. The intended use case is for applications that need to access multiple
Bigtable Instances from the same process.

Example Usage:


     BigtableDataSettings defaultSettings = BigtableDataSettings.newBuilder()
       .setProject("my-default-project")
       .setInstance("my-default-instance")
       .build();

     BigtableDataClientFactory clientFactory = BigtableDataClientFactory.create(defaultSettings);

     // Create a new client for "my-default-instance" in "my-default-project";
     BigtableDataClient defaultInstanceClient = clientFactory.createDefault();

     // Create a new client for a different application profile
     BigtableDataClient otherAppProfileClient = clientFactory.createForAppProfile("other-app-profile");

     // Create a new client for a completely different instance and application profile.
     BigtableDataClient otherInstanceClient = clientFactory
       .createForInstance("my-other-project", "my-other-instance", "my-other-app-profile");

     // Clean up: make sure close the clients AND the factory.
     defaultInstanceClient.close();
     otherAppProfileClient.close();
     otherInstanceClient.close();

     clientFactory.close();

     `Please note that this is an experimental feature and might be changed or removed in future.
     `

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> BigtableDataClientFactory

## Implements

[AutoCloseable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### create(BigtableDataSettings defaultSettings)

    public static BigtableDataClientFactory create(BigtableDataSettings defaultSettings)

Create a instance of this factory.

The factory will be used to create clients using the provided settings as the base. Make
sure to call [#close()](https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClientFactory#com_google_cloud_bigtable_data_v2_BigtableDataClientFactory_close__) on the factory after closing all clients.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `defaultSettings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClientFactory` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

## Methods

### close()

    public void close()

Release all of the resources associated with this factory.

This will close the underlying channel pooling, disconnecting all create clients.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html` |   |

### createDefault()

    public BigtableDataClient createDefault()

Create a lightweight client using the default settings in this factory. This will use the
factory default project, instance and application profile ids. The client will also share
resources like the channel pool with other clients created using this factory.

The client should be closed when it is no longer needed. Closing the client will release
client specific resources, but will leave shared resources like the channel pool open. To
release all resources, first close all of the created clients and then this factory instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient` |   |

### createForAppProfile(String appProfileId)

    public BigtableDataClient createForAppProfile(String appProfileId)

Create a lightweight client with an overriden application profile and the factory default
project and instance ids. The client will also share resources like the channel pool with other
clients created using this factory.

The client should be closed when it is no longer needed. Closing the client will release
client specific resources, but will leave shared resources like the channel pool open. To
release all resources, first close all of the created clients and then this factory instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `appProfileId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### createForInstance(String projectId, String instanceId)

    public BigtableDataClient createForInstance(String projectId, String instanceId)

Create a lightweight client with the specified project and instance id. The resulting client
will use the server default application profile. The client will also share resources like the
channel pool with other clients created using this factory.

The client should be closed when it is no longer needed. Closing the client will release
client specific resources, but will leave shared resources like the channel pool open. To
release all resources, first close all of the created clients and then this factory instance.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `projectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `instanceId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### createForInstance(String projectId, String instanceId, String appProfileId)

    public BigtableDataClient createForInstance(String projectId, String instanceId, String appProfileId)

Create a lightweight client to the specified project, instance and application profile id. The
client will share resources like the channel pool with other clients created using this
factory.

The client should be closed when it is no longer needed. Closing the client will release
client specific resources, but will leave shared resources like the channel pool open. To
release all resources, first close all of the created clients and then this factory instance.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `projectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `instanceId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `appProfileId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |