use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ClusterResource method setControlPanelSetting.
@Path("set/{type}/{value}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String setControlPanelSetting(@PathParam("type") String typeStr, @PathParam("value") boolean newValue) throws Exception {
ControlPanelTypes type = null;
try {
type = ControlPanelTypes.fuzzyFind(typeStr);
} catch (IllegalArgumentException ignore) {
// ignore
}
Result result;
if (type != null) {
try {
context.getExhibitor().getControlPanelValues().set(type, newValue);
result = new Result("OK", true);
} catch (Exception e) {
result = new Result(e);
}
} else {
result = new Result("Not found", false);
}
return JsonUtil.writeValueAsString(result);
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ClusterResource method stopZooKeeper.
@Path("stop")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String stopZooKeeper() throws Exception {
context.getExhibitor().getActivityQueue().add(QueueGroups.MAIN, new KillRunningInstance(context.getExhibitor(), false));
Result result = new Result("OK", true);
return JsonUtil.writeValueAsString(result);
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ClusterResource method stopStartZooKeeper.
@Path("restart")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String stopStartZooKeeper() throws Exception {
context.getExhibitor().getActivityQueue().add(QueueGroups.MAIN, new KillRunningInstance(context.getExhibitor(), true));
Result result = new Result("OK", true);
return JsonUtil.writeValueAsString(result);
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ClusterResource method startZooKeeper.
@Path("start")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String startZooKeeper() throws Exception {
context.getExhibitor().getActivityQueue().add(QueueGroups.MAIN, new StartInstance(context.getExhibitor()));
Result result = new Result("OK", true);
return JsonUtil.writeValueAsString(result);
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ExplorerResource method createNode.
@PUT
@Path("znode/{path:.*}")
@Produces("application/json")
@Consumes("application/json")
public Response createNode(@PathParam("path") String path, @HeaderParam("netflix-user-name") String trackingUserName, @HeaderParam("netflix-ticket-number") String trackingTicketNumber, @HeaderParam("netflix-reason") String trackingReason, String binaryDataStr) {
Response response;
do {
path = "/" + path;
context.getExhibitor().getLog().add(ActivityLog.Type.INFO, String.format("Create/update node request received. Path [%s], Username [%s], Ticket Number [%s], Reason [%s]", path, trackingUserName, trackingTicketNumber, trackingReason));
if (!context.getExhibitor().nodeMutationsAllowed()) {
response = Response.status(Response.Status.FORBIDDEN).build();
break;
}
try {
binaryDataStr = binaryDataStr.replace(" ", "");
byte[] data = new byte[binaryDataStr.length() / 2];
for (int i = 0; i < data.length; ++i) {
String hex = binaryDataStr.substring(i * 2, (i * 2) + 2);
int val = Integer.parseInt(hex, 16);
data[i] = (byte) (val & 0xff);
}
try {
context.getExhibitor().getLocalConnection().setData().forPath(path, data);
context.getExhibitor().getLog().add(ActivityLog.Type.INFO, String.format("createNode() updated node [%s] to data [%s]", path, binaryDataStr));
} catch (KeeperException.NoNodeException dummy) {
context.getExhibitor().getLocalConnection().create().creatingParentsIfNeeded().forPath(path, data);
context.getExhibitor().getLog().add(ActivityLog.Type.INFO, String.format("createNode() created node [%s] with data [%s]", path, binaryDataStr));
}
} catch (Exception e) {
response = Response.ok(new Result(e)).build();
break;
}
response = Response.ok(new Result("OK", true)).build();
} while (false);
return response;
}
Aggregations