/**
  * Do a get on a key in region REGION_NAME. Keys to get are specified in keyIntervals.
  *
  * @return true if all keys to have get performaed have been completed.
  */
 protected boolean get() {
   SharedCounters sc = CQUtilBB.getBB().getSharedCounters();
   long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_GET);
   if (!keyIntervals.keyInRange(KeyIntervals.GET, nextKey)) {
     Log.getLogWriter().info("All gets completed; returning from get");
     return true;
   }
   Object key = NameFactory.getObjectNameForCounter(nextKey);
   Log.getLogWriter().info("Getting " + key);
   try {
     Object existingValue = aRegion.get(key);
     Log.getLogWriter()
         .info(
             "Done getting "
                 + key
                 + ", num remaining: "
                 + (keyIntervals.getLastKey(KeyIntervals.GET) - nextKey));
     if (existingValue == null)
       throw new TestException("Get of key " + key + " returned unexpected " + existingValue);
   } catch (TimeoutException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   } catch (CacheLoaderException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   }
   return (nextKey >= keyIntervals.getLastKey(KeyIntervals.GET));
 }
 /**
  * Invalidate a key in region REGION_NAME. The keys to invalidate are specified in keyIntervals.
  *
  * @return true if all keys to be invalidated have been completed.
  */
 protected boolean invalidate() {
   SharedCounters sc = CQUtilBB.getBB().getSharedCounters();
   long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_INVALIDATE);
   if (!keyIntervals.keyInRange(KeyIntervals.INVALIDATE, nextKey)) {
     Log.getLogWriter().info("All existing keys invalidated; returning from invalidate");
     return true;
   }
   Object key = NameFactory.getObjectNameForCounter(nextKey);
   Log.getLogWriter().info("Invalidating " + key);
   checkContainsValueForKey(key, true, "before invalidate");
   try {
     aRegion.invalidate(key);
     Log.getLogWriter()
         .info(
             "Done invalidating "
                 + key
                 + ", num remaining: "
                 + (keyIntervals.getLastKey(KeyIntervals.INVALIDATE) - nextKey));
   } catch (TimeoutException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   } catch (EntryNotFoundException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   }
   return (nextKey >= keyIntervals.getLastKey(KeyIntervals.INVALIDATE));
 }
 /**
  * Destroy a key in region REGION_NAME. The keys to destroy are specified in keyIntervals.
  *
  * @return true if all keys to be destroyed have been completed.
  */
 protected boolean destroy() {
   SharedCounters sc = CQUtilBB.getBB().getSharedCounters();
   long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_DESTROY);
   if (!keyIntervals.keyInRange(KeyIntervals.DESTROY, nextKey)) {
     Log.getLogWriter().info("All destroys completed; returning from destroy");
     return true;
   }
   Object key = NameFactory.getObjectNameForCounter(nextKey);
   Log.getLogWriter().info("Destroying " + key);
   checkContainsValueForKey(key, true, "before destroy");
   try {
     aRegion.destroy(key);
     Log.getLogWriter()
         .info(
             "Done Destroying "
                 + key
                 + ", num remaining: "
                 + (keyIntervals.getLastKey(KeyIntervals.DESTROY) - nextKey));
   } catch (CacheWriterException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   } catch (TimeoutException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   } catch (EntryNotFoundException e) {
     throw new TestException(TestHelper.getStackTrace(e));
   }
   return (nextKey >= keyIntervals.getLastKey(KeyIntervals.DESTROY));
 }
 /**
  * Add a new key to REGION_NAME.
  *
  * @return true if all new keys have been added (specified by CQUtilPrms.numNewKeys)
  */
 protected boolean addNewKey() {
   SharedCounters sc = CQUtilBB.getBB().getSharedCounters();
   long numNewKeysCreated = sc.incrementAndRead(CQUtilBB.NUM_NEW_KEYS_CREATED);
   if (numNewKeysCreated > numNewKeys) {
     Log.getLogWriter().info("All new keys created; returning from addNewKey");
     return true;
   }
   Object key = NameFactory.getNextPositiveObjectName();
   checkContainsValueForKey(key, false, "before addNewKey");
   QueryObject value =
       new QueryObject(
           NameFactory.getCounterForName(key), QueryObject.EQUAL_VALUES, -1, queryDepth);
   value.extra = key; // encode the key in the value for later validation
   Log.getLogWriter().info("Adding new key " + key + " with put");
   aRegion.put(key, value);
   Log.getLogWriter()
       .info(
           "Done adding new key "
               + key
               + " with put, "
               + "num remaining: "
               + (numNewKeys - numNewKeysCreated));
   return (numNewKeysCreated >= numNewKeys);
 }