Search in sources :

Example 6 with NomadException

use of com.hashicorp.nomad.javasdk.NomadException in project twister2 by DSC-SPIDAL.

the class NomadController method start.

@Override
public boolean start(JobAPI.Job job) {
    String uri = NomadContext.nomadSchedulerUri(config);
    NomadApiClient nomadApiClient = new NomadApiClient(new NomadApiConfiguration.Builder().setAddress(uri).build());
    Job nomadJob = getJob(job);
    try {
        EvaluationResponse response = nomadApiClient.getJobsApi().register(nomadJob);
        LOG.log(Level.INFO, "Submitted job to nomad: " + response);
    } catch (IOException | NomadException e) {
        LOG.log(Level.SEVERE, "Failed to submit the job: ", e);
    } finally {
        closeClient(nomadApiClient);
    }
    return false;
}
Also used : NomadException(com.hashicorp.nomad.javasdk.NomadException) EvaluationResponse(com.hashicorp.nomad.javasdk.EvaluationResponse) IOException(java.io.IOException) Job(com.hashicorp.nomad.apimodel.Job) NomadApiClient(com.hashicorp.nomad.javasdk.NomadApiClient) NomadApiConfiguration(com.hashicorp.nomad.javasdk.NomadApiConfiguration)

Aggregations

Job (com.hashicorp.nomad.apimodel.Job)6 NomadException (com.hashicorp.nomad.javasdk.NomadException)6 IOException (java.io.IOException)6 EvaluationResponse (com.hashicorp.nomad.javasdk.EvaluationResponse)3 JobListStub (com.hashicorp.nomad.apimodel.JobListStub)2 NomadApiClient (com.hashicorp.nomad.javasdk.NomadApiClient)2 NomadApiConfiguration (com.hashicorp.nomad.javasdk.NomadApiConfiguration)2 LinkedList (java.util.LinkedList)2