这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import java.io.IOException;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.JsonEncoding;
Expand Down Expand Up @@ -113,6 +116,29 @@ public Response addEvent(String content) throws IOException {
return Response.status(responseStatus).entity(baos.toString("UTF-8")).build();
}

/**
* Gets the janitor status (e.g. to support an AWS ELB Healthcheck on an instance running JanitorMonkey).
* Creates GET /api/v1/janitor api which responds 200 OK if JanitorMonkey is running.
*
* @param uriInfo
* the uri info
* @return the chaos events json response
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@GET
public Response getJanitorStatus(@Context UriInfo uriInfo) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator gen = JSON_FACTORY.createJsonGenerator(baos, JsonEncoding.UTF8);
gen.writeStartArray();
gen.writeStartObject();
gen.writeStringField("JanitorMonkeyStatus", "OnLikeDonkeyKong");
gen.writeEndObject();
gen.writeEndArray();
gen.close();
return Response.status(Response.Status.OK).entity(baos.toString("UTF-8")).build();
}

private Response.Status optInResource(String resourceId, boolean optIn, JsonGenerator gen)
throws IOException {
String op = optIn ? "in" : "out";
Expand Down