public URI getPublicUri() { if (this.state.publicUri == null) { return getUri(); } return this.state.publicUri; }
public static URI buildUri(ServiceHost host, String path, String query, String userInfo) { URI base = host.getUri(); return UriUtils.buildUri(base.getScheme(), base.getHost(), base.getPort(), path, query, userInfo); }
private String buildThreadTag() { if (this.host != null) { return UriUtils.extendUri(this.host.getUri(), "netty-client").toString(); } return getClass().getSimpleName() + ":" + Utils.getSystemNowMicrosUtc(); }
/** * Build the URI for the auth provider host */ public static URI buildAuthProviderHostUri(ServiceHost host, String serviceLink) { URI uri = host.getStateNoCloning().authProviderHostURI; URI baseUri = uri != null ? uri : host.getUri(); return UriUtils.extendUri(baseUri, serviceLink); }
public static URI buildOperationTracingQueryUri(ServiceHost host, String selfLink, boolean doExpand, boolean includeDeleted, ServiceOption cap) { URI hostURI = UriUtils.extendUri(host.getUri(), ServiceUriPaths.CORE_OPERATION_INDEX); return buildIndexQueryUri(hostURI, selfLink, doExpand, includeDeleted, cap); }
public void stopHostAndPreserveState(ServiceHost host) { log("Stopping host %s", host.getUri()); // Do not delete the temporary directory with the lucene index. Notice that // we do not call host.tearDown(), which will delete disk state, we simply // stop the host and remove it from the peer node tracking tables host.stop(); this.peerHostIdToNodeState.remove(host.getId()); this.peerNodeGroups.remove(host.getUri()); this.localPeerHosts.remove(host.getUri()); }
private DeferredResult<Operation> patchContainerState(ContainerState cs) { Operation operation = Operation.createPatch(host, UriUtils.buildUriPath(cs.documentSelfLink)) .setBody(cs) .setReferer(host.getUri()) .setCompletion((o, ex) -> { if (ex != null) { logger.warning(String.format("Error patching container state [%s]. Error: [%s]", cs.documentSelfLink, ex.getMessage())); } }); return host.sendWithDeferredResult(operation); } }
public void stopHostAndPreserveState(ServiceHost host) { log("Stopping host %s", host.getUri()); // Do not delete the temporary directory with the lucene index. Notice that // we do not call host.tearDown(), which will delete disk state, we simply // stop the host and remove it from the peer node tracking tables host.stop(); this.peerHostIdToNodeState.remove(host.getId()); this.peerNodeGroups.remove(host.getUri()); this.localPeerHosts.remove(host.getUri()); }
public static Operation patchNicDescriptionOperation(ServiceHost host, String staticIp, String nicDescLink) { NetworkInterfaceDescription patch = new NetworkInterfaceDescription(); patch.assignment = IpAssignment.STATIC; patch.address = staticIp; return Operation.createPatch(host, nicDescLink) .setBody(patch) .setReferer(host.getUri()); }
private static DeferredResult<ProjectState> getProjectState(ServiceHost host, String projectId) { String projectSelfLink = UriUtils.buildUriPath(ProjectFactoryService.SELF_LINK, projectId); Operation getOp = Operation.createGet(host, projectSelfLink) .setReferer(host.getUri()); return host.sendWithDeferredResult(getOp, ProjectState.class); }
public static Operation patchNicStateOperation(ServiceHost host, SubnetState subnet, String staticIp, String nicLink) { NetworkInterfaceState patch = new NetworkInterfaceState(); patch.networkLink = null; patch.subnetLink = subnet.documentSelfLink; patch.address = staticIp; return (Operation.createPatch(host, nicLink) .setBody(patch) .setReferer(host.getUri())); }
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); }
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); }
private Operation buildCreateRoleOperation(RoleState state) { return Operation.createPost(getHost(), RoleService.FACTORY_LINK) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setReferer(getHost().getUri()) .setBody(state); }
private Operation buildCreateUserGroupOperation(UserGroupState state) { return Operation.createPost(getHost(), UserGroupService.FACTORY_LINK) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setReferer(getHost().getUri()) .setBody(state); }
private Operation buildCreateResourceGroupOperation(ResourceGroupState state) { return Operation.createPost(getHost(), ResourceGroupService.FACTORY_LINK) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setReferer(getHost().getUri()) .setBody(state); }
private void sendSynchRequest(URI parentUri, String documentSelfLink, CompletionHandler ch) { ServiceDocument synchState = new ServiceDocument(); synchState.documentSelfLink = documentSelfLink; Operation synchOp = Operation .createPost(this.host, parentUri.getPath()) .setBody(synchState) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_SYNCH_OWNER) .setReferer(this.host.getUri()) .setExpiration(Utils.fromNowMicrosUtc(NodeGroupService.PEER_REQUEST_TIMEOUT_MICROS)) .setCompletion((o, e) -> ch.handle(o, e)); this.host.handleRequest(null, synchOp); }
private void stopServiceAndClearFromCache(Service s, ServiceDocument state) { // Issue DELETE to stop the service and clear it from cache Operation deleteExp = Operation.createDelete(this.host, s.getSelfLink()) .setBody(state) .disableFailureLogging(true) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_NO_INDEX_UPDATE) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_NO_FORWARDING) .setReferer(this.host.getUri()); this.host.sendRequest(deleteExp); }
public static void stopContinuousQuerySubscription(TestRequestSender s, ServiceHost host, URI notificationTarget, QueryTask qt) { TestContext ctx = new TestContext(1, s.getTimeout()); Operation delete = Operation .createDelete(UriUtils.buildUri(notificationTarget, qt.documentSelfLink)) .setReferer(host.getUri()) .setCompletion(ctx.getCompletion()); host.stopSubscriptionService(delete, notificationTarget); ctx.await(); }
public static void stopContinuousQuerySubscription(TestRequestSender s, ServiceHost host, URI notificationTarget, QueryTask qt) { TestContext ctx = new TestContext(1, s.getTimeout()); Operation delete = Operation .createDelete(UriUtils.buildUri(notificationTarget, qt.documentSelfLink)) .setReferer(host.getUri()) .setCompletion(ctx.getCompletion()); host.stopSubscriptionService(delete, notificationTarget); ctx.await(); }