Finding Partition Load

Search Solutions & Best Practices
Searching Solutions and Best Practices
Browse Solutions & Best Practices

                                                              

Summary: This page describes two ways to determine the partition load in a Gigaspaces grid programmatically.
Author: Joe Ottinger, Technology Evangelist, GigaSpaces
Recently tested with GigaSpaces version: XAP 7.1.2

Overview

When using a GigaSpaces cluster as a task queue there are times you will need to determine how the space instances are loaded. This could be to determine where you can route the next task (minimum load partition/instance) or where you want to launch more processors (heavily loaded partition/instance).

There are couple of approaches you could use to identify these partitions: task executors and an executor service. You can also see the Executors example page for other similar examples.

Using a Task Executor

The first example shows an implementation of DistributedTask that can be used in scenarios where you want to run ad-hoc queries. Usage instructions are similar to the Task Executors Example. Business logic does not have to be on the cluster, it is dynamically transported to the server side and executed remotely.

Example is trying to find a partition with least number of objects and uses GigaSpaces SpaceRuntimeInfo API to get the count of objects. This API is lot faster compared to the count API and is preferred way of getting object counts.

Using an Executor Service

Another example shows an implementation using Executor Service. This approach should be used when this functionality is intrinsic part of the system and not needed on ad-hoc basis. Usage instructions are similar to the Executor Service Example.

In this example, we're trying to find the partition with the least number of objects, using GigaSpaces' SpaceRuntimeInfo API to get the count of objects. This API is lot faster than the count API and is the preferred way of getting object counts.

Rate this page:
Your Rating: Results: PatheticBadOKGoodOutstanding! 0 rates

Additional resources: XAP Application Server | XAP Data Grid | XAP for Cloud Computing | XAP J2EE Support

Labels

 
(None)