Tabnine Logo
ServiceId
Code IndexAdd Tabnine to your IDE (free)

How to use
ServiceId
in
co.cask.cdap.proto.id

Best Java code snippets using co.cask.cdap.proto.id.ServiceId (Showing top 20 results out of 315)

origin: co.cask.cdap/cdap-proto

public ServiceId service(String program) {
 return new ServiceId(this, program);
}
origin: caskdata/cdap

@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);
}
origin: caskdata/cdap

 /**
  * Constructs URL to reach RouteConfig REST API endpoints of a service.
  *
  * @param serviceId {@link ServiceId} of the service with the application version part ignored
  */
 private URL buildRouteConfigUrl(ServiceId serviceId)
  throws MalformedURLException {
  String path = String.format("apps/%s/services/%s/routeconfig", serviceId.getApplication(),
                serviceId.getEntityName());
  return config.resolveNamespacedURLV3(serviceId.getNamespaceId(), path);
 }
}
origin: co.cask.cdap/cdap-common

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());
}
origin: caskdata/cdap

/**
 * Gets a {@link URL} to call methods for a specific version of a {@link Service}.
 *
 * @param service {@link ServiceId} of the service
 * @return a URL to call methods of the service
 * @throws NotFoundException @throws NotFoundException if the app or service could not be found
 * @throws IOException if a network error occurred
 * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
 */
public URL getVersionedServiceURL(ServiceId service)
 throws NotFoundException, IOException, UnauthenticatedException, UnauthorizedException {
  // Make sure the service actually exists
  get(service);
  return config.resolveNamespacedURLV3(service.getNamespaceId(),
                     String.format("apps/%s/versions/%s/services/%s/methods/",
                            service.getApplication(), service.getVersion(),
                            service.getEntityName()));
}
origin: caskdata/cdap

/**
 * 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());
 }
}
origin: caskdata/cdap

/**
 * 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();
}
origin: caskdata/cdap

 public static Service fromEntityId(ServiceId serviceId) {
  return new Service(Id.Application.fromEntityId(serviceId.getParent()), serviceId.getProgram());
 }
}
origin: caskdata/cdap

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());
}
origin: caskdata/cdap

/**
 * 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);
 }
}
origin: co.cask.cdap/cdap-common

 public static Service fromEntityId(ServiceId serviceId) {
  return new Service(Id.Application.fromEntityId(serviceId.getParent()), serviceId.getProgram());
 }
}
origin: caskdata/cdap

public ServiceId service(String program) {
 return new ServiceId(this, program);
}
origin: co.cask.cdap/cdap-cli

@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);
}
origin: caskdata/cdap

 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);
 }
}
origin: caskdata/cdap

/**
 * Gets a {@link URL} to call methods for the endpoint of a {@link Service} with no application version. If multiple
 * versions exist, traffic to the {@link URL} will be distributed to each version according to routing strategy. If
 * only one version exists, this version will always be reached with the {@link URL}.
 *
 * @param service {@link ServiceId} of the service
 * @return a URL to call methods of the service
 * @throws NotFoundException @throws NotFoundException if the app or service could not be found
 * @throws IOException if a network error occurred
 * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
 */
public URL getServiceURL(ServiceId service)
 throws NotFoundException, IOException, UnauthenticatedException, UnauthorizedException {
 return config.resolveNamespacedURLV3(service.getNamespaceId(),
                    String.format("apps/%s/services/%s/methods/",
                           service.getApplication(), service.getEntityName()));
}
origin: cdapio/cdap

@Override
public ServiceManager getServiceManager(String serviceName) {
 ServiceId serviceId = new ServiceId(application, serviceName);
 return new RemoteServiceManager(serviceId, clientConfig, restClient, this);
}
origin: caskdata/cdap

@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);
}
origin: co.cask.cdap/cdap-common

 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);
 }
}
origin: caskdata/cdap

/**
 * Calls the non-versioned service endpoint for a given method and get routed to a specific version by the Router
 *
 * @param serviceId {@link ServiceId} of the service with the application version part ignored
 * @param methodPath the path specifying only the method
 * @return {@link HttpResponse} from the service method
 */
public HttpResponse callServiceMethod(ServiceId serviceId, String methodPath)
 throws IOException, UnauthorizedException, UnauthenticatedException {
 String path = String.format("apps/%s/services/%s/methods/%s", serviceId.getApplication(), serviceId.getEntityName(),
               methodPath);
 URL url = config.resolveNamespacedURLV3(serviceId.getNamespaceId(), path);
 return restClient.execute(HttpMethod.GET, url, config.getAccessToken());
}
origin: co.cask.cdap/cdap-cli

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
 ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE));
 Map<String, Integer> routeConfig = serviceClient.getRouteConfig(serviceId);
 output.printf(GSON.toJson(routeConfig));
}
co.cask.cdap.proto.idServiceId

Javadoc

Uniquely identifies a service.

Most used methods

  • <init>
  • getApplication
  • getProgram
  • getEntityName
  • getNamespace
  • getNamespaceId
  • getParent
  • getVersion
  • run
  • toMetadataEntity

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Kernel (java.awt.image)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Collectors (java.util.stream)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now