Search in sources :

Example 1 with EvaluationResponse

use of com.hashicorp.nomad.javasdk.EvaluationResponse in project incubator-heron by apache.

the class NomadScheduler method startJobs.

static void startJobs(NomadApiClient apiClient, Job... jobs) {
    for (Job job : jobs) {
        LOG.fine("Starting job " + job.getId());
        LOG.fine("Job spec: " + job.toString());
        try {
            EvaluationResponse response = apiClient.getJobsApi().register(job);
            LOG.fine("response: " + response);
        } catch (IOException | NomadException e) {
            String msg = "Failed to submit job " + job.getId() + " with error: " + e.getMessage();
            LOG.log(Level.FINE, msg + " with job spec: " + job.toString());
            throw new RuntimeException(msg, e);
        }
    }
}
Also used : NomadException(com.hashicorp.nomad.javasdk.NomadException) EvaluationResponse(com.hashicorp.nomad.javasdk.EvaluationResponse) IOException(java.io.IOException) Job(com.hashicorp.nomad.apimodel.Job)

Example 2 with EvaluationResponse

use of com.hashicorp.nomad.javasdk.EvaluationResponse in project heron by twitter.

the class NomadScheduler method startJobs.

static void startJobs(NomadApiClient apiClient, Job... jobs) {
    for (Job job : jobs) {
        LOG.fine("Starting job " + job.getId());
        LOG.fine("Job spec: " + job.toString());
        try {
            EvaluationResponse response = apiClient.getJobsApi().register(job);
            LOG.fine("response: " + response);
        } catch (IOException | NomadException e) {
            String msg = "Failed to submit job " + job.getId() + " with error: " + e.getMessage();
            LOG.log(Level.FINE, msg + " with job spec: " + job.toString());
            throw new RuntimeException(msg, e);
        }
    }
}
Also used : NomadException(com.hashicorp.nomad.javasdk.NomadException) EvaluationResponse(com.hashicorp.nomad.javasdk.EvaluationResponse) IOException(java.io.IOException) Job(com.hashicorp.nomad.apimodel.Job)

Example 3 with EvaluationResponse

use of com.hashicorp.nomad.javasdk.EvaluationResponse 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)3 EvaluationResponse (com.hashicorp.nomad.javasdk.EvaluationResponse)3 NomadException (com.hashicorp.nomad.javasdk.NomadException)3 IOException (java.io.IOException)3 NomadApiClient (com.hashicorp.nomad.javasdk.NomadApiClient)1 NomadApiConfiguration (com.hashicorp.nomad.javasdk.NomadApiConfiguration)1