use of io.mantisrx.runtime.MantisJobState in project mantis by Netflix.
the class NoOpMantisJobOperations method setWorkerMetadataWritable.
public static void setWorkerMetadataWritable(MantisWorkerMetadataWritable writable, IMantisWorkerMetadata workerMeta) {
writable.setAcceptedAt(workerMeta.getAcceptedAt());
writable.setLaunchedAt(workerMeta.getLaunchedAt());
writable.setCompletedAt(workerMeta.getCompletedAt());
writable.setStartingAt(workerMeta.getStartingAt());
writable.setStartedAt(workerMeta.getStartedAt());
writable.setCluster(workerMeta.getCluster());
writable.setSlave(workerMeta.getSlave());
writable.setSlaveID(workerMeta.getSlaveID());
Optional<WorkerPorts> wPorts = workerMeta.getPorts();
if (wPorts.isPresent()) {
WorkerPorts wP = wPorts.get();
writable.addPorts(wP.getPorts());
}
writable.setConsolePort(workerMeta.getConsolePort());
writable.setDebugPort(workerMeta.getDebugPort());
writable.setMetricsPort(workerMeta.getMetricsPort());
writable.setCustomPort(workerMeta.getCustomPort());
MantisJobState state = convertWorkerStateToMantisJobState(workerMeta.getState());
try {
switch(state) {
case Accepted:
writable.setStateNoValidation(state, workerMeta.getAcceptedAt(), workerMeta.getReason());
break;
case Launched:
writable.setStateNoValidation(state, workerMeta.getLaunchedAt(), workerMeta.getReason());
break;
case StartInitiated:
writable.setStateNoValidation(state, workerMeta.getStartingAt(), workerMeta.getReason());
break;
case Started:
writable.setStateNoValidation(state, workerMeta.getStartedAt(), workerMeta.getReason());
break;
case Failed:
writable.setStateNoValidation(state, workerMeta.getCompletedAt(), workerMeta.getReason());
break;
case Completed:
writable.setStateNoValidation(state, workerMeta.getCompletedAt(), workerMeta.getReason());
break;
default:
assert false : "Unexpected job state to set";
}
} catch (Exception e) {
throw new RuntimeException("Error converting to MantisWorkerWriteable " + e.getMessage());
}
writable.setResubmitInfo(workerMeta.getResubmitOf(), workerMeta.getTotalResubmitCount());
writable.setReason(workerMeta.getReason());
}
Aggregations