예제 #1
0
 /**
  * Atomically increment a counter in the ControllerBB sharedMap.
  *
  * @param keyBase A string from ControllerBB that prefixes a vm id to use as a key in the
  *     ControllerBB shared map. The VM id used is the current vm's id.
  */
 public static void incMapCounter(String keyBase) {
   String key = keyBase + RemoteTestModule.getMyVmid();
   Log.getLogWriter().info("Incrementing sharedMap counter " + key);
   SharedLock slock = ControllerBB.getBB().getSharedLock();
   slock.lock();
   try {
     int newValue = 0;
     Object value = ControllerBB.getBB().getSharedMap().get(key);
     if (value == null) {
       newValue = 1;
     } else {
       newValue = ((Integer) value).intValue() + 1;
     }
     ControllerBB.getBB().getSharedMap().put(key, new Integer(newValue));
     Log.getLogWriter().info("Incremented sharedMap counter, count is now " + newValue);
   } finally {
     slock.unlock();
   }
 }