Code Monkey home page Code Monkey logo

grpc-java's Introduction

grpc-java

In this demo you will work with the GRPC interface in Stargate

1. Prerequisites

๐Ÿ“ฆ Docker

docker -v
docker run hello-world

๐Ÿ“ฆ Java Development Kit (JDK) 11+

java -version

๐Ÿ“ฆ Apache Maven

mvn -version

2. Start Stargate

The element below have been extracted from Stargate documentation

โœ… Step 2a: Pull the docker image

Download Stargate docker image : Docker Image Version (tag latest semver)

docker pull stargateio/stargate-3_11:v1.0.41

โœ… Step 2b: Start stargate container in development mode.

docker run --name stargate \
  -p 8080:8080 \
  -p 8081:8081 \
  -p 8082:8082 \
  -p 8090:8090 \
  -p 127.0.0.1:9042:9042 \
  -d \
  -e CLUSTER_NAME=stargate \
  -e CLUSTER_VERSION=3.11 \
  -e DEVELOPER_MODE=true \
  stargateio/stargate-3_11:v1.0.41

With Development mode Stargate also the role of a data node, you do not need an extra Cassandra container.

All apis are enabled, here is the port list:

  • 8080 is the graphql port
  • 8081 is the authentication port
  • 8082 is the rest port
  • 8090 is the grpc port

After 30 seconds you should be able to following URLs:

3. Execute the main class for Stargate

You can now run the example

mvn install exec:java -Dexec.mainClass=com.datastax.tutorial.ConnectStargate

Expected output

[INFO] 
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ grpc-java ---
Keyspace 'test' has been created.
Table 'users' has been created.
2 rows have been inserted in table users.
FirstName=Doug, lastname=Wettlaufer
FirstName=Lorina, lastname=Poland
Everything worked!

4. Execute the main class for Astra

You will need an Astra Database with an Astra Token

In class ConnectAstra edit the following properties

private static final String ASTRA_DB_ID      = "<id>";
private static final String ASTRA_DB_REGION  = "<region>";
private static final String ASTRA_TOKEN      = "<token>";
private static final String ASTRA_KEYSPACE   = "<keyspace>";

Then execute the class

mvn install exec:java -Dexec.mainClass=com.datastax.tutorial.ConnectAstra

grpc-java's People

Contributors

clun avatar polandll avatar

Watchers

 avatar

Forkers

clun

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.