Products
Clients
Extensions
This quick start will help you get started using VMware GemFire and the VMware GemFire node.js client, with a small Book Service example.
Book Service
Download and install VMware GemFire from Tanzu Network. Follow the installation instructions in the GemFire documentation.
This guide uses a Book Service example that allows a user to look up books by ISBN or put new books into the service.
Clone the node examples from the GemFire Node Examples repository.
$ git clone https://github.com/gemfire/node-examples.git
To run the Book Service example, you must download and install the VMware GemFire Node.js client library.
In a terminal, change your working directory to node-examples/book-service, and npm install the VMware GemFire Node.js client you downloaded above, into your project directory.
node-examples/book-service
npm install
$ npm install /project/gemfire-nodejs-client-2.0.0.tgz $ npm update
There are shell scripts in the book-service/scripts directory. The startGemFire script starts up two locators and two cache servers. The locators allow clients to find the cache servers. To simplify local development, the script also creates the single region (analogous to a table in a relational database) that the app uses.
book-service/scripts
startGemFire
Start the scripts in the node-examples/book-service directory
Mac and Linux
$ ./scripts/startGemFire.sh
Windows
C:>powershell .\scripts\startGemFire.ps1
With a current working directory of node-examples/book-service
$ node src/server.js
C:>node .\src\server.js
To add a book to the data service, use a curl command:
$ curl -X PUT \ 'http://localhost:8080/book/put?isbn=0525565329' \ -H 'Content-Type: application/json' \ -d '{ "FullTitle": "The Shining", "ISBN": "0525565329", "MSRP": "9.99", "Publisher": "Anchor", "Authors": "Stephen King" }'
C:>curl -X PUT "http://localhost:8080/book/put?isbn=0525565329" -H "Content-Type: application/json" -d "{\"FullTitle\": \"The Shining\", \"ISBN\": \"0525565329\", \"MSRP\": \"9.99\", \"Publisher\": \"Anchor\", \"Authors\": \"Stephen King\"}"
To look up a book in the data service, use a curl command, specifying the ISBN as a key:
$ curl -X GET 'http://localhost:8080/book/get?isbn=0525565329'
When finished running the example locally, shut down the client and server processes.
In the shell running node, use control-C to stop running the app.
node
control-C
Use a script to tear down the GemFire cluster. With a current working directory of node-examples/book-service
$ ./scripts/shutdownGemFire.sh
C:>powershell .\scripts\shutdownGemFire.ps1
Use a script to remove the directories and files containing GemFire logs created for the cluster. With a current working directory of node-examples/book-service:
$ ./scripts/clearGemFireData.sh
C:>powershell .\scripts\clearGemFire.ps1