Search in sources :

Example 1 with MantisJobState

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());
}
Also used : MantisJobState(io.mantisrx.runtime.MantisJobState) WorkerPorts(io.mantisrx.common.WorkerPorts) NamedJobDeleteException(io.mantisrx.server.master.store.NamedJobDeleteException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvalidNamedJobException(io.mantisrx.server.master.store.InvalidNamedJobException)

Aggregations

WorkerPorts (io.mantisrx.common.WorkerPorts)1 MantisJobState (io.mantisrx.runtime.MantisJobState)1 InvalidNamedJobException (io.mantisrx.server.master.store.InvalidNamedJobException)1 NamedJobDeleteException (io.mantisrx.server.master.store.NamedJobDeleteException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1