/** * Transition to the given state. Notice that it's possible to transition to * the same state. * @param state The state to transition into * @return New dynamicState */ public DynamicState withState(final MachineState state) { long newStartTime = Time.currentTimeMillis(); //We may (though unlikely) lose metering here if state transition is too frequent (less than a millisecond) slotMetrics.timeSpentInState.get(this.state).update(newStartTime - startTime, TimeUnit.MILLISECONDS); slotMetrics.transitionIntoState.get(state).mark(); LocalAssignment assignment = this.currentAssignment; if (MachineState.RUNNING != this.state && MachineState.RUNNING == state && this.currentAssignment instanceof TimerDecoratedAssignment) { ((TimerDecoratedAssignment) assignment).stopTiming(); //Timer is discarded after the initial launch of an assignment assignment = new LocalAssignment(this.currentAssignment); } return new DynamicState(state, this.newAssignment, this.container, assignment, this.pendingLocalization, newStartTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions, this.changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }
this.dynamicState = new DynamicState(currentAssignment, container, this.newAssignment.get(), slotMetrics); if (MachineState.RUNNING == dynamicState.state) {
@Test public void testEmptyToEmpty() throws Exception { try (SimulatedTime t = new SimulatedTime(1010)) { AsyncLocalizer localizer = mock(AsyncLocalizer.class); LocalState state = mock(LocalState.class); BlobChangingCallback cb = mock(BlobChangingCallback.class); ContainerLauncher containerLauncher = mock(ContainerLauncher.class); ISupervisor iSuper = mock(ISupervisor.class); SlotMetrics slotMetrics = new SlotMetrics(new StormMetricsRegistry()); StaticState staticState = new StaticState(localizer, 1000, 1000, 1000, 1000, containerLauncher, "localhost", 8080, iSuper, state, cb, null, null, slotMetrics); DynamicState dynamicState = new DynamicState(null, null, null, slotMetrics); DynamicState nextState = Slot.handleEmpty(dynamicState, staticState); assertEquals(MachineState.EMPTY, nextState.state); assertTrue(Time.currentTimeMillis() > 1000); } }
dynamicState = new DynamicState(currentAssignment, container, newAssignment); staticState = new StaticState(localizer, Utils.getInt(conf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS)) * 1000,
/** * Set the new assignment for the state. This should never be called from within the state machine. * It is an input from outside. * @param newAssignment the new assignment to set * @return the updated DynamicState. */ public DynamicState withNewAssignment(LocalAssignment newAssignment) { return new DynamicState(this.state, newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions); }
public DynamicState withState(final MachineState state) { long newStartTime = Time.currentTimeMillis(); return new DynamicState(state, this.newAssignment, this.container, this.currentAssignment, this.pendingLocalization, newStartTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions); }
public DynamicState withPendingLocalization(LocalAssignment pendingLocalization, Future<Void> pendingDownload) { return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, pendingLocalization, this.startTime, pendingDownload, this.profileActions, this.pendingStopProfileActions); }
public DynamicState withProfileActions(Set<TopoProfileAction> profileActions, Set<TopoProfileAction> pendingStopProfileActions) { return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, profileActions, pendingStopProfileActions); } };
public DynamicState withCurrentAssignment(final Container container, final LocalAssignment currentAssignment) { return new DynamicState(this.state, this.newAssignment, container, currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions); }
StaticState staticState = new StaticState(localizer, 5000, 120000, 1000, 1000, containerLauncher, "localhost", port, iSuper, state, cb, null, null, slotMetrics); DynamicState dynamicState = new DynamicState(cAssignment, cContainer, nAssignment, slotMetrics);
StaticState staticState = new StaticState(localizer, 5000, 120000, 1000, 1000, containerLauncher, "localhost", port, iSuper, state, cb, null, null, slotMetrics); DynamicState dynamicState = new DynamicState(null, null, null, slotMetrics) .withNewAssignment(newAssignment);
DynamicState dynamicState = new DynamicState(cAssignment, cContainer, cAssignment, slotMetrics) .withProfileActions(profileActions, Collections.<TopoProfileAction>emptySet());
StaticState staticState = new StaticState(localizer, 5000, 120000, 1000, 1000, containerLauncher, "localhost", port, iSuper, state, cb, null, null, slotMetrics); DynamicState dynamicState = new DynamicState(cAssignment, cContainer, null, slotMetrics);
StaticState staticState = new StaticState(localizer, 5000, 120000, 1000, 1000, containerLauncher, "localhost", port, iSuper, state, cb, null, null, slotMetrics); DynamicState dynamicState = new DynamicState(assignment, container, assignment, slotMetrics);
/** * Set the new assignment for the state. This should never be called from within the state machine. * It is an input from outside. * @param newAssignment the new assignment to set * @return the updated DynamicState. */ public DynamicState withNewAssignment(LocalAssignment newAssignment) { return new DynamicState(this.state, newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions, this.changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }
public DynamicState withPendingChangingBlobs(Set<Future<Void>> pendingChangingBlobs, LocalAssignment pendingChangingBlobsAssignment) { return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, profileActions, this.pendingStopProfileActions, this.changingBlobs, pendingChangingBlobs, pendingChangingBlobsAssignment, this.slotMetrics); } }
public DynamicState withCurrentAssignment(final Container container, final LocalAssignment currentAssignment) { return new DynamicState(this.state, this.newAssignment, container, currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, this.profileActions, this.pendingStopProfileActions, this.changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }
public DynamicState withPendingLocalization(LocalAssignment pendingLocalization, Future<Void> pendingDownload) { return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, pendingLocalization, this.startTime, pendingDownload, this.profileActions, this.pendingStopProfileActions, this.changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }
public DynamicState withChangingBlobs(Set<BlobChanging> changingBlobs) { if (changingBlobs == this.changingBlobs) { return this; } return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, profileActions, this.pendingStopProfileActions, changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }
public DynamicState withProfileActions(Set<TopoProfileAction> profileActions, Set<TopoProfileAction> pendingStopProfileActions) { return new DynamicState(this.state, this.newAssignment, this.container, this.currentAssignment, this.pendingLocalization, this.startTime, this.pendingDownload, profileActions, pendingStopProfileActions, this.changingBlobs, this.pendingChangingBlobs, this.pendingChangingBlobsAssignment, this.slotMetrics); }