Skip to content

Commit

Permalink
server: restore old /status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pfurio committed Apr 14, 2021
1 parent 24964e7 commit 1cd11a3
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@

package org.opencb.opencga.server.rest;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.opencb.commons.datastore.core.ObjectMap;
import org.opencb.commons.datastore.core.QueryResult;
import org.opencb.opencga.core.common.GitRepositoryState;
import org.opencb.opencga.core.common.TimeUtils;
import org.opencb.opencga.core.exception.VersionException;
import org.opencb.opencga.core.models.monitor.HealthCheckDependencies;
import org.opencb.opencga.core.models.monitor.HealthCheckDependency;
import org.opencb.opencga.core.models.monitor.HealthCheckResponse;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -36,7 +33,9 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.*;
import java.io.IOException;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Created by pfurio on 05/05/17.
Expand Down Expand Up @@ -87,7 +86,7 @@ public Response ping() {
public Response status(
@ApiParam(value = "API token for health check. When passed all of the dependencies and their status will be displayed. "
+ "The dependencies will be checked if this parameter is not used, but they won't be part of the response.")
@QueryParam("token") String token) {
@QueryParam("token") String token) {
try {
if (StringUtils.isEmpty(sessionId) && StringUtils.isNotEmpty(token)) {
sessionId = token;
Expand All @@ -106,8 +105,20 @@ public Response status(
return createErrorResponse(e);
}
}
/*name: token
description: API token for health check. When passed all of the dependencies and their status will be displayed. The dependencies will be checked if this parameter is not used, but they won't be part of the response.

* */
@GET
@Path("/status")
@ApiOperation(httpMethod = "GET", value = "Database status.")
public Response status() {
try {
QueryResult queryResult = new QueryResult();
queryResult.setId("Status");
queryResult.setDbTime(0);
HealthCheckResponse healthCheckResponse = catalogManager.healthCheck(httpServletRequest.getRequestURI(), "");
queryResult.setResult(Collections.singletonList(new ObjectMap("ok", healthCheckResponse.getComponents().contains("MongoDB"))));
return createOkResponse(queryResult);
} catch (Exception e) {
return createErrorResponse(e);
}
}
}

0 comments on commit 1cd11a3

Please sign in to comment.