com.googlecode.icegem.utils
Class CacheUtils

java.lang.Object
  extended by com.googlecode.icegem.utils.CacheUtils

public class CacheUtils
extends Object

Help class for common operations with regions.

Author:
Andrey Stepanov aka standy

Constructor Summary
CacheUtils()
           
 
Method Summary
static String addQueryLimit(String queryString, int queryLimit)
          Limits query results.
static void clearRegion(com.gemstone.gemfire.cache.Region<?,?> region)
          Clears all types of regions.
static String[] getFirstLocatorFromLocatorsString(String locatorsString)
          Returns first locator host and port from locators string.
static int getRegionSize(com.gemstone.gemfire.cache.Region<?,?> region)
           
static
<T> T
retryWithExponentialBackoff(Retryable<T> runnable, int maxRetries)
          Retries passed operation with random exponential back off delay.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheUtils

public CacheUtils()
Method Detail

addQueryLimit

public static String addQueryLimit(String queryString,
                                   int queryLimit)
Limits query results.

Parameters:
queryString - Query string.
Returns:
Query string with injected "LIMIT" clause.

getFirstLocatorFromLocatorsString

public static String[] getFirstLocatorFromLocatorsString(String locatorsString)
Returns first locator host and port from locators string.

Parameters:
locatorsString - of type String
Returns:
String[0] - locator host String[1] - locator port

clearRegion

public static void clearRegion(com.gemstone.gemfire.cache.Region<?,?> region)
Clears all types of regions. This method can clean both types of regions (REPLICATED, PARTITIONED). It can be used both on client and server side. Note: if this method is used from client configured as CACHING_PROXY: clearing of PARTITIONED regions: - if client's data should be cleared together with server's data, client interest should be registered on entries changes; clearing of REPLICATED regions: - if client's data should be cleared together with server's data, this method should be invoked from the client together with region.localClear() method.

Parameters:
region - partitioned region

getRegionSize

public static int getRegionSize(com.gemstone.gemfire.cache.Region<?,?> region)
Parameters:
region - Region.
Returns:
Size of the given region.

retryWithExponentialBackoff

public static <T> T retryWithExponentialBackoff(Retryable<T> runnable,
                                                int maxRetries)
                                     throws InterruptedException,
                                            OperationRetryFailedException
Retries passed operation with random exponential back off delay.

Type Parameters:
T - Type of returned value.
Parameters:
runnable - the operation.
maxRetries - the maximum number of retries.
Returns:
the value returned by operation
Throws:
OperationRetryFailedException
InterruptedException


Copyright © 2011. All Rights Reserved.