public void getSystemServices(KubernetesContext context, String appId, CompletionHandler completionHandler) { URI uri = UriUtils.buildUri(ApiUtil.systemNamespacePrefix(context, ApiUtil.API_PREFIX_V1) + getKubernetesPath(SERVICE_TYPE)); if (appId != null) { uri = UriUtils.extendUriWithQuery(uri, LABEL_SELECTOR_QUERY, String .format("%s=%s", KUBERNETES_LABEL_APP_ID, appId)); } sendRequest(Action.GET, uri, null, context, completionHandler); }
/** * Compute URI prefix for static resources of a service. * * @param klass Service class * @return String */ public static String buildUiResourceUriPrefixPath(Class<? extends Service> klass) { return UriUtils.buildUriPath(ServiceUriPaths.UI_RESOURCES, buildServicePath(klass)); }
public static String buildLogUriPath(BaseKubernetesState state, String containerName) { return UriUtils.buildUriPath(LogService.FACTORY_LINK, UriUtils.getLastPathSegment(state.documentSelfLink) + "-" + containerName); }
/** * The method makes sure that the documentSelfLink always the associated factory as the prefix. */ private String normalizeLink(String factoryLink, String documentLink) { if (UriUtils.isChildPath(documentLink, factoryLink)) { return documentLink; } String lastPathSegment = UriUtils.getLastPathSegment(documentLink); return UriUtils.buildUriPath(factoryLink, lastPathSegment); }
private void startServicesSynchronously(ServiceHost serviceHost, FactoryService factoryService, Class<? extends Service> serviceClass) throws Throwable { URI factoryUri = UriUtils.buildFactoryUri(serviceHost, this.serviceClass); Operation post = Operation.createPost(UriUtils.buildUri(serviceHost, factoryUri.getPath())); startServicesSynchronously(serviceHost, Collections.singletonList(post), Collections.singletonList(factoryService)); }
public static void start(ServiceHost host, Consumer<Operation> parentHandler) { MaintenanceProxyService s = new MaintenanceProxyService(parentHandler); String path = UriUtils.buildUriPath(ServiceUriPaths.CORE, "netty-maint-proxies", host.nextUUID()); host.startService(Operation.createPost(UriUtils.buildUri(host, path)), s); }
@Test public void getLastPathSegment() { assertEquals("example", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com/example"))); assertEquals("example", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000/example?one=1"))); assertEquals("", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000"))); assertEquals("", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000/example/"))); }
public void addPeerNode(URI ngUri) { URI hostUri = UriUtils.buildUri(ngUri.getScheme(), ngUri.getHost(), ngUri.getPort(), null, null); this.peerNodeGroups.put(hostUri, ngUri); }
@Test public void testParseUriQueryParams() { URI u = UriUtils.buildUri("http://example.com:8000/?a=b&c=d&d&e=f=g&h=&=z"); Map<String, String> queryParams = UriUtils.parseUriQueryParams(u); assertEquals(5, queryParams.size()); assertTrue(queryParams.get("a").equals("b")); assertTrue(queryParams.get("c").equals("d")); assertTrue(queryParams.get("d").equals("")); assertTrue(queryParams.get("e").equals("f=g")); assertTrue(queryParams.get("h").equals("")); }
@Override public void listContainers(CommandInput input, CompletionHandler completionHandler) { createOrUpdateTargetSsl(input); URI uri = UriUtils.extendUri(input.getDockerUri(), "/containers/json"); uri = UriUtils.extendUriWithQuery(uri, "all", "1"); logger.info("List containers: " + uri); sendGet(uri, null, completionHandler); }
/** * Builds a metric key for given resource link and timestamp. */ public static String getMetricKey(String resourceLink, Long sourceTimeMicrosUtc) { return UriUtils.getLastPathSegment(resourceLink) + SEPARATOR + + sourceTimeMicrosUtc; }
public static Map<String, String> parseUriQueryParams(URI uri) { String query = uri.getQuery(); return parseUriQueryParams(query); }
@Test public void testSimplePathParamParsing() { String template = "/vmware/offices/{location}/sites/{site}"; URI u = UriUtils.buildUri("http://example.com:8000/vmware/offices/pa/sites/prom-e"); Map<String, String> pathParams = UriUtils.parseUriPathSegments(u, template); assertEquals(2, pathParams.size()); assertTrue(pathParams.keySet().contains("location")); assertTrue(pathParams.keySet().contains("site")); assertTrue(pathParams.get("location").equals("pa")); assertTrue(pathParams.get("site").equals("prom-e")); }
/** * Starts a factory service for the given instance service class using the provided factory creator * on the factory's default URI path. * @param instServiceClass the class of the instance service * @param factoryCreator a function which creates a factory service * @return the service host */ public ServiceHost startFactory(Class<? extends Service> instServiceClass, Supplier<FactoryService> factoryCreator) { URI factoryUri = UriUtils.buildFactoryUri(this, instServiceClass); return startFactory(factoryCreator, factoryUri.getPath()); }
public static URI buildUri(URI sdUri) { return UriUtils.buildExpandLinksQueryUri(sdUri); } }
private String buildThreadTag() { if (this.host != null) { return UriUtils.extendUri(this.host.getUri(), "netty-client").toString(); } return getClass().getSimpleName() + ":" + Utils.getSystemNowMicrosUtc(); }
public static URI buildUri(URI reservationServiceLink) { return UriUtils.extendUriWithQuery(reservationServiceLink, UriUtils.URI_PARAM_ODATA_EXPAND, GroupResourcePlacementState.FIELD_NAME_RESOURCE_POOL_LINK); }
protected ContainerState createContainerWithDifferentContextId(ContainerDescription desc, String hostLink) throws Throwable { ContainerState container = createContainer(desc, hostLink); String differentContextId = UUID.randomUUID().toString(); container.compositeComponentLink = UriUtils.buildUriPath( CompositeComponentFactoryService.SELF_LINK, differentContextId); doOperation(container, UriUtils.buildUri(host, container.documentSelfLink), false, Action.PUT); return container; }
@Test public void getLastPathSegment() { assertEquals("example", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com/example"))); assertEquals("example", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000/example?one=1"))); assertEquals("", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000"))); assertEquals("", UriUtils.getLastPathSegment(UriUtils.buildUri("http://example.com:8000/example/"))); }
private List<NodeGroupState> getNodeGroupStates() { TestRequestSender sender = getTestRequestSender(); String nodeGroupPath = getNodeGroupPath(); List<Operation> nodeGroupOps = this.hosts.stream() .map(host -> UriUtils.buildUri(host.getUri(), nodeGroupPath)) .map(Operation::createGet) .collect(toList()); return sender.sendAndWait(nodeGroupOps, NodeGroupState.class); }