partitionedRegionQuerying.README.html Maven / Gradle / Ivy
vFabric™ GemFire®
Querying Partitioned Regions
Query execution using Function API Example
This example demonstrates how to execute a query on a Partitioned Region using function from a client by setting a filter in the function call. The example consists of two servers with partitioned region and a client. The servers register a function which executes a query. The client invokes the function on one of the servers based on the filter provided to the function call. For information on Partitioned Region Querying, see the GemFire User's Guide.
The Configuration Files
The cacheserver uses the server.xml
cache configuration file. The client does not use any configuration files.
The Client/Server Processes
The processes used for this example are:
- Two cacheserver processes.
- The client process. All client configuration is done inside the application. The client runs outside of the server distributed system as a standalone application. In its cache configuration, the client defines a server connection pool, which specifies the servers' address and port to connect. At startup, the client connects to the two server processes.
Running the Examples
Follow these instructions to run the configuration examples.
When you run the examples, if you get a startup failure with a message indicating socket creation failure or that the port is already in use, make sure you are not starting a second copy of the same GemFire process, with the same port configuration. If you are not, then the port specification probably conflicts with some other non-GemFire application. Follow the instructions in Changing the ports used in the examples for the process that is failing to start.
You need three terminal sessions: two for the two cacheservers, and one for client. For all the sessions, make sure the environment is set
according to the instructions in examples/EnvSetup.html.
- Change directory to
examples/dist/partitionedRegionQuerying
.
The example instructions assume you are starting from that directory.
- Create two directories
server1
and server2
for the two servers.
- In one session, start a server.
cacheserver start -dir=server1 mcast-port=10334 cache-xml-file=../server.xml -server-port=40404
- In another session, start another server with different port.
cacheserver start -dir=server2 mcast-port=10334 cache-xml-file=../server.xml -server-port=40405
- In third session, run the client.
java partitionedRegionQuerying.Client
The client starts, connects to the two servers, inserts data and executes a query.
When the client finishes it returns.
- In the other two sessions, stop the two cacheservers:
cacheserver stop -dir=server1
cacheserver stop -dir=server2
- You can verify that the query has been executed on only one server by looking at the
cacheserver.log
files in the server1
and server2
directories.
Changing the ports used in the examples If you run the servers on some other ports, change the server ports for the client to connect in the following way:Add-Dserver1Port=
<yourPortNumber> and/or-Dserver2Port=
<yourPortNumber> to thejava
command-line invocation for the client to connect to the servers on these ports, like this:
java -Dserver1Port=40100 -Dserver2Port=40101 partitionedRegionQuerying.Client