init stargate

159 views
Skip to first unread message

Chris Splinter

unread,
Sep 15, 2020, 8:12:53 AM9/15/20
to Stargate Mailing List
We're officially live!

Use this list to ask questions and have discussions about all things Stargate.

You can find more information in the introduction blog post:

Some useful links:

Let's create something awesome!

Damien Bushby

unread,
Sep 30, 2020, 3:24:35 AM9/30/20
to Stargate Mailing List, Chris Splinter
Hi Chris,

Thanks for your work so far.
I got stargate working with own Cassandra 3.11 (https://stargate.io/docs/stargate/0.1/developers-guide/docker.html) and Postman on Centos 7 on vmware workstation 16 on windows 10 pro.
It looks like it will work well in connecting my frontend website to a Scylla database.


I was unable to get stargate with preinstalled docker Cassandra 3.11 (https://stargate.io/docs/stargate/0.1/developers-guide/existing_cstar.html) working

docker run --name some-cassandra --network some-network -d cassandra:3.11

firstly I had an error 'docker: Error response from daemon: network some-network not found.'

'some-docker' container started anyway

docker run --name stargate -d stargateio/stargate-3_11:v0.0.3 --cluster-name some-cassandra --cluster-seed 127.0.0.1 --cluster-version 3.11 --listen 127.0.0.2 --simple-snitch
started 'stargate' container

curl -L -X POST 'http://localhost:8081/v1/auth' -H 'Content-Type: application/json' --data-raw '{"username": "cassandra","password": "cassandra"}'
curl: option --data-raw: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

Error: connect ECONNREFUSED 127.0.0.1:8081
Request Headers
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Postman-Token: a082b4d7-5cda-49f3-9958-f4cd7e262cdf
Host: localhost:8081
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Request Body



I couldn't understand how to apply 'The starctl command' (https://stargate.io/docs/stargate/0.1/developers-guide/starctl.html)

There is also things like which IPs I should be using, which ports to expose, cluster names, version numbers for Scylla.


Maybe I just need some more examples.

I was thinking of having a frontend (Ext JS) connecting to a Scylla database via a REST API on aws.
Maybe Application_Load_Balancer - Nginx_Node_ExtJS_website_on_Fargate - Stargate_on_??? - ScyllaDB_on_EC2.

Thanks for your help.

Regards,
 Damien
Message has been deleted

Chris Splinter

unread,
Oct 1, 2020, 1:17:31 PM10/1/20
to Stargate Mailing List, classba...@gmail.com, Chris Splinter
Posting the response from Doug Wettlaufer that I saw in my inbox but not on this webpage, want to make sure his answer is received. We're looking into some funky-ness going on with this mailing list.

Doug's answer below:

Those docs are more geared towards already having a running Cassandra 3.11 instance on your local through something like ccm. Here is the minimum config needed to connect Stargate with Cassandra 3.11 each running in their own docker containers

docker network create cass-net --driver bridge

docker run --name some-cassandra \
--network cass-net \
-e CASSANDRA_CLUSTER_NAME=stargate-cluster \
-d cassandra:3.11

docker run --name stargate \
--network cass-net \
-p 8081:8081 \
-p 8082:8082 \
-p 9042:9042 \
-e CLUSTER_NAME=stargate-cluster \
-e CLUSTER_VERSION=3.11 \
-e SEED=some-cassandra  \
-e SIMPLE_SNITCH=true \
-e ENABLE_AUTH=true \
-d stargateio/stargate-3_11:v0.0.5


curl -sL -X POST 'localhost:8081/v1/auth' -H 'Content-Type: application/json' \
--data-raw '{
    "username": "cassandra",
    "password": "cassandra"
}' | jq .
{
  "authToken": "339fab81-c659-4dd1-b48e-33e440c9abbd"
}

Damien Bushby

unread,
Oct 2, 2020, 6:42:33 AM10/2/20
to Stargate Mailing List, Chris Splinter, Damien Bushby
Thanks Chris, and thanks to Doug,

I was able to get Stargate and Cassandra 3.11 working with a few modifications.
Windows 10 pro and Centos 7 did not like the jq program, I guess it is mainly a Mac thing.
The --data-raw in curl need to be changed to --data for running in the command line.
There seems to be a variation in / and /v1/ and /v2/, see below. It would be best to be consistent.
I was unable to delete a table or keyspace using curl, with different error messages.

I now have Stargate basically working with a preinstalled Cassandra 3.11 node.

How would I get Stargate working on preinstalled ScyllaDB, e.g. 3 nodes on aws r6gd.medium?
Some example code of a javascript client website on Docker Swarm read/write to a table would be great.

Thanks,
 Damien





docker network create cass-net --driver bridge

docker run --name some-cassandra --network cass-net -e CASSANDRA_CLUSTER_NAME=stargate-cluster -d cassandra:3.11

docker run --name stargate --network cass-net -p 8081:8081 -p 8082:8082 -p 9042:9042 -e CLUSTER_NAME=stargate-cluster -e CLUSTER_VERSION=3.11 -e SEED=some-cassandra -e SIMPLE_SNITCH=true -e ENABLE_AUTH=true -d stargateio/stargate-3_11:v0.0.5

works well with the Stargate with Cassandra 3.11 (https://stargate.io/docs/stargate/0.1/quickstart/quick_start.html) using Postman

However the documents have /v2/ for all but the token, which is /v1/, meaning they do not work with Postman for Stargate with preinstalled Cassandra 3.11
I think the Stargate with Cassandra 3.11 and example json file needs to be changed to /v2/ to be consistent. Maybe the token should also be /v2/

The curl statements do not work from the command line, as --data-raw is not available in curl, even though it is in Postman.

Get token
curl -L -X POST 'http://localhost:8081/v1/auth' -H 'Content-Type: application/json' --data '{"username": "cassandra","password": "cassandra"}'

create keyspace
curl --location --request POST 'localhost:8082/v2/schemas/keyspaces' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"name": "users_keyspace","replicas": 1}'

 dbba9c0b-17ea-40dd-97a4-7ff74c27e523 

create table in keyspace
curl --location --request POST 'localhost:8082/v2/schemas/keyspaces/users_keyspace/tables' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"name": "users","columnDefinitions":[{"name":"firstname","typeDefinition": "text"},{"name": "lastname","typeDefinition": "text"},{"name": "email","typeDefinition": "text"},{"name": "favorite color","typeDefinition": "text"}],"primaryKey":{"partitionKey":["firstname"],"clusteringKey":["lastname"]},"tableOptions":{"defaultTimeToLive": 0,"clusteringExpression":[{ "column": "lastname", "order": "ASC" }]}}'

