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

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

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

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

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

 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: 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

 /**
  * 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: 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: 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: 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

/**
 * 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: 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

@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-cli

@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: 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: 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

/**
 * 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());
 }
}
co.cask.cdap.proto.idServiceIdgetApplication

Popular methods of ServiceId

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

Popular in Java

  • Running tasks concurrently on multiple threads
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Collectors (java.util.stream)
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • CodeWhisperer alternatives
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