Search in sources :

Example 1 with SystemStatus

use of org.broadinstitute.dsde.workbench.client.sam.model.SystemStatus in project terra-cli by DataBiosphere.

the class Server method ping.

/**
 * Ping the service URLs to check their status. Return true if all return OK.
 *
 * <p>Each of the status checks in this method swallow all exceptions. This means that the CLI
 * treats all network or API exceptions when calling "/status" the same as a bad status code.
 */
public boolean ping() {
    boolean samUriSpecified = (samUri != null);
    SystemStatus samStatus = null;
    if (samUriSpecified) {
        try {
            samStatus = SamService.unauthenticated(this).getStatus();
            logger.info("SAM status: {}", samStatus);
        } catch (Exception ex) {
            logger.error("Error getting SAM status.", ex);
        }
    }
    boolean wsmUriSpecified = (workspaceManagerUri != null);
    boolean wsmStatusIsOk = true;
    if (wsmUriSpecified) {
        try {
            WorkspaceManagerService.unauthenticated(this).getStatus();
            logger.info("WSM status: {}", wsmStatusIsOk);
        } catch (Exception ex) {
            logger.error("Error getting WSM status.", ex);
            wsmStatusIsOk = false;
        }
    }
    boolean dataRepoUriSpecified = (dataRepoUri != null);
    RepositoryStatusModel tdrStatus = null;
    if (dataRepoUriSpecified) {
        try {
            tdrStatus = DataRepoService.unauthenticated(this).getStatus();
            logger.info("TDR status: {}", tdrStatus);
        } catch (Exception ex) {
            logger.error("Error getting TDR status.", ex);
        }
    }
    return (!samUriSpecified || (samStatus != null && samStatus.getOk())) && (!wsmUriSpecified || wsmStatusIsOk) && (!dataRepoUriSpecified || (tdrStatus != null && tdrStatus.isOk()));
}
Also used : SystemStatus(org.broadinstitute.dsde.workbench.client.sam.model.SystemStatus) RepositoryStatusModel(bio.terra.datarepo.model.RepositoryStatusModel) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SystemException(bio.terra.cli.exception.SystemException)

Aggregations

SystemException (bio.terra.cli.exception.SystemException)1 RepositoryStatusModel (bio.terra.datarepo.model.RepositoryStatusModel)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 SystemStatus (org.broadinstitute.dsde.workbench.client.sam.model.SystemStatus)1