.withPendingLocalization(null, null); return dynamicState .withCurrentAssignment(c, dynamicState.pendingLocalization).withState(MachineState.WAITING_FOR_WORKER_START) .withPendingLocalization(null, null); } catch (TimeoutException e) {
.withPendingLocalization(dynamicState.newAssignment, pendingDownload); break;
/** * State Transitions for WAITING_FOR_BASIC_LOCALIZATION state. * PRECONDITION: neither pendingLocalization nor pendingDownload is null. * PRECONDITION: The slot should be empty * @param dynamicState current state * @param staticState static data * @return the next state * @throws Exception on any error */ static DynamicState handleWaitingForBasicLocalization(DynamicState dynamicState, StaticState staticState) throws Exception { assert(dynamicState.pendingLocalization != null); assert(dynamicState.pendingDownload != null); assert(dynamicState.container == null); //Ignore changes to scheduling while downloading the topology code // We don't support canceling the download through the future yet, // so to keep everything in sync, just wait try { dynamicState.pendingDownload.get(1000, TimeUnit.MILLISECONDS); Future<Void> pendingDownload = staticState.localizer.requestDownloadTopologyBlobs(dynamicState.pendingLocalization, staticState.port); return dynamicState.withPendingLocalization(pendingDownload).withState(MachineState.WAITING_FOR_BLOB_LOCALIZATION); } catch (TimeoutException e) { return dynamicState; } }
return dynamicState.withCurrentAssignment(c, dynamicState.pendingLocalization).withState(MachineState.WAITING_FOR_WORKER_START).withPendingLocalization(null, null); } catch (TimeoutException e) {
/** * Kill the current container and start downloading what the new assignment needs, if there is a new assignment * PRECONDITION: container != null * @param dynamicState current state * @param staticState static data * @return the next state * @throws Exception */ static DynamicState killContainerForChangedAssignment(DynamicState dynamicState, StaticState staticState) throws Exception { assert(dynamicState.container != null); staticState.iSupervisor.killedWorker(staticState.port); dynamicState.container.kill(); Future<Void> pendingDownload = null; if (dynamicState.newAssignment != null) { pendingDownload = staticState.localizer.requestDownloadBaseTopologyBlobs(dynamicState.newAssignment, staticState.port); } Time.sleep(staticState.killSleepMs); return dynamicState.withPendingLocalization(dynamicState.newAssignment, pendingDownload).withState(MachineState.KILL); }
/** * Prepare for a new assignment by downloading new required blobs, or going to empty if there is nothing to download. * PRECONDITION: The slot should be empty * @param dynamicState current state * @param staticState static data * @return the next state * @throws IOException on any error */ static DynamicState prepareForNewAssignmentNoWorkersRunning(DynamicState dynamicState, StaticState staticState) throws IOException { assert(dynamicState.container == null); if (dynamicState.newAssignment == null) { return dynamicState.withState(MachineState.EMPTY); } Future<Void> pendingDownload = staticState.localizer.requestDownloadBaseTopologyBlobs(dynamicState.newAssignment, staticState.port); return dynamicState.withPendingLocalization(dynamicState.newAssignment, pendingDownload).withState(MachineState.WAITING_FOR_BASIC_LOCALIZATION); }
public DynamicState withPendingLocalization(Future<Void> pendingDownload) { return withPendingLocalization(this.pendingLocalization, pendingDownload); }
/** * Prepare for a new assignment by downloading new required blobs, or going to empty if there is nothing to download. * PRECONDITION: The slot should be empty * @param dynamicState current state * @param staticState static data * @return the next state * @throws IOException on any error */ private static DynamicState prepareForNewAssignmentNoWorkersRunning(DynamicState dynamicState, StaticState staticState) throws IOException { assert (dynamicState.container == null); if (dynamicState.newAssignment == null) { return dynamicState.withState(MachineState.EMPTY); } Future<Void> pendingDownload = staticState.localizer.requestDownloadTopologyBlobs(dynamicState.newAssignment, staticState.port, staticState.changingCallback); return dynamicState.withPendingLocalization(dynamicState.newAssignment, pendingDownload) .withState(MachineState.WAITING_FOR_BLOB_LOCALIZATION); }
public DynamicState withPendingLocalization(Future<Void> pendingDownload) { return withPendingLocalization(this.pendingLocalization, pendingDownload); }