diff --git a/google-cloud-clients/google-cloud-bigtable/handwritten_files.lst b/google-cloud-clients/google-cloud-bigtable/handwritten_files.lst index acf082236813..7d385c98eb25 100644 --- a/google-cloud-clients/google-cloud-bigtable/handwritten_files.lst +++ b/google-cloud-clients/google-cloud-bigtable/handwritten_files.lst @@ -74,3 +74,11 @@ src/main/java/com/google/cloud/bigtable/data/v2/internal/ByteStringComparator.ja src/main/java/com/google/cloud/bigtable/data/v2/internal/DummyBatchingDescriptor.java src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java +src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java +src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java +src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequests.java +src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java +src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java +src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java +src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequestsTest.java +src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponsesTest.java diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java index a812b63202c1..e923555ab52b 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java @@ -1,15 +1,17 @@ /* * Copyright 2018 Google LLC * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.google.cloud.bigtable.admin.v2; @@ -45,14 +47,15 @@ import com.google.protobuf.ByteString; import com.google.protobuf.Empty; -/** - * Client for creating, configuring, and deleting Cloud Bigtable tables - * +/** + * Client for creating, configuring, and deleting Cloud Bigtable tables + * *
Provides access to the table schemas only, not the data stored within the tables. - * + * *
See the individual methods for example code. - * - *
Sample code to get started: + * + *
Sample code to get started: + * *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
* CreateTable createTableReq =
@@ -65,7 +68,7 @@
* client.createTable(createTableReq);
* }
*
- *
+ *
* Note: close() needs to be called on the bigtableTableAdminClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -74,23 +77,25 @@ * create(). For example: * *
To customize credentials: + * *
* BigtableTableAdminSettings bigtableTableAdminSettings =
* BigtableTableAdminSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
- * TableAdminClient client =
+ * TableAdminClient client =
* TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"), bigtableTableAdminSettings);
*
*
* To customize the endpoint:
+ *
*
* BigtableTableAdminSettings bigtableTableAdminSettings =
* BigtableTableAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * TableAdminClient client =
+ * TableAdminClient client =
* TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"), bigtableTableAdminSettings);
*
- **/
+ */
@BetaApi
public class TableAdminClient implements AutoCloseable {
private final BigtableTableAdminStub stub;
@@ -98,7 +103,7 @@ public class TableAdminClient implements AutoCloseable {
/**
* Constructs an instance of TableAdminClient with the given instanceName
- *
+ *
* @param instanceName
* @throws IOException
*/
@@ -107,20 +112,22 @@ public static TableAdminClient create(InstanceName instanceName) throws IOExcept
}
/**
- * Constructs an instance of TableAdminClient with the given instanceName and bigtableTableAdminSettings
- *
+ * Constructs an instance of TableAdminClient with the given instanceName and
+ * bigtableTableAdminSettings
+ *
* @param instanceName
* @param adminSettings
* @throws IOException
*/
- public static TableAdminClient create(InstanceName instanceName,
- BigtableTableAdminSettings adminSettings) throws IOException {
+ public static TableAdminClient create(
+ InstanceName instanceName, BigtableTableAdminSettings adminSettings) throws IOException {
return new TableAdminClient(instanceName, adminSettings);
}
/**
- * Constructs an instance of TableAdminClient with the given instanceName and bigtableTableAdminStub
- *
+ * Constructs an instance of TableAdminClient with the given instanceName and
+ * bigtableTableAdminStub
+ *
* @param instanceName
* @param stub
* @throws IOException
@@ -132,8 +139,9 @@ public static TableAdminClient create(InstanceName instanceName, BigtableTableAd
private TableAdminClient(InstanceName instanceName, BigtableTableAdminSettings adminSettings)
throws IOException {
- this(instanceName,
- ((BigtableTableAdminStubSettings) adminSettings.getStubSettings()).createStub());
+ this(
+ instanceName,
+ ((BigtableTableAdminStubSettings) adminSettings.getStubSettings()).createStub());
}
private TableAdminClient(InstanceName instanceName, BigtableTableAdminStub stub)
@@ -146,6 +154,7 @@ private TableAdminClient(InstanceName instanceName, BigtableTableAdminStub stub)
/**
* Gets the instanceName this client is associated to
+ *
* @return InstanceName
*/
public InstanceName getInstanceName() {
@@ -158,21 +167,22 @@ public void close() {
}
/**
- * Creates a new table with the specified configuration
- * See {@link TableAdminRequests.createTable} for possible configurations
- *
+ * Creates a new table with the specified configuration See {@link TableAdminRequests.createTable}
+ * for possible configurations
+ *
* Sample code: - *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
* CreateTable createTableReq =
* TableAdminRequests.createTable("tableId")
* .addColumnFamily("cf2", GCRULES.maxVersions(10))
* .withGranularity(TimestampGranularity.MILLIS);
- *
+ *
* client.createTable(createTableReq);
* }
*
- *
+ *
* @param createTable
* @return Table - the newly created table
*/
@@ -185,15 +195,15 @@ public Table createTable(CreateTable createTable) {
/**
* Creates a new table with the specified configuration asynchronously
* See {@link TableAdminRequests#createTable(String)}
- *
+ *
* Sample code:
- *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
* CreateTable createTableReq =
* TableAdminRequests.createTable("tableId")
* .addColumnFamily("cf2", GCRULES.maxVersions(10))
* .withGranularity(TimestampGranularity.MILLIS);
- *
+ *
* client.createTableAsync(createTableReq);
* }
*
@@ -207,11 +217,12 @@ public ApiFuture createTableAsync(CreateTable createTable) {
}
/**
- * Creates, Updates and drops ColumnFamilies as per the request
- * See {@link TableAdminRequests#modifyFamilies(String)}
- *
+ * Creates, Updates and drops ColumnFamilies as per the request See {@link
+ * TableAdminRequests#modifyFamilies(String)}
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
* ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
* .create("mf1")
@@ -233,24 +244,24 @@ public ApiFuture createTableAsync(CreateTable createTable) {
* client.modifyFamilies(modifyFamiliesReq);
* }
*
- *
+ *
* @param modifyFamily
* @return Table - Modified table
*/
public Table modifyFamilies(ModifyFamilies modifyFamily) {
- ModifyColumnFamiliesRequest modReq =
- modifyFamily.toProto(instanceName);
+ ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName);
com.google.bigtable.admin.v2.Table table =
this.stub.modifyColumnFamiliesCallable().call(modReq);
return TableAdminResponses.convertTable(table);
}
/**
- * Creates, Updates and drops ColumnFamilies as per the request asynchronously
- * See {@link TableAdminRequests#modifyFamilies(String)}
- *
+ * Creates, Updates and drops ColumnFamilies as per the request asynchronously See {@link
+ * TableAdminRequests#modifyFamilies(String)}
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
* ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
* .create("mf1")
@@ -272,26 +283,26 @@ public Table modifyFamilies(ModifyFamilies modifyFamily) {
* client.modifyFamiliesAsync(modifyFamiliesReq);
* }
*
- *
+ *
* @param modifyFamily
* @return Table - Modified table
*/
public ApiFuture modifyFamiliesAsync(ModifyFamilies modifyFamily) {
- ModifyColumnFamiliesRequest modReq =
- modifyFamily.toProto(instanceName);
+ ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName);
return transformToTableResponse(this.stub.modifyColumnFamiliesCallable().futureCall(modReq));
}
/**
* Deletes the specified tableId
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.deleteTable("tableId");
+ * client.deleteTable("tableId");
* }
*
- *
+ *
* @param tableId
*/
public void deleteTable(String tableId) {
@@ -299,15 +310,16 @@ public void deleteTable(String tableId) {
}
/**
- * Deletes the specified tableId asynchronously
- *
+ * Deletes the specified tableId asynchronously
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.deleteTableAsync("tableId");
+ * client.deleteTableAsync("tableId");
* }
*
- *
+ *
* @param tableId
*/
public ApiFuture deleteTableAsync(String tableId) {
@@ -317,14 +329,15 @@ public ApiFuture deleteTableAsync(String tableId) {
/**
* Gets the Table by tableId
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.getTable("tableId");
+ * client.getTable("tableId");
* }
*
- *
+ *
* @param tableId
* @return Table
*/
@@ -336,14 +349,14 @@ public Table getTable(String tableId) {
/**
* Gets the Table by tableId
- *
+ *
* Sample code:
- *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.getTableAsync("tableId");
+ * client.getTableAsync("tableId");
* }
*
- *
+ *
* @param tableId
* @return ApiFuture
*/
@@ -353,15 +366,16 @@ public ApiFuture getTableAsync(String tableId) {
}
/**
- * Lists all TableNames in the instance.
- *
+ * Lists all TableNames in the instance.
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.listTables();
+ * client.listTables();
* }
*
- *
+ *
* @param tableId
* @return List
*/
@@ -372,14 +386,15 @@ public List listTables() {
/**
* Lists all TableNames in the instance asynchronously
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.listTablesAsync();
+ * client.listTablesAsync();
* }
*
- *
+ *
* @param tableId
* @return List
*/
@@ -387,21 +402,24 @@ public ApiFuture> listTablesAsync() {
ApiFuture listResp =
this.stub.listTablesCallable().futureCall(composeListTableRequest());
- return ApiFutures.transform(listResp, new ApiFunction>() {
- @Override
- public List apply(ListTablesResponse input) {
- return convertToTableNames(input);
- }
- });
+ return ApiFutures.transform(
+ listResp,
+ new ApiFunction>() {
+ @Override
+ public List apply(ListTablesResponse input) {
+ return convertToTableNames(input);
+ }
+ });
}
/**
* Drops rows by the specified key prefix and tableId
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropRowRange("tableId");
+ * client.dropRowRange("tableId");
* }
*
*
@@ -414,11 +432,12 @@ public void dropRowRange(String tableId, String rowKeyPrefix) {
/**
* Drops rows by the specified key prefix and tableId asynchronously
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropRowRangeAsync("tableId");
+ * client.dropRowRangeAsync("tableId");
* }
*
*
@@ -431,11 +450,12 @@ public ApiFuture dropRowRangeAsync(String tableId, String rowKeyPrefix) {
/**
* Drops rows by the specified key prefix and tableId
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropRowRange("tableId");
+ * client.dropRowRange("tableId");
* }
*
*
@@ -448,11 +468,12 @@ public void dropRowRange(String tableId, ByteString rowKeyPrefix) {
/**
* Drops rows by the specified key prefix and tableId
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropRowRangeAsync("tableId");
+ * client.dropRowRangeAsync("tableId");
* }
*
*
@@ -460,17 +481,20 @@ public void dropRowRange(String tableId, ByteString rowKeyPrefix) {
* @param rowKeyPrefix
*/
public ApiFuture dropRowRangeAsync(String tableId, ByteString rowKeyPrefix) {
- return transformToVoid(this.stub.dropRowRangeCallable().futureCall(
- composeDropRowRangeRequest(tableId, rowKeyPrefix, false)));
+ return transformToVoid(
+ this.stub
+ .dropRowRangeCallable()
+ .futureCall(composeDropRowRangeRequest(tableId, rowKeyPrefix, false)));
}
/**
* Drops all data in the table
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropAllData("tableId");
+ * client.dropAllData("tableId");
* }
*
*
@@ -482,61 +506,70 @@ public void dropAllData(String tableId) {
/**
* Drops all data in the table asynchronously
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.dropAllData("tableId");
+ * client.dropAllData("tableId");
* }
*
- *
+ *
* @param tableId
* @return ApiFuture
*/
public ApiFuture dropAllDataAsync(String tableId) {
- return transformToVoid(this.stub.dropRowRangeCallable()
- .futureCall(composeDropRowRangeRequest(tableId, null, true)));
+ return transformToVoid(
+ this.stub
+ .dropRowRangeCallable()
+ .futureCall(composeDropRowRangeRequest(tableId, null, true)));
}
/**
* Generates a token to verify the replication status of table mutations invoked before this call.
- * Token expires in 90 days
- *
+ * Token expires in 90 days
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.generateConsistencyToken("tableId");
+ * client.generateConsistencyToken("tableId");
* }
*
- *
+ *
* @param tableId
* @return ConsistencyToken
*/
public ConsistencyToken generateConsistencyToken(String tableId) {
- return TableAdminResponses.convertTokenResponse(this.stub.generateConsistencyTokenCallable()
- .call(composeGenerateConsistencyTokenRequest(tableId)));
+ return TableAdminResponses.convertTokenResponse(
+ this.stub
+ .generateConsistencyTokenCallable()
+ .call(composeGenerateConsistencyTokenRequest(tableId)));
}
/**
- * Generates a token to verify the replication status of table mutations invoked before this call asynchronously
- * Token expires in 90 days
- *
+ * Generates a token to verify the replication status of table mutations invoked before this call
+ * asynchronously Token expires in 90 days
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.generateConsistencyToken("tableId");
+ * client.generateConsistencyToken("tableId");
* }
*
- *
+ *
* @param tableId
* @return ApiFuture
*/
public ApiFuture generateConsistencyTokenAsync(String tableId) {
ApiFuture tokenResp =
- this.stub.generateConsistencyTokenCallable()
- .futureCall(composeGenerateConsistencyTokenRequest(tableId));
+ this.stub
+ .generateConsistencyTokenCallable()
+ .futureCall(composeGenerateConsistencyTokenRequest(tableId));
- return ApiFutures.transform(tokenResp,
+ return ApiFutures.transform(
+ tokenResp,
new ApiFunction() {
@Override
public ConsistencyToken apply(GenerateConsistencyTokenResponse input) {
@@ -547,33 +580,36 @@ public ConsistencyToken apply(GenerateConsistencyTokenResponse input) {
/**
* Checks replication consistency for the specified token consistency token
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.isConsistent("tableId", token);
+ * client.isConsistent("tableId", token);
* }
*
- *
+ *
* @param tableId
* @param token
* @return boolean
*/
public boolean isConsistent(String tableId, ConsistencyToken token) {
- return stub.checkConsistencyCallable().call(token.toProto(getTableName(tableId)))
- .getConsistent();
+ return stub.checkConsistencyCallable()
+ .call(token.toProto(getTableName(tableId)))
+ .getConsistent();
}
/**
* Checks replication consistency for the specified token consistency token asynchronously
- *
+ *
* Sample code:
- *
+ *
+ *
* try(TableAdminClient client = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- * client.isConsistentAsync("tableId", token);
+ * client.isConsistentAsync("tableId", token);
* }
*
- *
+ *
* @param tableId
* @param token
* @return ApiFuture
@@ -582,7 +618,8 @@ public ApiFuture isConsistentAsync(String tableId, ConsistencyToken tok
ApiFuture CheckConsResp =
stub.checkConsistencyCallable().futureCall(token.toProto(getTableName(tableId)));
- return ApiFutures.transform(CheckConsResp,
+ return ApiFutures.transform(
+ CheckConsResp,
new ApiFunction() {
@Override
public Boolean apply(CheckConsistencyResponse input) {
@@ -594,7 +631,7 @@ public Boolean apply(CheckConsistencyResponse input) {
/**
* Helper method to construct the table name in format:
* projects/{project}/instances/{instance}/tables/{tableId}
- *
+ *
* @param tableId
* @return String - unique table name
*/
@@ -605,7 +642,7 @@ String getTableName(String tableId) {
/**
* Helper method to build an instance of ListTablesRequest
- *
+ *
* @return ListTablesRequest
*/
@VisibleForTesting
@@ -615,7 +652,7 @@ ListTablesRequest composeListTableRequest() {
/**
* Helper method to build an instance of GetTableRequest
- *
+ *
* @param tableId
* @return GetTableRequest
*/
@@ -626,7 +663,7 @@ GetTableRequest composeGetTableRequest(String tableId) {
/**
* Helper method to build an instance of DeleteTableRequest
- *
+ *
* @param tableId
* @return DeleteTableRequest
*/
@@ -637,15 +674,15 @@ DeleteTableRequest composeDeleteTableRequest(String tableId) {
/**
* Helper method to build an instance of DropRowRangeRequest
- *
+ *
* @param tableId
* @param rowKeyPrefix
* @param boolean dropAll
* @return DropRowRangeRequest
*/
@VisibleForTesting
- DropRowRangeRequest composeDropRowRangeRequest(String tableId, ByteString rowKeyPrefix,
- boolean dropAll) {
+ DropRowRangeRequest composeDropRowRangeRequest(
+ String tableId, ByteString rowKeyPrefix, boolean dropAll) {
Builder dropRowReq = DropRowRangeRequest.newBuilder().setName(getTableName(tableId));
if (dropAll) {
@@ -658,7 +695,7 @@ DropRowRangeRequest composeDropRowRangeRequest(String tableId, ByteString rowKey
/**
* Helper method to build an instance of GenerateConsistencyTokenRequest
- *
+ *
* @param tableId
* @return GenerateConsistencyTokenRequest
*/
@@ -669,7 +706,7 @@ GenerateConsistencyTokenRequest composeGenerateConsistencyTokenRequest(String ta
/**
* Helper method to convert ListTablesResponse to List
- *
+ *
* @param listTablesResponse
* @return List
*/
@@ -685,14 +722,15 @@ static List convertToTableNames(ListTablesResponse listTablesResponse
/**
* Helper method to transform ApiFuture to ApiFuture
- *
+ *
* @param future
* @return ApiFuture
*/
@VisibleForTesting
static ApiFuture transformToTableResponse(
ApiFuture future) {
- return ApiFutures.transform(future,
+ return ApiFutures.transform(
+ future,
new ApiFunction() {
@Override
public Table apply(com.google.bigtable.admin.v2.Table table) {
@@ -703,17 +741,19 @@ public Table apply(com.google.bigtable.admin.v2.Table table) {
/**
* Helper method to transform ApiFuture to ApiFuture
- *
+ *
* @param future
* @return ApiFuture
*/
@VisibleForTesting
static ApiFuture transformToVoid(ApiFuture future) {
- return ApiFutures.transform(future, new ApiFunction() {
- @Override
- public Void apply(Empty empty) {
- return null;
- }
- });
+ return ApiFutures.transform(
+ future,
+ new ApiFunction() {
+ @Override
+ public Void apply(Empty empty) {
+ return null;
+ }
+ });
}
}
diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java
index d9158ee3f6b9..793d0868788f 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
@@ -25,9 +27,7 @@
import com.google.bigtable.admin.v2.GcRule.Union;
import com.google.common.base.MoreObjects;
-/**
- * Wraps {@link GcRule} protocol buffer object and exposes a simpler Fluent DSL model
- */
+/** Wraps {@link GcRule} protocol buffer object and exposes a simpler Fluent DSL model */
@BetaApi
public final class GCRules {
/** Factory method to create GCRules - entry point into the DSL. */
@@ -37,7 +37,7 @@ private GCRules() {}
/**
* Creates a new instance of the IntersectionRule
- *
+ *
* @return IntersectionRule
*/
public IntersectionRule intersection() {
@@ -46,7 +46,7 @@ public IntersectionRule intersection() {
/**
* Creates a new instance of the IntersectionRule
- *
+ *
* @return UnionRule
*/
public UnionRule union() {
@@ -55,7 +55,7 @@ public UnionRule union() {
/**
* Creates a new instance of the VersionRule
- *
+ *
* @param maxVersion - maximum number of cell versions to keep
* @return VersionRule
*/
@@ -65,7 +65,7 @@ public VersionRule maxVersions(int maxVersion) {
/**
* Creates a new instance of the DurationRule
- *
+ *
* @param maxAge - maximum age of the cell to keep
* @param timeUnit - timeunit for the age
* @return DurationRule
@@ -78,7 +78,7 @@ public DurationRule maxAge(long maxAge, TimeUnit timeUnit) {
/**
* Creates a new instance of the DurationRule
- *
+ *
* @param duration - age expressed as duration
* @return DurationRule
*/
@@ -88,7 +88,7 @@ public DurationRule maxAge(Duration duration) {
/**
* Creates an empty default rule
- *
+ *
* @return DefaultRule
*/
public DefaultRule defaulRule() {
@@ -96,20 +96,20 @@ public DefaultRule defaulRule() {
}
/**
- * Fluent wrapper for {@link Intersection} rule.
- * Allows far adding an hierarchy of rules with intersection as the root
+ * Fluent wrapper for {@link Intersection} rule. Allows far adding an hierarchy of rules with
+ * intersection as the root
*/
public static final class IntersectionRule extends BaseRule {
private GcRule.Intersection.Builder builder;
private List rulesList = new ArrayList<>();
-
+
private IntersectionRule() {
this.builder = GcRule.Intersection.newBuilder();
}
/**
* Adds a new GCRule
- *
+ *
* @param rule
* @return IntersectionRule
*/
@@ -121,20 +121,18 @@ public IntersectionRule rule(@Nonnull GCRule rule) {
/**
* Gets the list of child rules
- *
+ *
* @return List
*/
public List getRulesList() {
return rulesList;
}
-
+
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("rulesList", rulesList)
- .toString();
+ return MoreObjects.toStringHelper(this).add("rulesList", rulesList).toString();
}
-
+
@InternalApi
@Override
public GcRule toProto() {
@@ -150,20 +148,20 @@ public GcRule toProto() {
}
/**
- * Fluent wrapper for {@link Union} rule.
- * Allows far adding an hierarchy of rules with union as the root
+ * Fluent wrapper for {@link Union} rule. Allows far adding an hierarchy of rules with union as
+ * the root
*/
public static final class UnionRule extends BaseRule {
private GcRule.Union.Builder builder;
private List rulesList = new ArrayList<>();
-
+
private UnionRule() {
this.builder = GcRule.Union.newBuilder();
}
/**
* Adds a new GCRule
- *
+ *
* @param rule
* @return UnionRule
*/
@@ -175,18 +173,16 @@ public UnionRule rule(@Nonnull GCRule rule) {
/**
* Gets the list of child rules
- *
+ *
* @return List
*/
public List getRulesList() {
return rulesList;
}
-
+
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("rulesList", rulesList)
- .toString();
+ return MoreObjects.toStringHelper(this).add("rulesList", rulesList).toString();
}
@InternalApi
@@ -203,9 +199,7 @@ public GcRule toProto() {
}
}
- /**
- * Wrapper for building max versions rule
- */
+ /** Wrapper for building max versions rule */
public static final class VersionRule extends BaseRule {
private GcRule.Builder builder;
@@ -214,18 +208,14 @@ private VersionRule(int maxVersion) {
builder.setMaxNumVersions(maxVersion);
}
- /**
- * Gets the configured maximum versions
- */
+ /** Gets the configured maximum versions */
public int getMaxVersions() {
return toProto().getMaxNumVersions();
}
-
+
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("maxNumVersions", getMaxVersions())
- .toString();
+ return MoreObjects.toStringHelper(this).add("maxNumVersions", getMaxVersions()).toString();
}
@InternalApi
@@ -235,9 +225,7 @@ public GcRule toProto() {
}
}
- /**
- * Wrapper for building max duration rule
- */
+ /** Wrapper for building max duration rule */
public static final class DurationRule extends BaseRule {
private com.google.protobuf.Duration.Builder builder;
@@ -247,23 +235,21 @@ private DurationRule(Duration duration) {
.setSeconds(duration.getSeconds())
.setNanos(duration.getNano());
}
-
+
/**
* Gets the configured maximum age
- *
+ *
* @return Duration
*/
public Duration getMaxAge() {
long seconds = toProto().getMaxAge().getSeconds();
int nanos = toProto().getMaxAge().getNanos();
- return Duration.ofSeconds(seconds, nanos);
+ return Duration.ofSeconds(seconds, nanos);
}
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("maxAge", getMaxAge())
- .toString();
+ return MoreObjects.toStringHelper(this).add("maxAge", getMaxAge()).toString();
}
@InternalApi
@@ -273,10 +259,7 @@ public GcRule toProto() {
}
}
- /**
- * Wrapper for building a empty rule
- *
- */
+ /** Wrapper for building a empty rule */
public static final class DefaultRule extends BaseRule {
private DefaultRule() {}
@@ -285,63 +268,47 @@ private DefaultRule() {}
public GcRule toProto() {
return GcRule.getDefaultInstance();
}
-
+
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .toString();
+ return MoreObjects.toStringHelper(this).toString();
}
}
- /**
- * Helpers to support casting rules the Type, when the Type is known
- */
- public static abstract class BaseRule implements GCRule {
-
- /**
- * Casts the rule to DurationRule.
- * On failure throws a ClassCastException
- */
+ /** Helpers to support casting rules the Type, when the Type is known */
+ public abstract static class BaseRule implements GCRule {
+
+ /** Casts the rule to DurationRule. On failure throws a ClassCastException */
public DurationRule getDurationOrThow() {
return (DurationRule) this;
}
- /**
- * Casts the rule to VersionRule.
- * On failure throws a ClassCastException
- */
+ /** Casts the rule to VersionRule. On failure throws a ClassCastException */
public VersionRule getVersionOrThow() {
return (VersionRule) this;
}
- /**
- * Casts the rule to UnionRule.
- * On failure throws a ClassCastException
- */
+ /** Casts the rule to UnionRule. On failure throws a ClassCastException */
public UnionRule getUnionOrThow() {
return (UnionRule) this;
}
- /**
- * Casts the rule to IntersectionRule.
- * On failure throws a ClassCastException
- */
+ /** Casts the rule to IntersectionRule. On failure throws a ClassCastException */
public IntersectionRule getIntersectionOrThow() {
return (IntersectionRule) this;
}
}
-
- /**
- *
- * interface for fluent GcRule wrappers
- *
- */
+
+ /** interface for fluent GcRule wrappers */
public interface GCRule {
DurationRule getDurationOrThow();
+
VersionRule getVersionOrThow();
+
UnionRule getUnionOrThow();
+
IntersectionRule getIntersectionOrThow();
-
+
@InternalApi
GcRule toProto();
}
diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequests.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequests.java
index 7515ed361386..9ee75cae30d4 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequests.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequests.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
@@ -29,18 +31,14 @@
import com.google.common.base.Preconditions;
import com.google.protobuf.ByteString;
-/**
- *
- * Fluent DSL models to build Bigtable Table admin requests
- *
- */
+/** Fluent DSL models to build Bigtable Table admin requests */
@BetaApi
public final class TableAdminRequests {
private TableAdminRequests() {}
/**
* Factory method to get an instance of CreateTable
- *
+ *
* @param tableId - the id of the table to create
* @return CreateTable
*/
@@ -50,7 +48,7 @@ public static CreateTable createTable(String tableId) {
/**
* Factory method to get an instance of ModifyFamilies
- *
+ *
* @param tableId - the id of the table to create
* @return ModifyFamilies
*/
@@ -60,13 +58,13 @@ public static ModifyFamilies modifyFamilies(String tableId) {
/**
* Fluent wrapper for {@link CreateTableRequest}
- *
- *
- * Allows for creating table with
- * - optional columnFamilies, including optional {@link GCRule}
+ *
+ *
+ * Allows for creating table with
+ * - optional columnFamilies, including optional {@link GCRule}
* - optional granularity
* - and optional split points
- *
+ *
*/
public static final class CreateTable {
private final CreateTableRequest.Builder createTableRequest = CreateTableRequest.newBuilder();
@@ -74,7 +72,7 @@ public static final class CreateTable {
/**
* Configures table with the specified id
- *
+ *
* @param tableId
*/
private CreateTable(String tableId) {
@@ -83,7 +81,7 @@ private CreateTable(String tableId) {
/**
* Configures table with the specified granularity
- *
+ *
* @param granularity
*/
public CreateTable withGranularity(TimestampGranularity granularity) {
@@ -94,7 +92,7 @@ public CreateTable withGranularity(TimestampGranularity granularity) {
/**
* Adds a new columnFamily to the configuration
- *
+ *
* @param familyId
*/
public CreateTable addColumnFamily(String familyId) {
@@ -105,7 +103,7 @@ public CreateTable addColumnFamily(String familyId) {
/**
* Adds a new columnFamily with {@link GCRule} to the configuration
- *
+ *
* @param familyId
* @param gcRule
*/
@@ -118,7 +116,7 @@ public CreateTable addColumnFamily(String familyId, GCRule gcRule) {
/**
* Adds split at the specified key to the configuration
- *
+ *
* @param key
*/
public CreateTable addSplit(ByteString key) {
@@ -129,7 +127,7 @@ public CreateTable addSplit(ByteString key) {
/**
* Adds the specified number of uniform splits to the configuration
- *
+ *
* @param key
* @param numSplits
*/
@@ -151,13 +149,13 @@ public CreateTableRequest toProto(InstanceName instanceName) {
/**
* Fluent wrapper for {@link ModifyColumnFamiliesRequest}
- *
- *
- * Allows the following ColumnFamily modifications
- * - create family, optionally with {@link GCRule}
+ *
+ *
+ * Allows the following ColumnFamily modifications
+ * - create family, optionally with {@link GCRule}
* - update existing family {@link GCRule}
* - drop an existing family
- *
+ *
*/
public static final class ModifyFamilies {
private final ModifyColumnFamiliesRequest.Builder modFamilyRequest =
@@ -166,7 +164,7 @@ public static final class ModifyFamilies {
/**
* Configures the tableId to execute the modifications
- *
+ *
* @param tableId
*/
private ModifyFamilies(String tableId) {
@@ -176,6 +174,7 @@ private ModifyFamilies(String tableId) {
/**
* Configures the name of the new ColumnFamily to be created
+ *
* @param familyId
* @return
*/
@@ -185,7 +184,7 @@ public ModifyFamilies create(String familyId) {
/**
* Configures the name and GcRule of the new ColumnFamily to be created
- *
+ *
* @param familyId
* @param gcRule
* @return
@@ -200,7 +199,7 @@ public ModifyFamilies createWithGCRule(String familyId, GCRule gcRule) {
/**
* Updates the GCRule of existing ColumnFamily
- *
+ *
* @param familyId
* @param gcRule
* @return
@@ -215,7 +214,7 @@ public ModifyFamilies updateWithGCRule(String familyId, GCRule gcRule) {
/**
* Drops the specified ColumnFamily
- *
+ *
* @param familyId
* @return
*/
@@ -229,7 +228,8 @@ public ModifyFamilies drop(String familyId) {
@InternalApi
public ModifyColumnFamiliesRequest toProto(InstanceName instanceName) {
Preconditions.checkNotNull(instanceName);
- String tableName = TableName.of(instanceName.getProject(), instanceName.getInstance(), tableId).toString();
+ String tableName =
+ TableName.of(instanceName.getProject(), instanceName.getInstance(), tableId).toString();
return modFamilyRequest.setName(tableName).build();
}
}
diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java
index dcfeb3127ca0..c2305dfa7007 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
@@ -36,18 +38,14 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
-/**
- *
- * Bigtable Table admin response wrappers
- *
- */
+/** Bigtable Table admin response wrappers */
@BetaApi
public class TableAdminResponses {
private TableAdminResponses() {}
/**
* Converts the protocol buffer table to a simpler Table model with only the required elements
- *
+ *
* @param com.google.bigtable.admin.v2.Table - Protobuf table
* @return Table - Table response wrapper
*/
@@ -57,20 +55,18 @@ public static Table convertTable(com.google.bigtable.admin.v2.Table table) {
}
/**
- * Converts the protocol buffer response to a simpler ConsistencyToken which can be passed back as is.
- *
+ * Converts the protocol buffer response to a simpler ConsistencyToken which can be passed back as
+ * is.
+ *
* @param GenerateConsistencyTokenResponse - Protobuf ConsistencyTokenResponse
- * @return ConsistencyToken - ConsistencyToken response wrapper
+ * @return ConsistencyToken - ConsistencyToken response wrapper
*/
public static ConsistencyToken convertTokenResponse(
GenerateConsistencyTokenResponse tokenResponse) {
return new ConsistencyToken(tokenResponse);
}
- /**
- * Wrapper for {@link Table} protocol buffer object
- *
- */
+ /** Wrapper for {@link Table} protocol buffer object */
public static final class Table {
private TableName tableName;
private TimestampGranularity timestampGranularity;
@@ -82,24 +78,26 @@ private Table(com.google.bigtable.admin.v2.Table table) {
this.tableName = TableName.parse(table.getName());
this.timestampGranularity = table.getGranularity();
- Map clusterStatesMap = table.getClusterStatesMap();
- for (Entry entry : clusterStatesMap.entrySet()) {
- clusterStates.put(
- entry.getKey(), new ClusterState(entry.getKey(), entry.getValue()));
+ Map clusterStatesMap =
+ table.getClusterStatesMap();
+ for (Entry entry :
+ clusterStatesMap.entrySet()) {
+ clusterStates.put(entry.getKey(), new ClusterState(entry.getKey(), entry.getValue()));
}
- Map columnFamiliesMap = table.getColumnFamiliesMap();
- for (Entry entry : columnFamiliesMap.entrySet()) {
- columnFamilies.put(
- entry.getKey(), new ColumnFamily(entry.getKey(), entry.getValue()));
+ Map columnFamiliesMap =
+ table.getColumnFamiliesMap();
+ for (Entry entry :
+ columnFamiliesMap.entrySet()) {
+ columnFamilies.put(entry.getKey(), new ColumnFamily(entry.getKey(), entry.getValue()));
}
}
/**
* Gets the unique name of the table in the format:
* projects/{project}/instances/{instance}/tables/{tableId}
- *
- * @return TableName
+ *
+ * @return TableName
*/
public TableName getTableName() {
return tableName;
@@ -107,7 +105,7 @@ public TableName getTableName() {
/**
* Gets the timestampGranularity of the table
- *
+ *
* @return TimestampGranularity
*/
public TimestampGranularity getTimestampGranularity() {
@@ -115,8 +113,9 @@ public TimestampGranularity getTimestampGranularity() {
}
/**
- * Returns state of the table by clusters in the instance as map of clusterId and {@link ClusterState}
- *
+ * Returns state of the table by clusters in the instance as map of clusterId and {@link
+ * ClusterState}
+ *
* @return Map
*/
public Map getClusterStatesMap() {
@@ -125,7 +124,7 @@ public Map getClusterStatesMap() {
/**
* Returns a map of columfamilies in the table keyed by columnfamily and name
- *
+ *
* @return Map
*/
public Map getColumnFamiliesMap() {
@@ -134,7 +133,7 @@ public Map getColumnFamiliesMap() {
/**
* Returns state of the table by clusters in the instance as a Collection
- *
+ *
* @return Collection
*/
public Collection getClusterStates() {
@@ -143,7 +142,7 @@ public Collection getClusterStates() {
/**
* Returns all columnfamilies in the table as a Collection
- *
+ *
* @return
*/
public Collection getColumnFamiles() {
@@ -161,9 +160,7 @@ public String toString() {
}
}
- /**
- * Wrapper for {@link ClusterState} protocol buffer object
- */
+ /** Wrapper for {@link ClusterState} protocol buffer object */
public static final class ClusterState {
private String id;
private ReplicationState replicationState;
@@ -175,7 +172,7 @@ private ClusterState(String id, com.google.bigtable.admin.v2.Table.ClusterState
/**
* Gets the cluster Id
- *
+ *
* @return String
*/
public String getId() {
@@ -184,7 +181,7 @@ public String getId() {
/**
* Gets the ReplicationState of the table for this cluster
- *
+ *
* @return ReplicationState
*/
public ReplicationState getReplicationState() {
@@ -217,6 +214,7 @@ private ColumnFamily(String id, com.google.bigtable.admin.v2.ColumnFamily cf) {
/**
* Gets the columnfamily name
+ *
* @return String
*/
public String getId() {
@@ -225,7 +223,7 @@ public String getId() {
/**
* Get's the GCRule configured for the columnfamily
- *
+ *
* @return GCRule
*/
public GCRule getGCRule() {
@@ -234,6 +232,7 @@ public GCRule getGCRule() {
/**
* Returns true if a GCRule has been configured for the family
+ *
* @return
*/
public boolean hasGcRule() {
@@ -242,10 +241,7 @@ public boolean hasGcRule() {
@Override
public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("id", id)
- .add("gCRule", gCRule)
- .toString();
+ return MoreObjects.toStringHelper(this).add("id", id).add("gCRule", gCRule).toString();
}
private GCRule convertGcRule(GcRule source) {
@@ -277,9 +273,11 @@ private GCRule convertGcRule(GcRule source) {
}
}
- /**
+ /**
* Wrapper for {@link GenerateConsistencyTokenResponse#getConsistencyToken()}
- * Cannot be created, they are obtained by invoking {@link TableAdminClient#generateConsistencyToken(String)}
+ *
+ * Cannot be created.
+ * They are obtained by invoking {@link TableAdminClient#generateConsistencyToken(String)}
*/
public static final class ConsistencyToken {
private String token;
@@ -290,10 +288,12 @@ private ConsistencyToken(GenerateConsistencyTokenResponse resp) {
@InternalApi
public CheckConsistencyRequest toProto(String tableName) {
- return CheckConsistencyRequest.newBuilder().setName(tableName).setConsistencyToken(token)
- .build();
+ return CheckConsistencyRequest.newBuilder()
+ .setName(tableName)
+ .setConsistencyToken(token)
+ .build();
}
-
+
@VisibleForTesting
String getToken() {
return token;
diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java
index 259a15a8a69a..9b73d0aa6af4 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.google.cloud.bigtable.admin.v2;
import static com.google.common.truth.Truth.assertThat;
@@ -234,17 +249,15 @@ public void generateAndCheckConsistency() {
ConsistencyToken consistencyToken = adminClient.generateConsistencyToken("tableId");
Mockito.verify(mockGenerateConsistencyTokenCallable)
.call(adminClient.composeGenerateConsistencyTokenRequest("tableId"));
-
- ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(CheckConsistencyRequest.class);
+
+ ArgumentCaptor requestCaptor =
+ ArgumentCaptor.forClass(CheckConsistencyRequest.class);
CheckConsistencyResponse consistencyResp = CheckConsistencyResponse.newBuilder().build();
- Mockito.when(
- mockCheckConsistencyCallable.call(
- any(CheckConsistencyRequest.class)))
+ Mockito.when(mockCheckConsistencyCallable.call(any(CheckConsistencyRequest.class)))
.thenReturn(consistencyResp);
adminClient.isConsistent("tableId", consistencyToken);
- Mockito.verify(mockCheckConsistencyCallable)
- .call(requestCaptor.capture());
+ Mockito.verify(mockCheckConsistencyCallable).call(requestCaptor.capture());
}
@Test
@@ -256,21 +269,20 @@ public void generateAndCheckConsistencyAsync() throws Exception {
adminClient.composeGenerateConsistencyTokenRequest("tableId")))
.thenReturn(genResp);
- ApiFuture consistencyTokenFuture = adminClient.generateConsistencyTokenAsync("tableId");
+ ApiFuture consistencyTokenFuture =
+ adminClient.generateConsistencyTokenAsync("tableId");
Mockito.verify(mockGenerateConsistencyTokenCallable)
.futureCall(adminClient.composeGenerateConsistencyTokenRequest("tableId"));
-
- ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(CheckConsistencyRequest.class);
+
+ ArgumentCaptor requestCaptor =
+ ArgumentCaptor.forClass(CheckConsistencyRequest.class);
ApiFuture consistencyResp =
ApiFutures.immediateFuture(CheckConsistencyResponse.newBuilder().build());
- Mockito.when(
- mockCheckConsistencyCallable.futureCall(
- any(CheckConsistencyRequest.class)))
+ Mockito.when(mockCheckConsistencyCallable.futureCall(any(CheckConsistencyRequest.class)))
.thenReturn(consistencyResp);
adminClient.isConsistentAsync("tableId", consistencyTokenFuture.get());
- Mockito.verify(mockCheckConsistencyCallable)
- .futureCall(requestCaptor.capture());
+ Mockito.verify(mockCheckConsistencyCallable).futureCall(requestCaptor.capture());
}
@Test
diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java
index 5635bc4af11a..d5f539b2ab4e 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java
@@ -69,7 +69,13 @@ public void createTable() throws Exception {
assertFalse(tableResponse.getColumnFamiliesMap().get("cf1").hasGcRule());
assertTrue(tableResponse.getColumnFamiliesMap().get("cf2").hasGcRule());
assertEquals(
- 10, tableResponse.getColumnFamiliesMap().get("cf2").getGCRule().getVersionOrThow().getMaxVersions());
+ 10,
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("cf2")
+ .getGCRule()
+ .getVersionOrThow()
+ .getMaxVersions());
assertEquals(TimestampGranularity.MILLIS, tableResponse.getTimestampGranularity());
// TODO: is there a way to test splits here?
} finally {
@@ -84,8 +90,7 @@ public void modifyFamilies() {
Duration.ofSeconds(1000);
modifyFamiliesReq
.create("mf1")
- .createWithGCRule(
- "mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
+ .createWithGCRule("mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
.updateWithGCRule(
"mf1",
GCRULES
@@ -112,15 +117,51 @@ public void modifyFamilies() {
assertEquals(5, tableResponse.getColumnFamiles().size());
assertNotNull(tableResponse.getColumnFamiliesMap().get("mf1"));
assertNotNull(tableResponse.getColumnFamiliesMap().get("mf2"));
- assertEquals(2, tableResponse.getColumnFamiliesMap().get("mf1").getGCRule().getUnionOrThow().getRulesList().size());
+ assertEquals(
+ 2,
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("mf1")
+ .getGCRule()
+ .getUnionOrThow()
+ .getRulesList()
+ .size());
assertEquals(
1000,
- tableResponse.getColumnFamiliesMap().get("mf2").getGCRule().getDurationOrThow().getMaxAge().getSeconds());
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("mf2")
+ .getGCRule()
+ .getDurationOrThow()
+ .getMaxAge()
+ .getSeconds());
assertEquals(
20000,
- tableResponse.getColumnFamiliesMap().get("mf2").getGCRule().getDurationOrThow().getMaxAge().getNano());
- assertEquals(2, tableResponse.getColumnFamiliesMap().get("mf3").getGCRule().getIntersectionOrThow().getRulesList().size());
- assertEquals(360, tableResponse.getColumnFamiliesMap().get("mf4").getGCRule().getDurationOrThow().getMaxAge().getSeconds());
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("mf2")
+ .getGCRule()
+ .getDurationOrThow()
+ .getMaxAge()
+ .getNano());
+ assertEquals(
+ 2,
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("mf3")
+ .getGCRule()
+ .getIntersectionOrThow()
+ .getRulesList()
+ .size());
+ assertEquals(
+ 360,
+ tableResponse
+ .getColumnFamiliesMap()
+ .get("mf4")
+ .getGCRule()
+ .getDurationOrThow()
+ .getMaxAge()
+ .getSeconds());
assertNotNull(tableResponse.getColumnFamiliesMap().get("mf7"));
} finally {
tableAdmin.deleteTable(tableId);
diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java
index 9c800efe2028..e3dee2577159 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequestsTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequestsTest.java
index 6bce75f0ea6e..0b5aa9562b6a 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequestsTest.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminRequestsTest.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
@@ -31,13 +33,13 @@
@RunWith(JUnit4.class)
public class TableAdminRequestsTest {
- private final InstanceName instanceName = InstanceName.of("project", "instance");
+ private final InstanceName instanceName = InstanceName.of("project", "instance");
@Test
public void createTable() {
CreateTableRequest actual =
TableAdminRequests.createTable("tableId")
- .withGranularity(TimestampGranularity.MILLIS)
+ .withGranularity(TimestampGranularity.MILLIS)
.addColumnFamily("cf1")
.addColumnFamily("cf2", GCRules.GCRULES.maxVersions(1))
.addSplit(ByteString.copyFromUtf8("c"))
@@ -48,7 +50,7 @@ public void createTable() {
.setTableId("tableId")
.setParent(InstanceName.of("project", "instance").toString())
.addInitialSplits(Split.newBuilder().setKey(ByteString.copyFromUtf8("c")))
- .setTable(
+ .setTable(
Table.newBuilder()
.setGranularity(TimestampGranularity.MILLIS)
.putColumnFamilies("cf1", ColumnFamily.newBuilder().build())
@@ -80,14 +82,18 @@ public void modifyFamilies() {
.createWithGCRule("cf2", GCRules.GCRULES.maxVersions(1))
.create("cf3")
.updateWithGCRule("cf1", GCRules.GCRULES.maxVersions(5))
- .drop("cf3")
+ .drop("cf3")
.toProto(instanceName);
ModifyColumnFamiliesRequest expected =
ModifyColumnFamiliesRequest.newBuilder()
- .setName(TableName.of(instanceName.getProject(), instanceName.getInstance(), "tableId").toString())
+ .setName(
+ TableName.of(instanceName.getProject(), instanceName.getInstance(), "tableId")
+ .toString())
.addModifications(
- Modification.newBuilder().setId("cf1").setCreate(ColumnFamily.newBuilder().setGcRule(GcRule.getDefaultInstance())))
+ Modification.newBuilder()
+ .setId("cf1")
+ .setCreate(ColumnFamily.newBuilder().setGcRule(GcRule.getDefaultInstance())))
.addModifications(
Modification.newBuilder()
.setId("cf2")
@@ -95,14 +101,16 @@ public void modifyFamilies() {
ColumnFamily.newBuilder()
.setGcRule(GCRules.GCRULES.maxVersions(1).toProto())))
.addModifications(
- Modification.newBuilder().setId("cf3").setCreate(ColumnFamily.newBuilder().setGcRule(GcRule.getDefaultInstance())))
+ Modification.newBuilder()
+ .setId("cf3")
+ .setCreate(ColumnFamily.newBuilder().setGcRule(GcRule.getDefaultInstance())))
.addModifications(
Modification.newBuilder()
.setId("cf1")
.setUpdate(
ColumnFamily.newBuilder()
.setGcRule(GCRules.GCRULES.maxVersions(5).toProto())))
- .addModifications(Modification.newBuilder().setId("cf3").setDrop(true))
+ .addModifications(Modification.newBuilder().setId("cf3").setDrop(true))
.build();
assertThat(actual).isEqualTo(expected);
}
diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponsesTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponsesTest.java
index 0e1a2fb52cd4..76985f3a735e 100644
--- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponsesTest.java
+++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponsesTest.java
@@ -1,15 +1,17 @@
/*
* Copyright 2018 Google LLC
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.google.cloud.bigtable.admin.v2.models;
@@ -134,21 +136,51 @@ public void convertTable_unionOfIntersections() {
.build();
Table tableResponse = TableAdminResponses.convertTable(table);
- assertThat(actual).isEqualTo(tableResponse.getColumnFamiliesMap().get("cf3").getGCRule().toProto());
+ assertThat(actual)
+ .isEqualTo(tableResponse.getColumnFamiliesMap().get("cf3").getGCRule().toProto());
assertTrue(tableResponse.getColumnFamiliesMap().get("cf3").hasGcRule());
-
+
GCRule parentUnion = tableResponse.getColumnFamiliesMap().get("cf3").getGCRule();
assertEquals(2, parentUnion.getUnionOrThow().getRulesList().size());
- IntersectionRule intersectionRule = parentUnion.getUnionOrThow().getRulesList().get(0).getIntersectionOrThow();
+ IntersectionRule intersectionRule =
+ parentUnion.getUnionOrThow().getRulesList().get(0).getIntersectionOrThow();
assertEquals(2, intersectionRule.getIntersectionOrThow().getRulesList().size());
- assertEquals(1, intersectionRule.getIntersectionOrThow().getRulesList().get(0).getVersionOrThow().getMaxVersions());
- assertEquals(Duration.ofSeconds(1, 0), intersectionRule.getIntersectionOrThow().getRulesList().get(1).getDurationOrThow().getMaxAge());
-
+ assertEquals(
+ 1,
+ intersectionRule
+ .getIntersectionOrThow()
+ .getRulesList()
+ .get(0)
+ .getVersionOrThow()
+ .getMaxVersions());
+ assertEquals(
+ Duration.ofSeconds(1, 0),
+ intersectionRule
+ .getIntersectionOrThow()
+ .getRulesList()
+ .get(1)
+ .getDurationOrThow()
+ .getMaxAge());
+
intersectionRule = parentUnion.getUnionOrThow().getRulesList().get(1).getIntersectionOrThow();
assertEquals(2, intersectionRule.getIntersectionOrThow().getRulesList().size());
- assertEquals(1, intersectionRule.getIntersectionOrThow().getRulesList().get(0).getVersionOrThow().getMaxVersions());
- assertEquals(Duration.ofSeconds(1, 0), intersectionRule.getIntersectionOrThow().getRulesList().get(1).getDurationOrThow().getMaxAge());
+ assertEquals(
+ 1,
+ intersectionRule
+ .getIntersectionOrThow()
+ .getRulesList()
+ .get(0)
+ .getVersionOrThow()
+ .getMaxVersions());
+ assertEquals(
+ Duration.ofSeconds(1, 0),
+ intersectionRule
+ .getIntersectionOrThow()
+ .getRulesList()
+ .get(1)
+ .getDurationOrThow()
+ .getMaxAge());
}
@Test
@@ -192,12 +224,14 @@ public void convertTable_intersectionOfUnions() {
.build();
Table tableResponse = TableAdminResponses.convertTable(table);
- assertThat(actual).isEqualTo(tableResponse.getColumnFamiliesMap().get("cf3").getGCRule().toProto());
+ assertThat(actual)
+ .isEqualTo(tableResponse.getColumnFamiliesMap().get("cf3").getGCRule().toProto());
}
@Test
public void convertTable_Empty() {
- Table tableResponse = TableAdminResponses.convertTable(com.google.bigtable.admin.v2.Table.newBuilder().build());
+ Table tableResponse =
+ TableAdminResponses.convertTable(com.google.bigtable.admin.v2.Table.newBuilder().build());
assertNotNull(tableResponse);
assertEquals(