use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class IndexResource method deleteIndex.
@Path("{index-name}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
public Response deleteIndex(@PathParam("index-name") String indexName) {
File indexFile = getLogFile(indexName);
context.getExhibitor().getIndexCache().markForDeletion(indexFile);
return Response.ok(new Result("OK", true)).build();
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ConfigResource method setConfigRolling.
@Path("set-rolling")
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response setConfigRolling(String newConfigJson) throws Exception {
InstanceConfig wrapped = parseToConfig(newConfigJson);
Result result = null;
try {
PseudoLock lock = context.getExhibitor().getConfigManager().newConfigBasedLock();
try {
if (// TODO consider making configurable in the future
lock.lock(context.getExhibitor().getLog(), 10, TimeUnit.SECONDS)) {
if (context.getExhibitor().getConfigManager().startRollingConfig(wrapped, null)) {
result = new Result("OK", true);
}
}
} finally {
lock.unlock();
}
if (result == null) {
result = new Result("Another process has updated the config.", false);
}
context.getExhibitor().resetLocalConnection();
} catch (Exception e) {
result = new Result(e);
}
return Response.ok(result).build();
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ConfigResource method setConfig.
@Path("set")
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response setConfig(String newConfigJson) throws Exception {
InstanceConfig wrapped = parseToConfig(newConfigJson);
Result result = null;
try {
PseudoLock lock = context.getExhibitor().getConfigManager().newConfigBasedLock();
try {
if (// TODO consider making configurable in the future
lock.lock(context.getExhibitor().getLog(), 10, TimeUnit.SECONDS)) {
if (context.getExhibitor().getConfigManager().updateConfig(wrapped)) {
result = new Result("OK", true);
}
}
} finally {
lock.unlock();
}
if (result == null) {
result = new Result(CANT_UPDATE_CONFIG_MESSAGE, false);
}
context.getExhibitor().resetLocalConnection();
} catch (Exception e) {
result = new Result(e);
}
return Response.ok(result).build();
}
use of com.netflix.exhibitor.core.entities.Result in project exhibitor by soabase.
the class ExplorerResource method deleteNode.
@DELETE
@Path("znode/{path:.*}")
@Produces("application/json")
public Response deleteNode(@PathParam("path") String path, @HeaderParam("netflix-user-name") String trackingUserName, @HeaderParam("netflix-ticket-number") String trackingTicketNumber, @HeaderParam("netflix-reason") String trackingReason) {
Response response;
do {
path = "/" + path;
context.getExhibitor().getLog().add(ActivityLog.Type.INFO, String.format("Delete 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 {
recursivelyDelete(path);
} catch (Exception e) {
response = Response.ok(new Result(e)).build();
break;
}
response = Response.ok(new Result("OK", true)).build();
} while (false);
return response;
}
Aggregations