use of com.netflix.exhibitor.core.controlpanel.ControlPanelTypes 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.controlpanel.ControlPanelTypes in project exhibitor by soabase.
the class ClusterResource method getStatus.
@Path("state")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getStatus() throws Exception {
ObjectNode mainNode = JsonNodeFactory.instance.objectNode();
ObjectNode switchesNode = JsonNodeFactory.instance.objectNode();
for (ControlPanelTypes type : ControlPanelTypes.values()) {
switchesNode.put(UIResource.fixName(type), context.getExhibitor().getControlPanelValues().isSet(type));
}
mainNode.put("switches", switchesNode);
MonitorRunningInstance monitorRunningInstance = context.getExhibitor().getMonitorRunningInstance();
InstanceStateTypes state = monitorRunningInstance.getCurrentInstanceState();
mainNode.put("state", state.getCode());
mainNode.put("description", state.getDescription());
mainNode.put("isLeader", monitorRunningInstance.isCurrentlyLeader());
return JsonUtil.writeValueAsString(mainNode);
}
use of com.netflix.exhibitor.core.controlpanel.ControlPanelTypes in project exhibitor by soabase.
the class TestMonitorRunningInstance method makeMockExhibitor.
private Exhibitor makeMockExhibitor(InstanceConfig config, String us) {
Preferences preferences = Mockito.mock(Preferences.class);
ControlPanelValues controlPanelValues = new ControlPanelValues(preferences) {
@Override
public boolean isSet(ControlPanelTypes type) throws Exception {
return true;
}
};
ConfigManager configManager = Mockito.mock(ConfigManager.class);
Mockito.when(configManager.getConfig()).thenReturn(config);
Exhibitor mockExhibitor = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS);
Mockito.when(mockExhibitor.getConfigManager()).thenReturn(configManager);
Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn(us);
Mockito.when(mockExhibitor.getControlPanelValues()).thenReturn(controlPanelValues);
return mockExhibitor;
}
Aggregations