In this demo you will work with the GRPC interface in Stargate
- Use the reference documentation to install Docker Desktop
- Validate your installation with
docker -v
docker run hello-world
- Use the reference documentation to install a Java Development Kit
- Validate your installation with
java -version
- Use the reference documentation to install Apache Maven
- Validate your installation with
mvn -version
The element below have been extracted from Stargate documentation
Download Stargate docker image :
docker pull stargateio/stargate-3_11:v1.0.41
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 port8081
is the authentication port8082
is the rest port8090
is the grpc port
After 30 seconds you should be able to following URLs:
- URL for health: http://localhost:8082/health
- URL for Open Api specification: http://localhost:8082/swagger-ui/#/
- URL for graphql Playground: http://localhost:8080/playground
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!
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