nextState = nextState.withCurrentAssignment(nextState.container, nextState.newAssignment);
staticState.containerLauncher.launchContainer(staticState.port, dynamicState.pendingLocalization, staticState.localState); return dynamicState .withCurrentAssignment(c, dynamicState.pendingLocalization).withState(MachineState.WAITING_FOR_WORKER_START) .withPendingLocalization(null, null); } catch (TimeoutException e) {
return prepareForNewAssignmentNoWorkersRunning(dynamicState.withCurrentAssignment(null, null) .withPendingChangingBlobs(Collections.emptySet(), null), staticState); staticState.localState); return dynamicState .withCurrentAssignment(c, dynamicState.pendingChangingBlobsAssignment).withState(MachineState.WAITING_FOR_WORKER_START) .withPendingChangingBlobs(Collections.emptySet(), null); } catch (TimeoutException ex) {
nextState = nextState.withCurrentAssignment(nextState.container, nextState.newAssignment);
return dynamicState.withCurrentAssignment(c, dynamicState.pendingLocalization).withState(MachineState.WAITING_FOR_WORKER_START).withPendingLocalization(null, null); } catch (TimeoutException e) {
/** * Clean up a container * PRECONDITION: All of the processes have died. * @param dynamicState current state * @param staticState static data * @param nextState the next MachineState to go to. * @return the next state. */ static DynamicState cleanupCurrentContainer(DynamicState dynamicState, StaticState staticState, MachineState nextState) throws Exception { assert(dynamicState.container != null); assert(dynamicState.currentAssignment != null); assert(dynamicState.container.areAllProcessesDead()); dynamicState.container.cleanUp(); staticState.localizer.releaseSlotFor(dynamicState.currentAssignment, staticState.port); DynamicState ret = dynamicState.withCurrentAssignment(null, null); if (nextState != null) { ret = ret.withState(nextState); } return ret; }
/** * Clean up a container. * PRECONDITION: All of the processes have died. * @param dynamicState current state * @param staticState static data * @param nextState the next MachineState to go to. * @return the next state. */ private static DynamicState cleanupCurrentContainer(DynamicState dynamicState, StaticState staticState, MachineState nextState) throws Exception { assert (dynamicState.container != null); assert (dynamicState.currentAssignment != null); assert (dynamicState.container.areAllProcessesDead()); dynamicState.container.cleanUp(); staticState.localizer.releaseSlotFor(dynamicState.currentAssignment, staticState.port); DynamicState ret = dynamicState.withCurrentAssignment(null, null); if (nextState != null) { ret = ret.withState(nextState); } return ret; }
private static DynamicState updateAssignmentIfNeeded(DynamicState dynamicState) { if (dynamicState.newAssignment != null && !dynamicState.newAssignment.equals(dynamicState.currentAssignment)) { dynamicState = dynamicState.withCurrentAssignment(dynamicState.container, dynamicState.newAssignment); } return dynamicState; }