コード例 #1
0
 @Override
 public void handleEvent(EventContext context) {
   timer.purge(); // Get rid of finished tasks
   if (context instanceof GarbageCollectContext) {
     GarbageCollectContext gcc = (GarbageCollectContext) context;
     if (gcc.getDelay() > 0) {
       final long delay = gcc.getDelay();
       gcc.setDelay(0);
       scheduleDGC(gcc, delay);
     } else {
       gcRunning = true;
       collector.doGC(gcc.getType());
       gcRunning = false;
       // We want to let inline gc clean stuff up (quickly) before another young/full gc happens
       garbageCollectionManager.scheduleInlineGarbageCollectionIfNecessary();
       if (gcc instanceof PeriodicGarbageCollectContext) {
         // Rearm and requeue if it's a periodic gc.
         PeriodicGarbageCollectContext pgcc = (PeriodicGarbageCollectContext) gcc;
         pgcc.reset();
         gcSink.add(pgcc);
       }
     }
   } else if (context instanceof InlineGCContext) {
     garbageCollectionManager.inlineCleanup();
   } else {
     throw new AssertionError("Unknown context type: " + context.getClass().getName());
   }
 }
コード例 #2
0
 @Override
 public synchronized void moveToPassiveStandbyState() {
   if (state == ACTIVE_COORDINATOR) {
     // TODO:: Support this later
     throw new AssertionError(
         "Cant move to " + PASSIVE_STANDBY + " from " + ACTIVE_COORDINATOR + " at least for now");
   } else if (state != PASSIVE_STANDBY) {
     stateChangeSink.add(new StateChangedEvent(state, PASSIVE_STANDBY));
     state = PASSIVE_STANDBY;
     info("Moved to " + state, true);
     fireStateChangedOperatorEvent();
   } else {
     info("Already in " + state);
   }
 }
コード例 #3
0
 private synchronized void moveToActiveState() {
   if (state == START_STATE || state == PASSIVE_STANDBY) {
     // TODO :: If state == START_STATE publish cluster ID
     debugInfo("Moving to active state");
     StateChangedEvent event = new StateChangedEvent(state, ACTIVE_COORDINATOR);
     state = ACTIVE_COORDINATOR;
     setActiveNodeID(getLocalNodeID());
     info("Becoming " + state, true);
     fireStateChangedOperatorEvent();
     electionMgr.declareWinner(this.activeNode);
     stateChangeSink.add(event);
   } else {
     throw new AssertionError("Cant move to " + ACTIVE_COORDINATOR + " from " + state);
   }
 }
コード例 #4
0
 private synchronized void moveToPassiveState(Enrollment winningEnrollment) {
   electionMgr.reset(winningEnrollment);
   if (state == START_STATE) {
     state = PASSIVE_UNINITIALIZED;
     info("Moved to " + state, true);
     fireStateChangedOperatorEvent();
     stateChangeSink.add(new StateChangedEvent(START_STATE, state));
   } else if (state == ACTIVE_COORDINATOR) {
     // TODO:: Support this later
     throw new AssertionError(
         "Cant move to "
             + PASSIVE_UNINITIALIZED
             + " from "
             + ACTIVE_COORDINATOR
             + " at least for now");
   } else {
     debugInfo(
         "Move to passive state ignored - state="
             + state
             + ", winningEnrollment: "
             + winningEnrollment);
   }
 }