Skip to content

Commit

Permalink
Bigtable: Move admin api into its own artifact. (#3494)
Browse files Browse the repository at this point in the history
The target usecases are different enough that the clients should be split.
Also, it avoids confusion associated with duplicate static names.
  • Loading branch information
igorbernstein2 authored and garrettjonesgoogle committed Jul 25, 2018
1 parent 59bf71e commit 89433fc
Show file tree
Hide file tree
Showing 40 changed files with 321 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ jobs:
name: Run integration tests for google-cloud-bigtable
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

bigtableadmin_it:
working_directory: ~/googleapis
<<: *anchor_docker
<<: *anchor_auth_vars
steps:
- checkout
- run:
<<: *anchor_run_decrypt
- run:
name: Run integration tests for google-cloud-bigtable-admin
command: ./utilities/verify_single_it.sh google-cloud-clients/google-cloud-bigtable-admin -Dbigtable.instance=projects/gcloud-devel/instances/google-cloud-bigtable

compute_it:
working_directory: ~/googleapis
<<: *anchor_docker
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This library supports the following Google Cloud Platform services with clients
This library supports the following Google Cloud Platform services with clients at an [Alpha](#versioning) quality level:

- [Cloud Bigtable](google-cloud-clients/google-cloud-bigtable) (Alpha)
- [Cloud Bigtable Admin](google-cloud-clients/google-cloud-bigtable-admin) (Alpha)
- [Cloud Compute](google-cloud-clients/google-cloud-compute) (Alpha)
- [Cloud Dataproc](google-cloud-clients/google-cloud-dataproc) (Alpha)
- [Cloud DNS](google-cloud-clients/google-cloud-dns) (Alpha)
Expand Down
15 changes: 15 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ To use the `prod` environment:
-Dbigtable.table=projects/my-project/instances/my-instance/tables/my-table
```

### Testing code that uses Bigtable Admin

Bigtable Admin integration tests are run against a real Bigtable instance.

To run the tests:
1. Set up the target table using `google-cloud-bigtable/scripts/setup-test-table.sh`
2. Download the [JSON service account credentials file][create-service-account] from the Google
Developer's Console.
3. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the path of the credentials file
4. Set the system property `bigtable.instance` to the full instance name you
created earlier. Example:
```shell
mvn verify -am -pl google-cloud-bigtable-admin \
-Dbigtable.instance=projects/my-project/instances/my-instance
```
### Testing code that uses Compute
Expand Down
11 changes: 11 additions & 0 deletions google-cloud-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,17 @@
<artifactId>grpc-google-cloud-bigtable-v2</artifactId>
<version>0.20.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-bigtable-v2:current} -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable-admin</artifactId>
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable-admin</artifactId>
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-bigtable-admin-v2</artifactId>
Expand Down
134 changes: 134 additions & 0 deletions google-cloud-clients/google-cloud-bigtable-admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Google Cloud Java Client for Bigtable Admin

Java idiomatic client for [Cloud Bigtable Admin][cloud-bigtable]. Please note that this client is under
heavy development and is not ready for production use. Please continue to use the
[HBase API client](https://github.com/GoogleCloudPlatform/cloud-bigtable-client) for production.

[[![CircleCI](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-java/tree/master.svg?style=shield)](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-java/tree/master)
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/google-cloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/google-cloud-java?branch=master)
[![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)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
[![Dependency Status](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772/badge.svg?style=flat)](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772)

- [Product Documentation][bigtable-product-docs]
- [Client Library Documentation][bigtable-admin-client-lib-docs]

> Note: This client is under heavy development and should not be used in production.
## Quickstart

[//]: # ({x-version-update-start:google-cloud-bigtable-admin:released})
If you are using Maven, add this to your pom.xml file
```xml
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable-admin</artifactId>
<version>0.55.1-alpha</version>
</dependency>
```
If you are using Gradle, add this to your dependencies
```Groovy
compile 'com.google.cloud:google-cloud-bigtable-admin:0.55.1-alpha'
```
If you are using SBT, add this to your dependencies
```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable-admin" % "0.55.1-alpha"
```
[//]: # ({x-version-update-end})

## Authentication

See the
[Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication)
section in the base directory's README.

## About Cloud Bigtable Admin

[Cloud Bigtable][cloud-bigtable] is Google's NoSQL Big Data database service. It's
the same database that powers many core Google services, including Search, Analytics, Maps, and
Gmail. The API is split into the data api and the admin api. This client targets the admin api.

Be sure to activate the Cloud Bigtable Admin API on the Developer's Console to use Cloud Bigtable
from your project.

See the [Bigtable Amin client lib docs][bigtable-admin-client-lib-docs] to learn how to
interact with Cloud Bigtable Admin API using this Client Library.

## Getting Started
#### Prerequisites
For this tutorial, you will need a
[Google Developers Console](https://console.developers.google.com/) project with the Cloud Bigtable
API enabled. You will need to
[enable billing](https://support.google.com/cloud/answer/6158867?hl=en) to use Google Cloud Bigtable.
[Follow these instructions](https://cloud.google.com/docs/authentication#preparation) to get your
project set up. You will also need to set up the local development environment by [installing the
Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line:
`gcloud auth login`.

#### Calling Cloud Bigtable

The Cloud Bigtable API is split into 2 parts: Data API, Instance Admin API and Table Admin API.

Here is a code snippet showing simple usage of the Table API. Add the following imports
at the top of your file:


```java
import com.google.bigtable.admin.v2.ColumnFamily;
import com.google.bigtable.admin.v2.InstanceName;
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
```

Then, to create a table, use the following code:
```java
InstanceName instanceName = InstanceName.of("my-project", "my-instance");

TableAdminClient tableAdminClient = TableAdminClient.create(instanceName);

try {
CreateTable createTableReq = TableAdminRequests.createTable("tableId")
.addFamily("cf2", GCRULES.maxVersions(10));
client.createTable(createTableReq);

} finally {
tableAdminClient.close();
}
```

## Troubleshooting

To get help, follow the instructions in the [shared Troubleshooting
document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).

Transport
---------
Bigtable uses gRPC for the transport layer.

## Java Versions

Java 7 or above is required for using this client.

## Versioning

This library follows [Semantic Versioning](http://semver.org/).

It is currently in major version zero (`0.y.z`), which means that anything may
change at any time and the public API should not be considered stable.

## Contributing

Contributions to this library are always welcome and highly encouraged.

See [CONTRIBUTING] for more information on how to get started and [DEVELOPING] for a layout of the
codebase.

## License

Apache 2.0 - See [LICENSE] for more information.

[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md
[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE
[cloud-platform]: https://cloud.google.com/
[cloud-bigtable]: https://cloud.google.com/bigtable/
[bigtable-product-docs]: https://cloud.google.com/bigtable/docs/
[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
125 changes: 125 additions & 0 deletions google-cloud-clients/google-cloud-bigtable-admin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<artifactId>google-cloud-bigtable-admin</artifactId>
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable-admin:current} -->
<packaging>jar</packaging>
<name>Google Cloud Bigtable Admin</name>
<url>https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-bigtable</url>
<description>
Java idiomatic client for Google Cloud Bigtable Admin API.
</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-clients</artifactId>
<version>0.55.2-alpha-SNAPSHOT</version><!-- {x-version-update:google-cloud-clients:current} -->
</parent>
<properties>
<site.installationModule>google-cloud-bigtable-admin</site.installationModule>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>google-cloud-core</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>google-cloud-core-grpc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-bigtable-admin-v2</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-bigtable-admin-v2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-auth</artifactId>
</dependency>

<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>google-cloud-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>doclint-java8-disable</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<!-- add this to disable checking -->
<javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<parallel>classes</parallel>
<perCoreThreadCount>true</perCoreThreadCount>
<threadCount>2</threadCount>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@
import org.threeten.bp.Duration;

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

static TableAdminClient tableAdmin;
private static TableAdminClient tableAdmin;

@BeforeClass
public static void createClient() throws IOException {
if (!"prod".equals(System.getProperty(ENV_PROPERTY))) {
String targetInstance = System.getProperty(INSTANCE_PROPERTY_NAME);

if (targetInstance == null) {
tableAdmin = null;
return;
}

TableName tableName = TableName.parse(System.getProperty(TABLE_PROPERTY_NAME));
InstanceName instanceName = InstanceName.of(tableName.getProject(), tableName.getInstance());

InstanceName instanceName = InstanceName.parse(targetInstance);
tableAdmin = TableAdminClient.create(instanceName);
}

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

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

Expand Down
5 changes: 5 additions & 0 deletions google-cloud-clients/google-cloud-bigtable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-bigtable-admin-v2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Loading

0 comments on commit 89433fc

Please sign in to comment.