All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hashicorp.nomad.javasdk.SystemApi Maven / Gradle / Ivy

There is a newer version: 0.11.3.0
Show newest version
package com.hashicorp.nomad.javasdk;


import javax.annotation.Nullable;
import java.io.IOException;

/**
 * API for performing system maintenance that shouldn't be necessary for most users,
 * exposing the functionality of the
 * {@code /v1/system/…} endpoints
 * of the Nomad HTTP API.
 */
public class SystemApi extends ApiBase {

    SystemApi(NomadApiClient apiClient) {
        super(apiClient);
    }

    /**
     * Initiates garbage collection of jobs, evals, allocations and nodes in the active region.
     *
     * @throws IOException    if there is an HTTP or lower-level problem
     * @throws NomadException if the response signals an error or cannot be deserialized
     * @see {@code PUT /v1/system/gc}
     */
    public NomadResponse garbageCollect() throws IOException, NomadException {
        return garbageCollect(null);
    }

    /**
     * Initiates garbage collection of jobs, evals, allocations and nodes
     * in the active region.
     *
     * @param options options controlling how the request is performed
     * @throws IOException    if there is an HTTP or lower-level problem
     * @throws NomadException if the response signals an error or cannot be deserialized
     * @see {@code PUT /v1/system/gc}
     */
    public NomadResponse garbageCollect(@Nullable WriteOptions options) throws IOException, NomadException {
        return executePlain(put(uri("/v1/system/gc"), options), null);
    }

    /**
     * Reconciles the summaries of all jobs in the active region.
     *
     * @throws IOException    if there is an HTTP or lower-level problem
     * @throws NomadException if the response signals an error or cannot be deserialized
     * @see {@code PUT /v1/system/reconcile/summaries}
     */
    public NomadResponse reconcileSummaries() throws IOException, NomadException {
        return reconcileSummaries(null);
    }

    /**
     * Reconciles the summaries of all jobs in the active region.
     *
     * @param options options controlling how the request is performed
     * @throws IOException    if there is an HTTP or lower-level problem
     * @throws NomadException if the response signals an error or cannot be deserialized
     * @see {@code PUT /v1/system/reconcile/summaries}
     */
    public NomadResponse reconcileSummaries(@Nullable WriteOptions options) throws IOException, NomadException {
        return executePlain(put(uri("/v1/system/reconcile/summaries"), options), null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy