Skip to content

This repository contains example code to accompany the Sequence generation in Cloud Spanner solution paper.

License

Notifications You must be signed in to change notification settings

GoogleCloudPlatform/solutions-spanner-sequences

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spanner Sequence Generator example code

This repository contains example code to accompany the Sequence generation in Cloud Spanner solution paper.

How to use this example

The example code includes performance tests of the different types of sequence generators. These tests require a Cloud Spanner database.

  1. Create a Cloud Spanner instance (if required). One node is sufficient for these tests.

  2. Create a Cloud Spanner database with the following table definition:

    CREATE TABLE sequences (
      name STRING(64) NOT NULL,
      next_value INT64 NOT NULL,
    ) PRIMARY KEY(name)
  3. Insert the following single row into the database:

    INSERT INTO sequences (name, next_value) VALUES ('my-sequence', 0);
  4. Clone the repository from GitHub

    git clone https://github.com/GoogleCloudPlatform/solutions-spanner-sequences.git
  5. If running on a Compute Engine VM, ensure that the service account being used has access to the Cloud Spanner API and can read/write to the Cloud Spanner Database.
    If running on a development machine ensure that your Application Default Credentials are set to an account that can read/write to the Cloud Spanner database.
    See Authentication Overview in Google Cloud documentation for more information.

  6. Compile and run the performance test

    Either: compile and execute using Maven:

    mvn compile exec:java \
        -Dexec.mainClass=com.google.cloud.solutions.spanner.PerformanceTest \
        -Dexec.args="INSTANCE_NAME DATABASE_NAME MODE ITERATIONS THREADS"

    Or: build a 'fat' deployable JAR containing all dependencies (for easy copying to a remote machine), and execute the JAR:

    mvn package
    java -jar target/sequence-generator-1.0-SNAPSHOT-jar-with-dependencies.jar \
        INSTANCE_NAME DATABASE_NAME MODE ITERATIONS THREADS

    where:

    • INSTANCE_NAME is your Cloud Spanner instance name
    • DATABASE_NAME is the name of your database
    • MODE is one of the sequence generator modes: simple, sync, async, batch or asyncbatch. (see the solution document for the definition of these modes)
    • ITERATIONS - the number of sequence values to generate
    • THREADS - the number of simultaneous threads requesting sequence values

License

Apache Version 2.0

About

This repository contains example code to accompany the Sequence generation in Cloud Spanner solution paper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages