Class MetastorePartitionServiceClient
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource,AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (MetastorePartitionServiceClient metastorePartitionServiceClient =
MetastorePartitionServiceClient.create()) {
BatchCreateMetastorePartitionsRequest request =
BatchCreateMetastorePartitionsRequest.newBuilder()
.setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
.addAllRequests(new ArrayList<CreateMetastorePartitionRequest>())
.setSkipExistingPartitions(true)
.build();
BatchCreateMetastorePartitionsResponse response =
metastorePartitionServiceClient.batchCreateMetastorePartitions(request);
}
Note: close() needs to be called on the MetastorePartitionServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
BatchCreateMetastorePartitions |
Adds metastore partitions to a table. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
BatchDeleteMetastorePartitions |
Deletes metastore partitions from a table. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
BatchUpdateMetastorePartitions |
Updates metastore partitions in a table. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListMetastorePartitions |
Gets metastore partitions from a table. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
StreamMetastorePartitions |
This is a bi-di streaming rpc method that allows the client to send a stream of partitions and commit all of them atomically at the end. If the commit is successful, the server will return a response and close the stream. If the commit fails (due to duplicate partitions or other reason), the server will close the stream with an error. This method is only available via the gRPC API (not REST). |
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of MetastorePartitionServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
MetastorePartitionServiceSettings metastorePartitionServiceSettings =
MetastorePartitionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
MetastorePartitionServiceClient metastorePartitionServiceClient =
MetastorePartitionServiceClient.create(metastorePartitionServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
MetastorePartitionServiceSettings metastorePartitionServiceSettings =
MetastorePartitionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
MetastorePartitionServiceClient metastorePartitionServiceClient =
MetastorePartitionServiceClient.create(metastorePartitionServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of MetastorePartitionServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) Adds metastore partitions to a table.final com.google.api.gax.rpc.UnaryCallable<BatchCreateMetastorePartitionsRequest,BatchCreateMetastorePartitionsResponse> Adds metastore partitions to a table.final voidDeletes metastore partitions from a table.final com.google.api.gax.rpc.UnaryCallable<BatchDeleteMetastorePartitionsRequest,com.google.protobuf.Empty> Deletes metastore partitions from a table.Updates metastore partitions in a table.final com.google.api.gax.rpc.UnaryCallable<BatchUpdateMetastorePartitionsRequest,BatchUpdateMetastorePartitionsResponse> Updates metastore partitions in a table.final voidclose()static final MetastorePartitionServiceClientcreate()Constructs an instance of MetastorePartitionServiceClient with default settings.static final MetastorePartitionServiceClientcreate(MetastorePartitionServiceSettings settings) Constructs an instance of MetastorePartitionServiceClient, using the given settings.static final MetastorePartitionServiceClientConstructs an instance of MetastorePartitionServiceClient, using the given stub for making calls.getStub()booleanbooleanGets metastore partitions from a table.listMetastorePartitions(TableName parent) Gets metastore partitions from a table.listMetastorePartitions(String parent) Gets metastore partitions from a table.final com.google.api.gax.rpc.UnaryCallable<ListMetastorePartitionsRequest,ListMetastorePartitionsResponse> Gets metastore partitions from a table.voidshutdown()voidfinal com.google.api.gax.rpc.BidiStreamingCallable<StreamMetastorePartitionsRequest,StreamMetastorePartitionsResponse> This is a bi-di streaming rpc method that allows the client to send a stream of partitions and commit all of them atomically at the end.
-
Constructor Details
-
MetastorePartitionServiceClient
protected MetastorePartitionServiceClient(MetastorePartitionServiceSettings settings) throws IOException Constructs an instance of MetastorePartitionServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
MetastorePartitionServiceClient
-
-
Method Details
-
create
Constructs an instance of MetastorePartitionServiceClient with default settings.- Throws:
IOException
-
create
public static final MetastorePartitionServiceClient create(MetastorePartitionServiceSettings settings) throws IOException Constructs an instance of MetastorePartitionServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of MetastorePartitionServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(MetastorePartitionServiceSettings). -
getSettings
-
getStub
-
batchCreateMetastorePartitions
public final BatchCreateMetastorePartitionsResponse batchCreateMetastorePartitions(BatchCreateMetastorePartitionsRequest request) Adds metastore partitions to a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchCreateMetastorePartitionsRequest request = BatchCreateMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllRequests(new ArrayList<CreateMetastorePartitionRequest>()) .setSkipExistingPartitions(true) .build(); BatchCreateMetastorePartitionsResponse response = metastorePartitionServiceClient.batchCreateMetastorePartitions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
batchCreateMetastorePartitionsCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchCreateMetastorePartitionsRequest,BatchCreateMetastorePartitionsResponse> batchCreateMetastorePartitionsCallable()Adds metastore partitions to a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchCreateMetastorePartitionsRequest request = BatchCreateMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllRequests(new ArrayList<CreateMetastorePartitionRequest>()) .setSkipExistingPartitions(true) .build(); ApiFuture<BatchCreateMetastorePartitionsResponse> future = metastorePartitionServiceClient .batchCreateMetastorePartitionsCallable() .futureCall(request); // Do something. BatchCreateMetastorePartitionsResponse response = future.get(); } -
batchDeleteMetastorePartitions
Deletes metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchDeleteMetastorePartitionsRequest request = BatchDeleteMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllPartitionValues(new ArrayList<MetastorePartitionValues>()) .build(); metastorePartitionServiceClient.batchDeleteMetastorePartitions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
batchDeleteMetastorePartitionsCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchDeleteMetastorePartitionsRequest,com.google.protobuf.Empty> batchDeleteMetastorePartitionsCallable()Deletes metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchDeleteMetastorePartitionsRequest request = BatchDeleteMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllPartitionValues(new ArrayList<MetastorePartitionValues>()) .build(); ApiFuture<Empty> future = metastorePartitionServiceClient .batchDeleteMetastorePartitionsCallable() .futureCall(request); // Do something. future.get(); } -
batchUpdateMetastorePartitions
public final BatchUpdateMetastorePartitionsResponse batchUpdateMetastorePartitions(BatchUpdateMetastorePartitionsRequest request) Updates metastore partitions in a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchUpdateMetastorePartitionsRequest request = BatchUpdateMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllRequests(new ArrayList<UpdateMetastorePartitionRequest>()) .build(); BatchUpdateMetastorePartitionsResponse response = metastorePartitionServiceClient.batchUpdateMetastorePartitions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
batchUpdateMetastorePartitionsCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchUpdateMetastorePartitionsRequest,BatchUpdateMetastorePartitionsResponse> batchUpdateMetastorePartitionsCallable()Updates metastore partitions in a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BatchUpdateMetastorePartitionsRequest request = BatchUpdateMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllRequests(new ArrayList<UpdateMetastorePartitionRequest>()) .build(); ApiFuture<BatchUpdateMetastorePartitionsResponse> future = metastorePartitionServiceClient .batchUpdateMetastorePartitionsCallable() .futureCall(request); // Do something. BatchUpdateMetastorePartitionsResponse response = future.get(); } -
listMetastorePartitions
Gets metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { TableName parent = TableName.of("[PROJECT]", "[DATASET]", "[TABLE]"); ListMetastorePartitionsResponse response = metastorePartitionServiceClient.listMetastorePartitions(parent); }- Parameters:
parent- Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
listMetastorePartitions
Gets metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { String parent = TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString(); ListMetastorePartitionsResponse response = metastorePartitionServiceClient.listMetastorePartitions(parent); }- Parameters:
parent- Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
listMetastorePartitions
public final ListMetastorePartitionsResponse listMetastorePartitions(ListMetastorePartitionsRequest request) Gets metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { ListMetastorePartitionsRequest request = ListMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .setFilter("filter-1274492040") .build(); ListMetastorePartitionsResponse response = metastorePartitionServiceClient.listMetastorePartitions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
listMetastorePartitionsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListMetastorePartitionsRequest,ListMetastorePartitionsResponse> listMetastorePartitionsCallable()Gets metastore partitions from a table.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { ListMetastorePartitionsRequest request = ListMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .setFilter("filter-1274492040") .build(); ApiFuture<ListMetastorePartitionsResponse> future = metastorePartitionServiceClient.listMetastorePartitionsCallable().futureCall(request); // Do something. ListMetastorePartitionsResponse response = future.get(); } -
streamMetastorePartitionsCallable
public final com.google.api.gax.rpc.BidiStreamingCallable<StreamMetastorePartitionsRequest,StreamMetastorePartitionsResponse> streamMetastorePartitionsCallable()This is a bi-di streaming rpc method that allows the client to send a stream of partitions and commit all of them atomically at the end. If the commit is successful, the server will return a response and close the stream. If the commit fails (due to duplicate partitions or other reason), the server will close the stream with an error. This method is only available via the gRPC API (not REST).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (MetastorePartitionServiceClient metastorePartitionServiceClient = MetastorePartitionServiceClient.create()) { BidiStream<StreamMetastorePartitionsRequest, StreamMetastorePartitionsResponse> bidiStream = metastorePartitionServiceClient.streamMetastorePartitionsCallable().call(); StreamMetastorePartitionsRequest request = StreamMetastorePartitionsRequest.newBuilder() .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString()) .addAllMetastorePartitions(new ArrayList<MetastorePartition>()) .setSkipExistingPartitions(true) .build(); bidiStream.send(request); for (StreamMetastorePartitionsResponse response : bidiStream) { // Do something when a response is received. } } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfacecom.google.api.gax.core.BackgroundResource- Throws:
InterruptedException
-