public class EventTest extends Object
EventBB, EventCountersBB and {@link WriterCountersBB
to keep track of what * has happened and to validate that what has
happened is expected (in terms of CacheListener & Writer callbacks).
It requires that the regions that it tests be distributed and
mirrored.EventPrms| Modifier and Type | Field and Description |
|---|---|
protected static int |
ADD_OPERATION |
protected static int |
CLEAR_OPERATION |
protected static String |
createCallbackPrefix |
protected static int |
DESTROY_OPERATION |
protected static String |
destroyCallbackPrefix |
protected com.gemstone.gemfire.distributed.DistributedLockService |
distLockService |
protected static EventTest |
eventTest |
protected static int |
INVALIDATE_OPERATION |
protected static String |
invalidateCallbackPrefix |
boolean |
isCarefulValidation |
protected boolean |
isListenerTest |
protected boolean |
isMirrored |
protected boolean |
isSerialExecution |
boolean |
listenerInstalled |
protected static int |
LOCAL_DESTROY_OPERATION |
protected static int |
LOCAL_INVALIDATE_OPERATION |
protected static String |
LOCK_NAME |
protected static String |
LOCK_SERVICE_NAME |
protected int |
lowerThreshold |
protected int |
maxObjects |
protected int |
maxRegions |
protected static String |
memberIdString |
static int |
MILLIS_TO_WAIT |
protected long |
minTaskGranularityMS |
protected long |
minTaskGranularitySec |
protected int |
numVMs |
protected static String |
PR_NAME_PREFIX |
protected static int |
PUT_IF_ABSENT_OPERATION |
protected static int |
PUTALL_OPERATION |
protected Random |
rand |
protected RandomValues |
randomValues |
protected static int |
READ_OPERATION |
protected static int |
REGION_CLOSE_OPERATION |
protected static String |
regionDestroyCallbackPrefix |
protected static String |
regionInvalidateCallbackPrefix |
String |
regionName |
protected static int |
REMOVE_OPERATION |
protected static int |
REPLACE_OPERATION |
protected static int |
UPDATE_OPERATION |
protected static String |
updateCallbackPrefix |
protected int |
upperThreshold |
protected boolean |
useCounters |
protected boolean |
useEvictionController |
protected boolean |
useTransactions |
protected static String |
VmIDStr |
| Constructor and Description |
|---|
EventTest() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addObject(com.gemstone.gemfire.cache.Region aRegion,
boolean logAddition) |
protected void |
addRegion()
Creates a new subregion of a randomly-selected parent region
(which could be the root region).
|
protected void |
addRegion(com.gemstone.gemfire.cache.Region parentRegion)
addRegion - adds a subregion beneath the given region
|
protected void |
addToRegion()
Random choose a region and add an object to it for the duration
of minTaskGranularity hydra param
|
protected void |
checkEventCounters()
Must overridden in a subclass
|
protected int |
clearRegion() |
protected int |
clearRegion(com.gemstone.gemfire.cache.Region aRegion)
Perform clear on targeted region, verify all VMs receive clearRegion event
|
protected int |
closeRegion()
Close a random region.
|
protected int |
closeRegion(com.gemstone.gemfire.cache.Region aRegion) |
protected void |
createRootRegions()
Creates the root region in the
Cache used in this test
according to the configuration in a RegionDefinition. |
protected void |
destroyObject(com.gemstone.gemfire.cache.Region aRegion,
boolean isLocalDestroy) |
protected int |
destroyRegion(boolean isLocalDestroy)
Destroys a random region.
|
protected int |
destroyRegion(boolean isLocalDestroy,
com.gemstone.gemfire.cache.Region aRegion) |
protected void |
doEntryOperations(com.gemstone.gemfire.cache.Region aRegion) |
protected void |
doRegionOperations() |
protected int |
faultInNewRegions()
Find regions created during the test (in any cache) using the
EventBB and create those regions in this cache also. |
protected Object[] |
faultInRegion(com.gemstone.gemfire.cache.Region parentRegion,
String newRegionName,
com.gemstone.gemfire.cache.RegionAttributes attr)
Create a region in this cache, which was previously created in another cache.
|
protected com.gemstone.gemfire.cache.CacheListener |
getCacheListener()
Returns the
CacheListener that is installed on
regions created by this test. |
protected int |
getNumNames(com.gemstone.gemfire.cache.Region aRegion,
boolean hasValueOnly)
Given a region, return the number of names in the region and any
of its subregions.
|
protected long |
getNumNonRootRegions()
Return the current number of non-root regions.
|
protected int |
getNumVMsWithListeners() |
protected Object |
getObjectToAdd(String name)
Creates a new object with the given
name to add to a
region. |
protected int |
getOperation(Long whichPrm,
boolean disallowLocalEntryOps)
Return a random operation from the hydra parameter specified by whichPrm.
|
protected Object[] |
getPartitionAttributes() |
protected com.gemstone.gemfire.cache.Region |
getRandomRegion(boolean allowRootRegion)
Return a currently existing random region.
|
protected Object |
getUpdateObject(String name)
Returns the "updated" value of the object with the given
name. |
protected void |
handleRegionDestroyedException(com.gemstone.gemfire.cache.Region aRegion,
com.gemstone.gemfire.cache.RegionDestroyedException anException)
Called when the test gets a RegionDestroyedException.
|
static void |
HydraTask_addToRegion()
Adds new entries to randomly selected regions until the
minimum task
granularity has been reached.
|
static void |
HydraTask_doEntryOperations()
Performs randomly selected operations (add, invalidate, etc.) on
the root region based on the weightings in
EventPrms.entryOperations. |
static void |
HydraTask_doRegionOperations()
Performs randomly selected operations (create new region,
invalidate an entire randomly selected region, etc.) based on the
weightings in
EventPrms.regionOperations.The operations
will continue to be performed until the minimum task granularity
has been reached. |
static void |
HydraTask_endTask() |
static void |
HydraTask_initialize()
Creates and initializes the singleton
instance of
EventTest in this VM. |
static void |
HydraTask_iterate() |
static void |
HydraTask_printBB() |
static void |
HydraTask_stopStartVMs()
Randomly stop and restart vms.
|
protected void |
initialize() |
protected void |
invalidateObject(com.gemstone.gemfire.cache.Region aRegion,
boolean isLocalInvalidate) |
protected int |
invalidateRegion(boolean isLocalInvalidate)
Invalidate a random region.
|
protected int |
invalidateRegion(boolean isLocalInvalidate,
com.gemstone.gemfire.cache.Region aRegion)
Invalidate a random region.
|
protected Object[] |
iterateRegion(com.gemstone.gemfire.cache.Region aRegion,
boolean allowZeroKeys,
boolean allowZeroNonNullValues)
Used for end task validation, iterate the keys/values in the given region,
checking that the key/value match according to the test strategy.
|
protected static void |
logExecutionNumber() |
protected void |
putIfAbsent(com.gemstone.gemfire.cache.Region aRegion,
boolean logAddition)
ConcurrentMap API testing
First round ...
|
protected void |
readObject(com.gemstone.gemfire.cache.Region aRegion)
Fetches (reads) the value of a randomly selected entry in the
given region.
|
protected void |
remove(com.gemstone.gemfire.cache.Region aRegion)
ConcurrentMap API testing
|
protected void |
replace(com.gemstone.gemfire.cache.Region aRegion)
Updates the "first" entry in a given region
|
protected void |
replace(com.gemstone.gemfire.cache.Region aRegion,
Object name)
Updates the entry with the given key (
name) in the
given region. |
protected void |
updateAllObjects(com.gemstone.gemfire.cache.Region aRegion,
Map aMap)
Updates all the objects specified in aMap in the given region.
|
protected void |
updateObject(com.gemstone.gemfire.cache.Region aRegion)
Updates the "first" entry in a given region
|
protected void |
updateObject(com.gemstone.gemfire.cache.Region aRegion,
Object name)
Updates the entry with the given key (
name) in the
given region. |
protected void |
updateObjects(com.gemstone.gemfire.cache.Region aRegion)
Updates the "first" few entries in a given region
|
protected void |
updateObjects(com.gemstone.gemfire.cache.Region aRegion,
long numObjects)
Update specified number of objects in the region.
|
protected void |
verifyObjectDestroyed(com.gemstone.gemfire.cache.Region aRegion,
Object key)
Verify that the given key in the given region is destroyed (has no key/value).
|
protected void |
verifyObjectInvalidated(com.gemstone.gemfire.cache.Region aRegion,
Object key)
Verify that the given key in the given region is invalid (has a null value).
|
protected void |
writeMyRegionNames() |
protected void |
writeMyRegionNames(com.gemstone.gemfire.cache.Region excludeRegion) |
protected static EventTest eventTest
protected static final int ADD_OPERATION
protected static final int UPDATE_OPERATION
protected static final int INVALIDATE_OPERATION
protected static final int DESTROY_OPERATION
protected static final int READ_OPERATION
protected static final int LOCAL_INVALIDATE_OPERATION
protected static final int LOCAL_DESTROY_OPERATION
protected static final int REGION_CLOSE_OPERATION
protected static final int CLEAR_OPERATION
protected static final int PUT_IF_ABSENT_OPERATION
protected static final int REMOVE_OPERATION
protected static final int REPLACE_OPERATION
protected static final int PUTALL_OPERATION
protected boolean useTransactions
protected boolean isSerialExecution
public boolean isCarefulValidation
public boolean listenerInstalled
public static final int MILLIS_TO_WAIT
protected int numVMs
protected long minTaskGranularitySec
protected long minTaskGranularityMS
protected RandomValues randomValues
protected boolean useEvictionController
protected int maxObjects
protected int maxRegions
protected com.gemstone.gemfire.distributed.DistributedLockService distLockService
protected boolean isMirrored
protected boolean isListenerTest
protected boolean useCounters
protected int lowerThreshold
protected int upperThreshold
public String regionName
protected Random rand
protected static final String createCallbackPrefix
protected static final String updateCallbackPrefix
protected static final String invalidateCallbackPrefix
protected static final String destroyCallbackPrefix
protected static final String regionInvalidateCallbackPrefix
protected static final String regionDestroyCallbackPrefix
protected static final String memberIdString
protected static final String VmIDStr
protected static String LOCK_SERVICE_NAME
protected static String LOCK_NAME
protected static final String PR_NAME_PREFIX
public static void HydraTask_initialize()
EventTest in this VM.protected void initialize()
HydraTask_initialize()public static void HydraTask_doEntryOperations()
EventPrms.entryOperations. The operations will continue to be
performed until the minimum task granularity
has been reached.public static void HydraTask_doRegionOperations()
EventPrms.regionOperations.The operations
will continue to be performed until the minimum task granularity
has been reached.public static void HydraTask_addToRegion()
public static void HydraTask_stopStartVMs()
protected void doEntryOperations(com.gemstone.gemfire.cache.Region aRegion)
HydraTask_doEntryOperations()protected void addObject(com.gemstone.gemfire.cache.Region aRegion,
boolean logAddition)
protected void putIfAbsent(com.gemstone.gemfire.cache.Region aRegion,
boolean logAddition)
protected void invalidateObject(com.gemstone.gemfire.cache.Region aRegion,
boolean isLocalInvalidate)
protected void destroyObject(com.gemstone.gemfire.cache.Region aRegion,
boolean isLocalDestroy)
protected void remove(com.gemstone.gemfire.cache.Region aRegion)
protected void updateObject(com.gemstone.gemfire.cache.Region aRegion)
protected void updateObject(com.gemstone.gemfire.cache.Region aRegion,
Object name)
name) in the
given region.protected void updateObjects(com.gemstone.gemfire.cache.Region aRegion)
protected void updateObjects(com.gemstone.gemfire.cache.Region aRegion,
long numObjects)
aRegion - numObjects - protected void updateAllObjects(com.gemstone.gemfire.cache.Region aRegion,
Map aMap)
protected void replace(com.gemstone.gemfire.cache.Region aRegion)
protected void replace(com.gemstone.gemfire.cache.Region aRegion,
Object name)
name) in the
given region.protected void readObject(com.gemstone.gemfire.cache.Region aRegion)
protected void doRegionOperations()
HydraTask_doRegionOperations()protected void addRegion()
protected void addRegion(com.gemstone.gemfire.cache.Region parentRegion)
parentRegion - - add a subregion to the region providedaddRegion()protected int invalidateRegion(boolean isLocalInvalidate)
isLocalInvalidate - true if the invalidate should be a local invalidate, false otherwise.protected int invalidateRegion(boolean isLocalInvalidate,
com.gemstone.gemfire.cache.Region aRegion)
aRegion - - region to invalidateisLocalInvalidate - true if the invalidate should be a local invalidate, false otherwise.protected int closeRegion()
protected int closeRegion(com.gemstone.gemfire.cache.Region aRegion)
protected int destroyRegion(boolean isLocalDestroy)
isLocalDestroy - true if the destroy should be a local destroy, false otherwise.protected int destroyRegion(boolean isLocalDestroy,
com.gemstone.gemfire.cache.Region aRegion)
protected int clearRegion()
protected int clearRegion(com.gemstone.gemfire.cache.Region aRegion)
aRegion - - targeted regionprotected void addToRegion()
protected int faultInNewRegions()
EventBB and create those regions in this cache also. By
doing this, a cache which did not originally create a region will
be able to invalidate or destroy it.protected Object[] faultInRegion(com.gemstone.gemfire.cache.Region parentRegion, String newRegionName, com.gemstone.gemfire.cache.RegionAttributes attr)
parentRegion - The parent region of the region to create.newRegionName - The new of the new subregion of parentRegion.attr - The region attributes for the new region.protected void checkEventCounters()
protected Object getObjectToAdd(String name)
name to add to a
region.BaseValueHolder,
RandomValuesprotected Object getUpdateObject(String name)
name.protected com.gemstone.gemfire.cache.CacheListener getCacheListener()
CacheListener that is installed on
regions created by this test.ETListenerprotected Object[] getPartitionAttributes()
protected int getNumVMsWithListeners()
protected void createRootRegions()
Cache used in this test
according to the configuration in a RegionDefinition.protected Object[] iterateRegion(com.gemstone.gemfire.cache.Region aRegion, boolean allowZeroKeys, boolean allowZeroNonNullValues)
aRegion - - the region to iterate.allowZeroKeys - - If the number of keys in the region is 0, then allow it
if this is true, otherwise log an error to the return string.allowZeroNonNullValues - - If the number of non-null values in the region
is 0, then allow it if this is true, otherwise log an error to the return
string.protected int getOperation(Long whichPrm, boolean disallowLocalEntryOps)
whichPrm - - the hydra parameter that is a list of operationsdisallowLocalEntryOps - - if true, then do not return localInvalidate
or localDestroy. This is used for regions that are mirrored, since
localInvalidate and localDestroy are disallowed for mirrored regions.protected static void logExecutionNumber()
protected void writeMyRegionNames()
protected void writeMyRegionNames(com.gemstone.gemfire.cache.Region excludeRegion)
protected com.gemstone.gemfire.cache.Region getRandomRegion(boolean allowRootRegion)
allowRootRegion - true if this call can return the root region, false otherwise.protected void handleRegionDestroyedException(com.gemstone.gemfire.cache.Region aRegion,
com.gemstone.gemfire.cache.RegionDestroyedException anException)
aRegion - - the region that supposedly was destroyed and triggered the
RegionDestroyedExceptionanException - - the exception that was thrown.protected int getNumNames(com.gemstone.gemfire.cache.Region aRegion,
boolean hasValueOnly)
aRegion - The region to use to determin the number of names.hasValueOnly - True if the number of names returned should only
include those names that return containsValueForKey true, false
if all names should be counted.protected long getNumNonRootRegions()
protected void verifyObjectInvalidated(com.gemstone.gemfire.cache.Region aRegion,
Object key)
aRegion - The region containing keykey - The key that should have a null valueprotected void verifyObjectDestroyed(com.gemstone.gemfire.cache.Region aRegion,
Object key)
aRegion - The region contains the destroyed keykey - The destroyed keyCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.