Skip to content

Commit 89433fc

Browse files
igorbernstein2garrettjonesgoogle
authored andcommitted
Bigtable: Move admin api into its own artifact. (#3494)
The target usecases are different enough that the clients should be split. Also, it avoids confusion associated with duplicate static names.
1 parent 59bf71e commit 89433fc

40 files changed

+321
-24
lines changed

.circleci/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ jobs:
9292
name: Run integration tests for google-cloud-bigtable
9393
command: ./utilities/verify_single_it.sh google-cloud-clients/google-cloud-bigtable -Dbigtable.env=prod -Dbigtable.table=projects/gcloud-devel/instances/google-cloud-bigtable/tables/integration-tests
9494

95+
bigtableadmin_it:
96+
working_directory: ~/googleapis
97+
<<: *anchor_docker
98+
<<: *anchor_auth_vars
99+
steps:
100+
- checkout
101+
- run:
102+
<<: *anchor_run_decrypt
103+
- run:
104+
name: Run integration tests for google-cloud-bigtable-admin
105+
command: ./utilities/verify_single_it.sh google-cloud-clients/google-cloud-bigtable-admin -Dbigtable.instance=projects/gcloud-devel/instances/google-cloud-bigtable
106+
95107
compute_it:
96108
working_directory: ~/googleapis
97109
<<: *anchor_docker

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ This library supports the following Google Cloud Platform services with clients
4242
This library supports the following Google Cloud Platform services with clients at an [Alpha](#versioning) quality level:
4343

4444
- [Cloud Bigtable](google-cloud-clients/google-cloud-bigtable) (Alpha)
45+
- [Cloud Bigtable Admin](google-cloud-clients/google-cloud-bigtable-admin) (Alpha)
4546
- [Cloud Compute](google-cloud-clients/google-cloud-compute) (Alpha)
4647
- [Cloud Dataproc](google-cloud-clients/google-cloud-dataproc) (Alpha)
4748
- [Cloud DNS](google-cloud-clients/google-cloud-dns) (Alpha)

TESTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ To use the `prod` environment:
6464
-Dbigtable.table=projects/my-project/instances/my-instance/tables/my-table
6565
```
6666

67+
### Testing code that uses Bigtable Admin
68+
69+
Bigtable Admin integration tests are run against a real Bigtable instance.
70+
71+
To run the tests:
72+
1. Set up the target table using `google-cloud-bigtable/scripts/setup-test-table.sh`
73+
2. Download the [JSON service account credentials file][create-service-account] from the Google
74+
Developer's Console.
75+
3. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the path of the credentials file
76+
4. Set the system property `bigtable.instance` to the full instance name you
77+
created earlier. Example:
78+
```shell
79+
mvn verify -am -pl google-cloud-bigtable-admin \
80+
-Dbigtable.instance=projects/my-project/instances/my-instance
81+
```
6782
6883
### Testing code that uses Compute
6984

google-cloud-bom/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@
256256
<artifactId>grpc-google-cloud-bigtable-v2</artifactId>
257257
<version>0.20.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-bigtable-v2:current} -->
258258
</dependency>
259+
<dependency>
260+
<groupId>com.google.cloud</groupId>
261+
<artifactId>google-cloud-bigtable-admin</artifactId>
262+
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
263+
</dependency>
264+
<dependency>
265+
<groupId>com.google.cloud</groupId>
266+
<artifactId>google-cloud-bigtable-admin</artifactId>
267+
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
268+
<type>test-jar</type>
269+
</dependency>
259270
<dependency>
260271
<groupId>com.google.api.grpc</groupId>
261272
<artifactId>proto-google-cloud-bigtable-admin-v2</artifactId>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Google Cloud Java Client for Bigtable Admin
2+
3+
Java idiomatic client for [Cloud Bigtable Admin][cloud-bigtable]. Please note that this client is under
4+
heavy development and is not ready for production use. Please continue to use the
5+
[HBase API client](https://github.com/GoogleCloudPlatform/cloud-bigtable-client) for production.
6+
7+
[[![CircleCI](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-java/tree/master.svg?style=shield)](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-java/tree/master)
8+
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/google-cloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/google-cloud-java?branch=master)
9+
[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable-admin.svg)
10+
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
11+
[![Dependency Status](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772/badge.svg?style=flat)](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772)
12+
13+
- [Product Documentation][bigtable-product-docs]
14+
- [Client Library Documentation][bigtable-admin-client-lib-docs]
15+
16+
> Note: This client is under heavy development and should not be used in production.
17+
18+
## Quickstart
19+
20+
[//]: # ({x-version-update-start:google-cloud-bigtable-admin:released})
21+
If you are using Maven, add this to your pom.xml file
22+
```xml
23+
<dependency>
24+
<groupId>com.google.cloud</groupId>
25+
<artifactId>google-cloud-bigtable-admin</artifactId>
26+
<version>0.55.1-alpha</version>
27+
</dependency>
28+
```
29+
If you are using Gradle, add this to your dependencies
30+
```Groovy
31+
compile 'com.google.cloud:google-cloud-bigtable-admin:0.55.1-alpha'
32+
```
33+
If you are using SBT, add this to your dependencies
34+
```Scala
35+
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable-admin" % "0.55.1-alpha"
36+
```
37+
[//]: # ({x-version-update-end})
38+
39+
## Authentication
40+
41+
See the
42+
[Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication)
43+
section in the base directory's README.
44+
45+
## About Cloud Bigtable Admin
46+
47+
[Cloud Bigtable][cloud-bigtable] is Google's NoSQL Big Data database service. It's
48+
the same database that powers many core Google services, including Search, Analytics, Maps, and
49+
Gmail. The API is split into the data api and the admin api. This client targets the admin api.
50+
51+
Be sure to activate the Cloud Bigtable Admin API on the Developer's Console to use Cloud Bigtable
52+
from your project.
53+
54+
See the [Bigtable Amin client lib docs][bigtable-admin-client-lib-docs] to learn how to
55+
interact with Cloud Bigtable Admin API using this Client Library.
56+
57+
## Getting Started
58+
#### Prerequisites
59+
For this tutorial, you will need a
60+
[Google Developers Console](https://console.developers.google.com/) project with the Cloud Bigtable
61+
API enabled. You will need to
62+
[enable billing](https://support.google.com/cloud/answer/6158867?hl=en) to use Google Cloud Bigtable.
63+
[Follow these instructions](https://cloud.google.com/docs/authentication#preparation) to get your
64+
project set up. You will also need to set up the local development environment by [installing the
65+
Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line:
66+
`gcloud auth login`.
67+
68+
#### Calling Cloud Bigtable
69+
70+
The Cloud Bigtable API is split into 2 parts: Data API, Instance Admin API and Table Admin API.
71+
72+
Here is a code snippet showing simple usage of the Table API. Add the following imports
73+
at the top of your file:
74+
75+
76+
```java
77+
import com.google.bigtable.admin.v2.ColumnFamily;
78+
import com.google.bigtable.admin.v2.InstanceName;
79+
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
80+
```
81+
82+
Then, to create a table, use the following code:
83+
```java
84+
InstanceName instanceName = InstanceName.of("my-project", "my-instance");
85+
86+
TableAdminClient tableAdminClient = TableAdminClient.create(instanceName);
87+
88+
try {
89+
CreateTable createTableReq = TableAdminRequests.createTable("tableId")
90+
.addFamily("cf2", GCRULES.maxVersions(10));
91+
client.createTable(createTableReq);
92+
93+
} finally {
94+
tableAdminClient.close();
95+
}
96+
```
97+
98+
## Troubleshooting
99+
100+
To get help, follow the instructions in the [shared Troubleshooting
101+
document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
102+
103+
Transport
104+
---------
105+
Bigtable uses gRPC for the transport layer.
106+
107+
## Java Versions
108+
109+
Java 7 or above is required for using this client.
110+
111+
## Versioning
112+
113+
This library follows [Semantic Versioning](http://semver.org/).
114+
115+
It is currently in major version zero (`0.y.z`), which means that anything may
116+
change at any time and the public API should not be considered stable.
117+
118+
## Contributing
119+
120+
Contributions to this library are always welcome and highly encouraged.
121+
122+
See [CONTRIBUTING] for more information on how to get started and [DEVELOPING] for a layout of the
123+
codebase.
124+
125+
## License
126+
127+
Apache 2.0 - See [LICENSE] for more information.
128+
129+
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md
130+
[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE
131+
[cloud-platform]: https://cloud.google.com/
132+
[cloud-bigtable]: https://cloud.google.com/bigtable/
133+
[bigtable-product-docs]: https://cloud.google.com/bigtable/docs/
134+
[bigtable-admin-client-lib-docs]: https://googlecloudplatform.github.io/google-cloud-java/google-cloud-clients/apidocs/index.html?com/google/cloud/bigtable/admin/v2/package-summary.html
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>google-cloud-bigtable-admin</artifactId>
5+
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
6+
<packaging>jar</packaging>
7+
<name>Google Cloud Bigtable Admin</name>
8+
<url>https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-bigtable</url>
9+
<description>
10+
Java idiomatic client for Google Cloud Bigtable Admin API.
11+
</description>
12+
<parent>
13+
<groupId>com.google.cloud</groupId>
14+
<artifactId>google-cloud-clients</artifactId>
15+
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-clients:current} -->
16+
</parent>
17+
<properties>
18+
<site.installationModule>google-cloud-bigtable-admin</site.installationModule>
19+
</properties>
20+
<dependencies>
21+
<dependency>
22+
<groupId>${project.groupId}</groupId>
23+
<artifactId>google-cloud-core</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>${project.groupId}</groupId>
27+
<artifactId>google-cloud-core-grpc</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>com.google.api.grpc</groupId>
31+
<artifactId>proto-google-cloud-bigtable-admin-v2</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.google.api.grpc</groupId>
35+
<artifactId>grpc-google-cloud-bigtable-admin-v2</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.grpc</groupId>
40+
<artifactId>grpc-netty-shaded</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.grpc</groupId>
44+
<artifactId>grpc-stub</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.grpc</groupId>
48+
<artifactId>grpc-auth</artifactId>
49+
</dependency>
50+
51+
<dependency>
52+
<groupId>com.google.auto.value</groupId>
53+
<artifactId>auto-value</artifactId>
54+
<scope>provided</scope>
55+
</dependency>
56+
57+
<!-- Test -->
58+
<dependency>
59+
<groupId>${project.groupId}</groupId>
60+
<artifactId>google-cloud-core</artifactId>
61+
<type>test-jar</type>
62+
<scope>test</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.mockito</groupId>
71+
<artifactId>mockito-all</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>com.google.truth</groupId>
76+
<artifactId>truth</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>com.google.api</groupId>
81+
<artifactId>gax-grpc</artifactId>
82+
<classifier>testlib</classifier>
83+
<scope>test</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>io.grpc</groupId>
87+
<artifactId>grpc-testing</artifactId>
88+
<scope>test</scope>
89+
</dependency>
90+
</dependencies>
91+
<profiles>
92+
<profile>
93+
<id>doclint-java8-disable</id>
94+
<activation>
95+
<jdk>[1.8,)</jdk>
96+
</activation>
97+
<properties>
98+
<!-- add this to disable checking -->
99+
<javadoc.opts>-Xdoclint:none</javadoc.opts>
100+
</properties>
101+
</profile>
102+
</profiles>
103+
<build>
104+
<plugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-failsafe-plugin</artifactId>
108+
<version>2.19.1</version>
109+
<executions>
110+
<execution>
111+
<goals>
112+
<goal>integration-test</goal>
113+
<goal>verify</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
<configuration>
118+
<parallel>classes</parallel>
119+
<perCoreThreadCount>true</perCoreThreadCount>
120+
<threadCount>2</threadCount>
121+
</configuration>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
</project>
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,20 @@
4444
import org.threeten.bp.Duration;
4545

4646
public class TableAdminClientIT {
47-
// TODO(igorbernstein2): remove these properties once admin is split from data client
48-
private static final String ENV_PROPERTY = "bigtable.env";
49-
private static final String TABLE_PROPERTY_NAME = "bigtable.table";
47+
private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance";
5048

51-
static TableAdminClient tableAdmin;
49+
private static TableAdminClient tableAdmin;
5250

5351
@BeforeClass
5452
public static void createClient() throws IOException {
55-
if (!"prod".equals(System.getProperty(ENV_PROPERTY))) {
53+
String targetInstance = System.getProperty(INSTANCE_PROPERTY_NAME);
54+
55+
if (targetInstance == null) {
5656
tableAdmin = null;
5757
return;
5858
}
5959

60-
TableName tableName = TableName.parse(System.getProperty(TABLE_PROPERTY_NAME));
61-
InstanceName instanceName = InstanceName.of(tableName.getProject(), tableName.getInstance());
62-
60+
InstanceName instanceName = InstanceName.parse(targetInstance);
6361
tableAdmin = TableAdminClient.create(instanceName);
6462
}
6563

@@ -72,9 +70,9 @@ public static void closeClient() {
7270

7371
@Before
7472
public void setup() {
75-
// TODO(igorbernstein2): remove this check once admin is split
7673
if (tableAdmin == null) {
77-
throw new AssumptionViolatedException("Tests can only run against prod environment");
74+
throw new AssumptionViolatedException(
75+
INSTANCE_PROPERTY_NAME + " property is not set, skipping integration tests.");
7876
}
7977
}
8078

google-cloud-clients/google-cloud-bigtable/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
<type>test-jar</type>
7171
<scope>test</scope>
7272
</dependency>
73+
<dependency>
74+
<groupId>com.google.api.grpc</groupId>
75+
<artifactId>grpc-google-cloud-bigtable-admin-v2</artifactId>
76+
<scope>test</scope>
77+
</dependency>
7378
<dependency>
7479
<groupId>junit</groupId>
7580
<artifactId>junit</artifactId>

0 commit comments

Comments
 (0)