insert data into table
curl --location --request POST 'localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"firstname": "Mookie","lastname": "Betts","email": "mookie...@gmail.com","favorite color": "blue"}'

read data from table
curl -G --location 'http://localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data-urlencode 'where={"firstname": {"$eq": "Mookie"}}'

curl -G --location 'http://localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: dbba9c0b-17ea-40dd-97a4-7ff74c27e523" --header 'Content-Type: application/json' --data-urlencode 'where={"firstname": {"$eq": "Mookie"}}'

update data in table
curl --location --request PUT 'localhost:8082/v2/keyspaces/users_keyspace/users/Mookie/Betts' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"email": "mookie.bett...@email.com"}'

delete data from table
curl --location --request DELETE 'localhost:8082/v2/keyspaces/users_keyspace/users/Mookie' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json'

delete table
curl --location --request DELETE 'localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json'
{"code":405,"message":"HTTP 405 Method Not Allowed"}

delete keyspace
curl --location --request DELETE 'localhost:8082/v2/keyspaces/users_keyspace' --header "X-Cassandra-Token: 44c0340d-3c75-4a92-abe5-460c0bb059b8" --header 'Content-Type: application/json'
"code":404,"message":"HTTP 404 Not Found"}


Damien Bushby

unread,
Oct 2, 2020, 8:41:14 AM10/2/20
to Stargate Mailing List, Damien Bushby, Chris Splinter
Tomorrow I will try out Node-Fetch (https://github.com/node-fetch/node-fetch) to send data to/from Cassandra 3.11 via Stargate.

Here are the Windows Command Prompt equivalents, basically " instead of ' and \" to escape the " inside a string.

Windows Command Prompt
Get token
curl -L -X POST "http://localhost:8081/v1/auth" -H "Content-Type: application/json" --data "{\"username\": \"cassandra\",\"password\": \"cassandra\"}"

create keyspace
curl --location --request POST "localhost:8082/v2/schemas/keyspaces" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json" --data "{\"name\": \"users_keyspace\",\"replicas\": 1}"

create table in keyspace
curl --location --request POST "localhost:8082/v2/schemas/keyspaces/users_keyspace/tables" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json" --data "{\"name\": \"users\",\"columnDefinitions\":[{\"name\":\"firstname\",\"typeDefinition\": \"text\"},{\"name\": \"lastname\",\"typeDefinition\": \"text\"},{\"name\": \"email\",\"typeDefinition\": \"text\"},{\"name\": \"favorite color\",\"typeDefinition\": \"text\"}],\"primaryKey\":{\"partitionKey\":[\"firstname\"],\"clusteringKey\":[\"lastname\"]},\"tableOptions\":{\"defaultTimeToLive\": 0,\"clusteringExpression\":[{\"column\": \"lastname\", \"order\": \"ASC\" }]}}"

insert data into table
curl --location --request POST "localhost:8082/v2/keyspaces/users_keyspace/users" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json" --data "{\"firstname\": \"Mookie\",\"lastname\": \"Betts\",\"email\": \"mookie...@gmail.com\",\"favorite color\": \"blue\"}'

read data from table
curl -G --location "http://localhost:8082/v2/keyspaces/users_keyspace/users" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json" --data-urlencode "where={\"firstname\": {\"$eq\": \"Mookie\"}}"

update data in table
curl --location --request PUT "localhost:8082/v2/keyspaces/users_keyspace/users/Mookie/Betts" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json" --data "{\"email\": \"mookie.bett...@email.com\"}"

delete data from table
curl --location --request DELETE "localhost:8082/v2/keyspaces/users_keyspace/users/Mookie" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json"

Damien Bushby

unread,
Oct 2, 2020, 8:50:49 AM10/2/20
to Stargate Mailing List, Damien Bushby, Chris Splinter
Here are the ones for Linux.
For both Windows and Linux needs to 

docker exec -it some-cassandra sh
#nodetool status
#cqlsh
cqlsh> drop table users_keyspace.users;
cqlsh> drop keyspace users_keyspace;



Get token
curl -L -X POST 'http://localhost:8081/v1/auth' -H 'Content-Type: application/json' --data '{"username": "cassandra","password": "cassandra"}'

create keyspace
curl --location --request POST 'localhost:8082/v2/schemas/keyspaces' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"name": "users_keyspace","replicas": 1}'

create table in keyspace
curl --location --request POST 'localhost:8082/v2/schemas/keyspaces/users_keyspace/tables' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"name": "users","columnDefinitions":[{"name":"firstname","typeDefinition": "text"},{"name": "lastname","typeDefinition": "text"},{"name": "email","typeDefinition": "text"},{"name": "favorite color","typeDefinition": "text"}],"primaryKey":{"partitionKey":["firstname"],"clusteringKey":["lastname"]},"tableOptions":{"defaultTimeToLive": 0,"clusteringExpression":[{ "column": "lastname", "order": "ASC" }]}}'

insert data into table
curl --location --request POST 'localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"firstname": "Mookie","lastname": "Betts","email": "mookie...@gmail.com","favorite color": "blue"}'

read data from table
curl -G --location 'http://localhost:8082/v2/keyspaces/users_keyspace/users' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data-urlencode 'where={"firstname": {"$eq": "Mookie"}}'

update data in table
curl --location --request PUT 'localhost:8082/v2/keyspaces/users_keyspace/users/Mookie/Betts' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json' --data '{"email": "mookie.bett...@email.com"}'

delete data from table
curl --location --request DELETE 'localhost:8082/v2/keyspaces/users_keyspace/users/Mookie' --header "X-Cassandra-Token: $AUTH_TOKEN" --header 'Content-Type: application/json'

Chris Splinter

unread,
Oct 3, 2020, 3:24:53 PM10/3/20
to Stargate Mailing List, classba...@gmail.com, Chris Splinter
Hey Damien,

Thanks for these details, glad you were able to get things working w/Cassandra 3.11 and Stargate. Responses to your questions / comments below

The --data-raw in curl need to be changed to --data for running in the command line
What version of curl are you using (curl -V)? I checked the docs and it looks like --data-raw was introduced in 7.43.0. Regardless I opened #23 to update our docs to make this better for users.

There seems to be a variation in / and /v1/ and /v2/
Yes, this is true. The service that handles the auth token is different than the service that handles the data requests. These two services will be evolved separately and therefore may not always have the same versions. That said, everything should still work as expected in Postman and via curl, just have to use the proper v1 / v2 version in your URLs.

I was unable to delete a table or keyspace using curl
See below for the proper curl commands, let me know if these work for you:

Delete a table:

curl --location --request DELETE 'localhost:8082/v2/schemas/keyspaces/users_keyspace/tables/users' --header 'X-Cassandra-Token: $AUTH_TOKEN' --header 'Content-Type: application/json'

Delete a keyspace:

curl --location --request DELETE 'localhost:8082/v2/schemas/keyspaces/users_keyspace' --header 'X-Cassandra-Token: $AUTH_TOKEN'' --header 'Content-Type: application/json'

Corrections to the Postman collection file and Quickstart instructions

As you mentioned, there are issues with a few of the /schemas operations. For now please reference the spec and I will update the Postman collection and Quickstart to reflect this #24. Huge thanks for raising it!!

Windows & Linux
Created #25 for us to get the instructions you detailed into our documentation.

Compatibility with ScyllaDB
We haven't tested the compatibility of Stargate with ScyllaDB but the project is built for pluggability and we'd be happy to take this as a contribution to add a new persistence engine for this.

Cheers,

Chris

Damien Bushby

unread,
Oct 7, 2020, 2:32:24 AM10/7/20
to Stargate Mailing List, Chris Splinter, Damien Bushby
Hi Chris,

curl --version
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: 2017-11-14, security patched: 2019-11-05
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL

--data-raw now working, my curl must have updated recently


delete table and delete keyspace did not work, using stargate with cassandra 3.11

C:\Users\selvy>curl --location --request DELETE 'localhost:8082/v2/schemas/keyspaces/users_keyspace/tables/users' --header 'X-Cassandra-Token: 4addd77e-c4b4-4dbf-82f8-d0103024b716' --header 'Content-Type: application/json'
curl: (6) Could not resolve host: 'localhost
curl: (6) Could not resolve host: 4addd77e-c4b4-4dbf-82f8-d0103024b716'
curl: (6) Could not resolve host: application

C:\Users\selvy>curl --location --request DELETE 'localhost:8082/v2/schemas/keyspaces/users_keyspace' --header 'X-Cassandra-Token: 4addd77e-c4b4-4dbf-82f8-d0103024b716'' --header 'Content-Type: application/json'
curl: (6) Could not resolve host: 'localhost
curl: (6) Could not resolve host: 4addd77e-c4b4-4dbf-82f8-d0103024b716''
curl: (6) Could not resolve host: application

C:\Users\selvy>curl --location --request DELETE 'localhost:8082/v2/schemas/keyspaces/users_keyspace' --header 'X-Cassandra-Token: 4addd77e-c4b4-4dbf-82f8-d0103024b716' --header 'Content-Type: application/json'
curl: (6) Could not resolve host: 'localhost
curl: (6) Could not resolve host: 4addd77e-c4b4-4dbf-82f8-d0103024b716'
curl: (6) Could not resolve host: application

C:\Users\selvy>docker ps -a
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS              PORTS                                                        NAMES
8190574e7bee        stargateio/stargate-3_11:v0.0.6   "./starctl"         42 minutes ago      Up 42 minutes       0.0.0.0:8080-8082->8080-8082/tcp, 127.0.0.1:9042->9042/tcp   stargate

 in / and /v1/ and /v2/ 
The variation I was referring to was between the code, postman example and general format. These examples are no longer there to compare.

Regards,
 Damien
 

Doug Wettlaufer

unread,
Oct 7, 2020, 11:13:38 AM10/7/20
to Stargate Mailing List, classba...@gmail.com, Chris Splinter
Hi Damien,

I've created a docs issue to fix those links (https://github.com/stargate/docs/issues/31) thanks for pointing that out.


Have you been able to get those requests to work with Postman or maybe a quick python script? Based on the errors this seems like maybe curl is needing double quotes
curl: (6) Could not resolve host: 'localhost
curl: (6) Could not resolve host: 4addd77e-c4b4-4dbf-82f8-d0103024b716'
curl: (6) Could not resolve host: application

Although on mac your exact curl command works.

-Doug

Damien Bushby

unread,
Oct 8, 2020, 8:32:21 AM10/8/20
to Stargate Mailing List, doug.we...@datastax.com, Damien Bushby, Chris Splinter
Hi  Doug,

These worked
Windows command prompt
Delete a table:
curl --location --request DELETE "localhost:8082/v2/schemas/keyspaces/users_keyspace/tables/users" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json"

Delete a keyspace:
curl --location --request DELETE "localhost:8082/v2/schemas/keyspaces/users_keyspace" --header "X-Cassandra-Token: $AUTH_TOKEN" --header "Content-Type: application/json"


maybe these should be the links to

Postman worked.
Maybe include 'Read all tables from keyspace'

Now that the curls are working I was trying to get it working with Ext JS 7.3 (https://docs.sencha.com/extjs/7.3.0/modern/Ext.data.proxy.Rest.html).
The authorization provided the token, but the insert user and load store gave errors.
Sencha's documentation is poor, with few examples, multiple dead links and other errors.


Regards, 
Damien

Damien Bushby

unread,
Oct 9, 2020, 1:32:12 AM10/9/20
to Stargate Mailing List, Damien Bushby, doug.we...@datastax.com, Chris Splinter
Hi Doug or Chris,

I tried to read the the demo data using a localhost:1962 app without success.

Ext.define('User2', {
extend: 'Ext.data.Model',
proxy: {
cors: true,
type: 'rest',
//fields:['firstname'],
appendId: false,
headers: {
'X-Cassandra-Token': "0ebd96c1-df7d-4222-8a90-9bffb57d8e85",
'Content-Type': "application/json"
},
url: 'http://localhost:8082/v2/keyspaces/users_keyspace/users'
}
});
// the Store automatically picks up the Proxy from the User model
let store2 = Ext.create('Ext.data.Store', {
model: 'User2'
});

store2.load(); // GET /users
console.log(store2);

    1. Request URL:
    2. Request Method:
      GET
    3. Status Code:
      400 Bad Request
    4. Remote Address:
      [::1]:8082
    5. Referrer Policy:
      no-referrer-when-downgrade
  1. Response Headersview source
    1. Access-Control-Allow-Credentials:
      true
    2. Access-Control-Allow-Origin:
    3. Access-Control-Expose-Headers:
      Date
    4. Content-Length:
      70
    5. Content-Type:
      application/json
    6. Date:
      Fri, 09 Oct 2020 05:18:17 GMT
    7. Vary:
      Origin
  2. Request Headersview source
    1. Accept:
      */*
    2. Accept-Encoding:
      gzip, deflate, br
    3. Accept-Language:
      en-GB,en-US;q=0.9,en;q=0.8
    4. Cache-Control:
      no-cache
    5. Connection:
      keep-alive
    6. Content-Type:
      application/json
    7. Host:
      localhost:8082
    8. Origin:
    9. Pragma:
      no-cache
    10. Referer:
    11. sec-ch-ua:
      "Chromium";v="88", "Google Chrome";v="88", ";Not\\A\"Brand";v="99"
    12. sec-ch-ua-mobile:
      ?0
    13. Sec-Fetch-Dest:
      empty
    14. Sec-Fetch-Mode:
      cors
    15. Sec-Fetch-Site:
      same-site
    16. User-Agent:
      Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4286.0 Safari/537.36
    17. X-Cassandra-Token:
      0ebd96c1-df7d-4222-8a90-9bffb57d8e85
    18. X-Requested-With:
      XMLHttpRequest
  3. Query String Parametersview sourceview decoded
    1. _dc:
      1602220697267
    2. page:
      1
    3. start:
      0
    4. limit:
      25
I tried to find the server logs
docker exec -it stargate sh
# ls
did not know what else to do.

I don't think the problem is cors as I can get the token via localhost:1962 and I get an authorization error with a different token.
It is probably some minor client side code error I have made.

**************************
Ext.define('User1', {
extend: 'Ext.data.Model',
proxy: {
cors: true,
type: 'rest',
url: 'http://localhost:3000/test'
}
});
// the Store automatically picks up the Proxy from the User model
let store1 = Ext.create('Ext.data.Store', {
model: 'User1'
});

store1.load(); // GET /users
console.log(store1);


works fine with a nestjs app on localhost:3000
...
@Get('test')
getHello(): string {
return this.appService.getHello();
}
...
getHello(): string {
return "[{\"firstname\":\"Jane\"},{\"firstname\":\"John\"}]";
}
...

Doug Wettlaufer

unread,
Oct 26, 2020, 11:21:46 AM10/26/20
to Stargate Mailing List, classba...@gmail.com, Doug Wettlaufer
Hi Damien,

I'm very sorry about the delay. 

Is there any response body being returned with the 400 or is it just a 400? For your logs you might want to try `docker logs -f stargate` rather than jumping into the container since stargate is logging to standard out.

-Doug

Reply all
Reply to author
Forward
0 new messages