Products
Clients
Extensions
This guide walks you through creating a VMware GemFire service instance on the Tanzu Application Service using the Book Service example to confirm that it is working.
Book Service
Starting in a terminal
Run cf login, and create or target your organization’s space.
cf login
Run cf marketplace -s p-cloudcache to list your available VMware GemFire plans. Take note of the service plan as this will be your <PLAN-NAME> in the following step. Note that VMware GemFire was previously called Pivotal Cloud Cache).
cf marketplace -s p-cloudcache
service plan
<PLAN-NAME>
Create a VMware GemFire service instance within the space with the following command:
cf create-service p-cloudcache <PLAN-NAME> <SERVICE-INSTANCE-NAME>
<SERVICE-INSTANCE-NAME>
The <SERVICE-INSTANCE-NAME> can include alpha-numeric characters, hyphens, and underscores. This is also the name you will use in your manifest.yml to bind your client application to the service instance.
manifest.yml
If successful you will see
OK
Create in progress. Use 'cf services' or 'cf service <your-service-name>' to check operation status.
Confirm the VMware GemFire service instance has been created by running
$ cf services
This command outputs the current status of the service instance creation. In the last operation column you will either see create in progress if it is still be created or create succeeded when it is ready to be used.
create in progress
create succeeded
It can take several minutes for the service instance creation to complete.
Fill in the Instance Name with a custom name for your service instance. The service instance name can include alpha-numeric characters, hyphens, and underscores. This is the name you will use in your manifest.yml. (Alternatively, if you have already pushed your application to your space can select it in the “Bind to App” dropdown - however we prefer to bind our applications through a manifest.yml file)
Click CREATE
After clicking create you will see VMware GemFire service instance provisioning begin and in the Last Operation column it will say create in progress.
Once complete you will see create succeeded under the Last Operation column (you may need to refresh the page for the status to update).
This section will guide you through testing a Book Service client application on the Tanzu Application Service to confirm that your VMware GemFire service instance and node.js client are set up correctly.
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
In order to connect to your VMware GemFire service instance and create the needed regions, you must first create a service key.
In a terminal
Run cf login, and create or target your organization’s space where your VMware GemFire service instance is running.
Create a service key
$ cf create-service-key [YOUR-SERVICE INSTANCE-NAME] [SERVICE-NAME-service-key]
Output the service key:
$ cf service-key [YOUR-SERVICE INSTANCE-NAME] [SERVICE-NAME-service-key]
Copy the gfsh connect command labeled as gfsh_login_string. It will look something like this:
gfsh_login_string
connect --url=https://TAS-name.cf-app.com/gemfire/v1 --user=cluster_operator_XXX --password=YYY --skip-ssl-validation
Start the VMware GemFire CLI by typing gfsh in your terminal.
gfsh
With gfsh running, Use the connect string from above to connect to the VMware GemFire service instance. Use the return key when prompted for the keystore and truststore values (in this example you don’t need to enter any information in them).
return
gfsh>connect --url=https://TAS-name.cf-app.com/gemfire/v1 --user=cluster_operator_BhKM --password=xucZ --skip-ssl-validation key-store: key-store-password: key-store-type(default: JKS): trust-store: trust-store-password: trust-store-type(default: JKS): ssl-ciphers(default: any): ssl-protocols(default: any): ssl-enabled-components(default: all): Successfully connected to: GemFire Manager HTTP service @ https://TAS-name.cf-app.com/gemfire/v1
Once connected, create the region that the Book Service expects to find.
gfsh>create region --name=test --type=PARTITION Member | Status | Message ---------------------------------------- | ------ | ------------------------------------------------ cacheserver-a75d6fcc | OK | Region "/test" created on "cacheserver-a75d6fcc" Cluster configuration for group 'cluster' is updated.
Type exit to quit GFSH.
exit
manifest.yaml
manifest.yml file
PCC-TLS
cf services
cf push
The cf push operation will bind the Book Service app to the VMware GemFire service instance named in your manifest.yaml file and then start the app.
Once the BookService app is running, you can now add and look-up books.
To add a book to the data service, use a curl command similar to the one used when running with a local cluster, specifying the app route assigned in the cf push step.
Mac and Linux
$ curl -X PUT \ 'https://TAS-name.cf-app.com/book/put?isbn=0525565329' \ -H 'Content-Type: application/json' \ -d '{ "FullTitle": "The Shining", "ISBN": "0525565329", "MSRP": "9.99", "Publisher": "Anchor", "Authors": "Stephen King" }'
Windows
$ curl -X PUT "https://cloudcache-node-sample.apps.tas-name.cf-app.com/book/put?isbn=0525565329" -H "Content-Type: application/json" -d "{\"FullTitle\": \"The Shining\", \"ISBN\": \"0525565329\", \"MSRP\": \"9.99\", \"Publisher\": \"Anchor\", \"Authors\": \"Stephen King\"}"
The curl command responds with a confirmation:
`{"initialized":true}`
To look up a book in the data service, use a curl command similar to the one used when running with a local cluster, specifying the ISBN as a key:
`$ curl -X GET \'https://cloudcache-node-sample.apps.tas-name.cf-app.com/book/get?isbn=0525565329'`
The curl command responds with the requested data: {"FullTitle":"The Shining","ISBN":"0525565329","MSRP":"9.99","Publisher":"Anchor","Authors":"Stephen King"}
{"FullTitle":"The Shining","ISBN":"0525565329","MSRP":"9.99","Publisher":"Anchor","Authors":"Stephen King"}
There are two ways to delete the app and the VMware GemFire service instance
Stop the running app
cf stop cloudcache-node-sample
Delete the app and it’s route
cf delete cloudcache-node-sample -r -f
If the VMware GemFire service instance is no longer needed, delete the service
$ cf delete-service <YOUR SERVICE NAME> Really delete the service <YOUR SERVICE NAME>?> y
Congratulations! You’re ready to start using VMware GemFire. You will need to create a new VMware GemFire Service Instance when working with your own application.