Skip to content

Latest commit

 

History

History
 
 

hello-world

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Cloud Bigtable Hello World

This is a simple application that demonstrates using the native HBase API to connect to and interact with Cloud Bigtable.

See the documentation for this sample for a brief explanation of the code.

Table of Contents

Downloading the sample

Download the sample app and navigate into the app directory:

  1. Clone the Cloud Bigtable examples repository, to your local machine:

    git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-examples.git
    

    Alternatively, you can download the sample as a zip file and extract it.

  2. Change to the Hello World code sample directory.

    cd cloud-bigtable-examples/java/hello-world
    

Costs

This sample uses billable components of Cloud Platform, including:

  • Google Cloud Bigtable

Use the Pricing Calculator to generate a cost estimate based on your projected usage. New Cloud Platform users might be eligible for a free trial.

Before you begin

This sample assumes you have Java 8 installed.

Installing Maven

These samples use the Apache Maven build system. Before getting started, be sure to download and install it. When you use Maven as described here, it will automatically download the needed client libraries.

Creating a Project in the Google Cloud Platform Console

If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.

  1. Open the Cloud Platform Console.
  2. In the drop-down menu at the top, select Create a project.
  3. Give your project a name.
  4. Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.

Enabling billing for your project.

If you haven't already enabled billing for your project, enable billing now. Enabling billing allows is required to use Cloud Bigtable and to create VM instances.

Install the Google Cloud SDK.

If you haven't already installed the Google Cloud SDK, install the Google Cloud SDK now. The SDK contains tools and libraries that enable you to create and manage resources on Google Cloud Platform.

Setting Google Application Default Credentials

Set your Google Application Default Credentials by initializing the Google Cloud SDK with the command:

	gcloud init

Generate a credentials file by running the application-default login command:

gcloud auth application-default login

Provisioning an instance

Follow the instructions in the user documentation to create a Google Cloud Platform project and Cloud Bigtable instance if necessary. You'll need to reference your project id and instance id to run the application.

Running the application

Build and run the sample using Maven.

mvn package
mvn exec:java -Dbigtable.projectID=GCLOUDPROJECT -Dbigtable.instanceID=BIGTABLEINSTANCE

You will see output resembling the following, interspersed with informational logging from the underlying libraries:

HelloWorld: Create table Hello-Bigtable
HelloWorld: Write some greetings to the table
HelloWorld: Scan for all greetings:
    Hello World!
    Hello Cloud Bigtable!
    Hello HBase!
HelloWorld: Delete the table

Cleaning up

To avoid incurring extra charges to your Google Cloud Platform account, remove the resources created for this sample.

  1. Go to the Cloud Bigtable instance page in the Cloud Console.

  2. Click on the instance name.

  3. Click Delete instance.

    Delete

  4. Type the instance ID, then click Delete to delete the instance.