private int getSystemServiceInstanceCount(String serviceName) throws Exception { Integer count = serviceStore.getServiceInstance(serviceName); //In standalone mode, this count will be null. And thus we just return the actual instance count. if (count == null) { return serviceManagementMap.get(serviceName).getInstances(); } else { return count; } }
private int getSystemServiceInstanceCount(String serviceName) throws Exception { Integer count = serviceStore.getServiceInstance(serviceName); //In standalone mode, this count will be null. And thus we just return the actual instance count. if (count == null) { return serviceManagementMap.get(serviceName).getInstances(); } else { return count; } }
/** * Returns the number of instances of CDAP Services */ @Path("/system/services/{service-name}/instances") @GET public void getServiceInstance(HttpRequest request, HttpResponder responder, @PathParam("service-name") String serviceName) throws Exception { JsonObject reply = new JsonObject(); if (!serviceManagementMap.containsKey(serviceName)) { throw new NotFoundException(String.format("Invalid service name %s", serviceName)); } MasterServiceManager serviceManager = serviceManagementMap.get(serviceName); if (serviceManager.isServiceEnabled()) { int actualInstance = serviceManagementMap.get(serviceName).getInstances(); reply.addProperty("provisioned", actualInstance); reply.addProperty("requested", getSystemServiceInstanceCount(serviceName)); responder.sendJson(HttpResponseStatus.OK, reply.toString()); } else { throw new ForbiddenException(String.format("Service %s is not enabled", serviceName)); } }
/** * Returns the number of instances of CDAP Services */ @Path("/system/services/{service-name}/instances") @GET public void getServiceInstance(HttpRequest request, HttpResponder responder, @PathParam("service-name") String serviceName) throws Exception { JsonObject reply = new JsonObject(); if (!serviceManagementMap.containsKey(serviceName)) { throw new NotFoundException(String.format("Invalid service name %s", serviceName)); } MasterServiceManager serviceManager = serviceManagementMap.get(serviceName); if (serviceManager.isServiceEnabled()) { int actualInstance = serviceManagementMap.get(serviceName).getInstances(); reply.addProperty("provisioned", actualInstance); reply.addProperty("requested", getSystemServiceInstanceCount(serviceName)); responder.sendJson(HttpResponseStatus.OK, reply.toString()); } else { throw new ForbiddenException(String.format("Service %s is not enabled", serviceName)); } }
@Path("/system/services") @GET public void getServiceSpec(HttpRequest request, HttpResponder responder) throws Exception { List<SystemServiceMeta> response = new ArrayList<>(); SortedSet<String> services = new TreeSet<>(serviceManagementMap.keySet()); List<String> serviceList = new ArrayList<>(services); for (String service : serviceList) { MasterServiceManager serviceManager = serviceManagementMap.get(service); if (serviceManager.isServiceEnabled()) { String logs = serviceManager.isLogAvailable() ? Constants.Monitor.STATUS_OK : Constants.Monitor.STATUS_NOTOK; String canCheck = serviceManager.canCheckStatus() ? ( serviceManager.isServiceAvailable() ? STATUSOK : STATUSNOTOK) : NOTAPPLICABLE; //TODO: Add metric name for Event Rate monitoring response.add(new SystemServiceMeta(service, serviceManager.getDescription(), canCheck, logs, serviceManager.getMinInstances(), serviceManager.getMaxInstances(), getSystemServiceInstanceCount(service), serviceManager.getInstances())); } } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(response)); }
@Path("/system/services") @GET public void getServiceSpec(HttpRequest request, HttpResponder responder) throws Exception { List<SystemServiceMeta> response = new ArrayList<>(); SortedSet<String> services = new TreeSet<>(serviceManagementMap.keySet()); List<String> serviceList = new ArrayList<>(services); for (String service : serviceList) { MasterServiceManager serviceManager = serviceManagementMap.get(service); if (serviceManager.isServiceEnabled()) { String logs = serviceManager.isLogAvailable() ? Constants.Monitor.STATUS_OK : Constants.Monitor.STATUS_NOTOK; String canCheck = serviceManager.canCheckStatus() ? ( serviceManager.isServiceAvailable() ? STATUSOK : STATUSNOTOK) : NOTAPPLICABLE; //TODO: Add metric name for Event Rate monitoring response.add(new SystemServiceMeta(service, serviceManager.getDescription(), canCheck, logs, serviceManager.getMinInstances(), serviceManager.getMaxInstances(), getSystemServiceInstanceCount(service), serviceManager.getInstances())); } } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(response)); }
masterServiceManager.restartAllInstances(); } else { if (instanceId < 0 || instanceId >= masterServiceManager.getInstances()) { throw new IllegalArgumentException();
masterServiceManager.restartAllInstances(); } else { if (instanceId < 0 || instanceId >= masterServiceManager.getInstances()) { throw new IllegalArgumentException();