Source: SqlExample.php
This example demonstrates GridGain usage as an SQL database:
- connects to a node
- creates a cache, if it doesn't exist
- creates tables (CREATE TABLE)
- creates indices (CREATE INDEX)
- writes data of primitive types into the tables (INSERT INTO table)
- reads data from the tables (SELECT ...)
- deletes tables (DROP TABLE)
- destroys the cache
Source: CachePutGetExample.php
This example demonstrates basic Cache, Key-Value Queries and Scan Query operations:
- connects to a node
- creates a cache, if it doesn't exist
- specifies key type as Integer
- executes different cache operations with Complex Objects and Binary Objects
- put several objects
- putAll
- get
- getAll
- ScanQuery
- destroys the cache
Source: SqlQueryEntriesExample.php
This example demonstrates basic Cache, Key-Value Queries and SQL Query operations:
- connects to a node
- creates a cache from CacheConfiguration, if it doesn't exist
- writes data of primitive and Complex Object types into the cache using Key-Value put operation
- reads data from the cache using SQL Query
- destroys the cache
Source: AuthTlsExample.php
This example requires additional setup.
This example demonstrates how to establish a secure connection to an GridGain node and use username/password authentication, as well as basic Key-Value Queries operations for primitive types:
- connects to a node using TLS and providing username/password
- creates a cache, if it doesn't exist
- specifies key and value type of the cache
- puts data of primitive types into the cache
- gets data from the cache
- destroys the cache
- Obtain certificates required for TLS:
-
either use pre-generated certificates provided in the examples/certs folder. Password for the files:
123456. Note, these certificates work for an GridGain server installed locally only. -
or obtain other existing certificates applicable for a concrete GridGain server.
-
or generate new certificates applicable for a concrete GridGain server.
-
The following files are needed:
- keystore.jks, truststore.jks - for the server side
- client.pem, ca.pem - for the client side
-
Place client.pem and ca.pem files somewhere locally, eg. into the examples/certs folder.
-
If needed, modify
TLS_CLIENT_CERT_FILE_NAMEandTLS_CA_FILE_NAMEconstants in the example source file. The default values point to the files in the examples/certs folder. -
Setup GridGain server to accept TLS - see appropriate GridGain documentation. Provide the obtained keystore.jks and truststore.jks certificates during the setup.
-
Switch on and setup authentication in GridGain server - see appropriate GridGain documentation.
-
If needed, modify
USER_NAMEandPASSWORDconstants in the example source file. The default values are the default GridGain username/password. -
Executes Setup and Running steps.
Source: FailoverExample.php
This example requires additional setup.
This example demonstrates "failover re-connection algorithm" of the client. It:
- configures the client to connect to a set of nodes
- connects to a node
- executes an operation with GridGain server in a cycle (10 operations with 5 seconds pause) and finishes (in about 50 seconds after start)
- if connection is broken, the client automatically tries to reconnect to another node
- if not possible to connect to any node, the example finishes immediately
-
Run three GridGain nodes.
-
If needed, modify
ENDPOINT1,ENDPOINT2,ENDPOINT2constants in an example source file - GridGain node endpoints. Default values arelocalhost:10800,localhost:10801,localhost:10802respectively. -
Run the example by calling
php FailoverExample.php. -
Shut down the node the client connected to (you can find it out from the client logs in the console).
-
From the logs, you will see that the client automatically reconnects to another node which is available.
-
Shut down all the nodes. You will see the client being stopped after failing to connect to each of the nodes.
Note, you have about 50 seconds after the example is started to play with the nodes. After this time the example finishes.