public static Map<String, String> service(ServiceId serviceId) { return ImmutableMap.of( Constants.Metrics.Tag.NAMESPACE, serviceId.getNamespace(), Constants.Metrics.Tag.APP, serviceId.getApplication(), Constants.Metrics.Tag.SERVICE, serviceId.getProgram()); }
public static Map<String, String> serviceHandler(ServiceId id, String handlerId) { return ImmutableMap.of( Constants.Metrics.Tag.NAMESPACE, id.getNamespace(), Constants.Metrics.Tag.APP, id.getApplication(), Constants.Metrics.Tag.SERVICE, id.getProgram(), Constants.Metrics.Tag.HANDLER, handlerId); } }
public static Map<String, String> service(ServiceId serviceId) { return ImmutableMap.of( Constants.Metrics.Tag.NAMESPACE, serviceId.getNamespace(), Constants.Metrics.Tag.APP, serviceId.getApplication(), Constants.Metrics.Tag.SERVICE, serviceId.getProgram()); }
public static Map<String, String> serviceHandler(ServiceId id, String handlerId) { return ImmutableMap.of( Constants.Metrics.Tag.NAMESPACE, id.getNamespace(), Constants.Metrics.Tag.APP, id.getApplication(), Constants.Metrics.Tag.SERVICE, id.getProgram(), Constants.Metrics.Tag.HANDLER, handlerId); } }
public static Service fromEntityId(ServiceId serviceId) { return new Service(Id.Application.fromEntityId(serviceId.getParent()), serviceId.getProgram()); } }
public static Service fromEntityId(ServiceId serviceId) { return new Service(Id.Application.fromEntityId(serviceId.getParent()), serviceId.getProgram()); } }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE)); String appName = serviceId.getApplication(); String serviceName = serviceId.getProgram(); serviceClient.deleteRouteConfig(serviceId); output.printf("Successfully deleted route configuration of %s '%s' of application '%s'\n", ElementType.SERVICE.getName(), serviceName, appName); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE)); String appName = serviceId.getApplication(); String serviceName = serviceId.getProgram(); serviceClient.deleteRouteConfig(serviceId); output.printf("Successfully deleted route configuration of %s '%s' of application '%s'\n", ElementType.SERVICE.getName(), serviceName, appName); }
/** * Checks whether the {@link Service} is active. * * @param service ID of the service * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server * @throws NotFoundException if the app or service could not be found * @throws ServiceUnavailableException if the service is not available */ public void checkAvailability(ServiceId service) throws IOException, UnauthenticatedException, NotFoundException, ServiceUnavailableException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/versions/%s/services/%s/available", service.getApplication(), service.getVersion(), service.getProgram())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_BAD_REQUEST, HttpURLConnection.HTTP_UNAVAILABLE); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NotFoundException(service); } if (response.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) { throw new ServiceUnavailableException(service.getProgram()); } }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE)); String routeConfig = arguments.get(ArgumentName.ROUTE_CONFIG.getName()); serviceClient.storeRouteConfig(serviceId, ArgumentParser.parseStringIntegerMap( routeConfig, ArgumentName.ROUTE_CONFIG.toString())); output.printf("Successfully set route configuration of %s '%s' of application '%s' to '%s'\n", ElementType.SERVICE.getName(), serviceId.getProgram(), serviceId.getApplication(), routeConfig); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE)); String routeConfig = arguments.get(ArgumentName.ROUTE_CONFIG.getName()); serviceClient.storeRouteConfig(serviceId, ArgumentParser.parseStringIntegerMap( routeConfig, ArgumentName.ROUTE_CONFIG.toString())); output.printf("Successfully set route configuration of %s '%s' of application '%s' to '%s'\n", ElementType.SERVICE.getName(), serviceId.getProgram(), serviceId.getApplication(), routeConfig); }
/** * Sets the number of instances of a service. * * @param service the service * @param instances number of instances for the service * @throws IOException if a network error occurred * @throws NotFoundException if the application or service could not be found * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public void setServiceInstances(ServiceId service, int instances) throws IOException, NotFoundException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/services/%s/instances", service.getApplication(), service.getProgram())); HttpRequest request = HttpRequest.put(url).withBody(GSON.toJson(new Instances(instances))).build(); HttpResponse response = restClient.execute(request, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NotFoundException(service); } }
/** * Gets the number of instances of a service. * * @param service the service * @return number of instances of the service handler * @throws IOException if a network error occurred * @throws NotFoundException if the application or service could not found * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public int getServiceInstances(ServiceId service) throws IOException, NotFoundException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/services/%s/instances", service.getApplication(), service.getProgram())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NotFoundException(service); } return ObjectResponse.fromJsonBody(response, Instances.class).getResponseObject().getInstances(); }