Skip to content

ngcgarcia/cloud-spanner-samples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Spanner Banking Application

This repository contains a sample banking application built using Cloud Spanner.

How to run the application locally

NOTE: Requires gcloud, mvn, grpc_cli installed.

  1. Create a database locally using cloud-spanner-emulator and export spanner host for client libraries to work.

    $ gcloud emulators spanner start
    $ gcloud config configurations create emulator
    $ gcloud config set auth/disable_credentials true
    $ gcloud config set project test-project
    $ gcloud config set api_endpoint_overrides/spanner http://localhost:9020/
    $ gcloud spanner instances create test-instance \
        --config=emulator-config --description="Test Instance" --nodes=1
    $ gcloud config set spanner/instance test-instance
    $ gcloud spanner databases create test-database \
        --ddl-file src/main/java/com/google/finapp/schema.sdl
    $ export SPANNER_EMULATOR_HOST="localhost:9010"
    
  2. Bring up the FinAppServer hosting a grpc service.

    $ mvn verify
    $ mvn exec:java -Dexec.mainClass=com.google.finapp.ServerMain
    
  3. Call RPCs using grpc_cli.

    $ grpc_cli call localhost:8080 CreateCustomer \
        "name: 'google' address: 'amphitheatre pkwy'"
    

How to run the workload generator

  1. Run the application in a separate terminal.

  2. In the cloud-spanner-samples/workload directory, run

    $ mvn clean compile assembly:single
    $ java -jar target/workload-1.0-SNAPSHOT-jar-with-dependencies.jar --address-name localhost --port 8080 --num-accounts 200 
    

How to run the application tests

  1. Set up the emulator as described in #1 above.
  2. Run mvn integration-test.

To run the tests using the JDBC implementation of the application instead of the Java client implementation, run mvn integration-test -DSPANNER_USE_JDBC=true

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.8%
  • Dockerfile 0.2%