@Override public ServiceHost getHost() { return this.parent.getHost(); } }
@Override public ServiceHost getHost() { return this.parent.getHost(); }
public static Operation createPost(Service sender, String targetPath) { return createPost(sender.getHost(), targetPath); }
private void logTransactionUpdate(String msg) { this.service.getHost().log(Level.INFO, msg); }
public static Operation createPatch(Service sender, String targetPath) { return createPatch(sender.getHost(), targetPath); }
public static Operation createPut(Service sender, String targetPath) { return createPut(UriUtils.buildUri(sender.getHost(), targetPath)); }
public static Operation createOptions(Service sender, String targetPath) { return createOptions(UriUtils.buildUri(sender.getHost(), targetPath)); }
public static Operation createGet(Service sender, String targetPath) { return createGet(UriUtils.buildUri(sender.getHost(), targetPath)); }
public static Operation createForcedPost(Service sender, String targetPath) { return createForcedPost(UriUtils.buildUri(sender.getHost(), targetPath)); }
public static Operation createDelete(Service sender, String targetPath) { return createDelete(UriUtils.buildUri(sender.getHost(), targetPath)); }
public NodeSelectorReplicationService(Service parent) { this.parent = parent; super.setHost(parent.getHost()); super.setSelfLink(UriUtils.buildUriPath(parent.getSelfLink(), ServiceHost.SERVICE_URI_SUFFIX_REPLICATION)); if (parent.getHost().getLocation() != null) { this.nodeCountPerLocation = new ConcurrentHashMap<>(); this.locationPerNodeURI = new ConcurrentHashMap<>(); } super.setProcessingStage(ProcessingStage.AVAILABLE); }
/** * Sets a metric with unit and value in the ServiceStat associated with the service */ public static void setStat(Service service, String name, String unit, double value) { service.getHost().log(Level.INFO, "Setting stat [service=%s] [name=%s] [unit=%s] [value=%f]", service.getClass(), name, unit, value); ServiceStats.ServiceStat stat = new ServiceStats.ServiceStat(); stat.name = name; stat.unit = unit; service.setStat(stat, value); }
public void checkReplicatedServiceAvailable(CompletionHandler ch, String servicePath, String nodeSelectorPath) { Service s = this.findService(servicePath, true); if (s == null) { ch.handle(null, new IllegalStateException("service not found")); return; } String peerNodeSelectorPath = s.getPeerNodeSelectorPath(); if (peerNodeSelectorPath != null && !peerNodeSelectorPath.equals(nodeSelectorPath)) { nodeSelectorPath = peerNodeSelectorPath; } NodeGroupUtils.checkServiceAvailability(ch, s.getHost(), s.getSelfLink(), nodeSelectorPath); }
private static Operation createOperation(Service service, ResourceOperationSpec spec) { service.getHost().log(Level.FINE, "Going to register Resource Operation name=%s, operation='%s'", spec.name, spec.operation); return Operation.createPost(service, ResourceOperationSpecService.FACTORY_LINK) .setBody(spec); }
/** * Issues a GET to service/stats and looks for {@link Service#STAT_NAME_AVAILABLE} * The request is issued on the node selected as owner, by the node selector co-located * with the service. The stat must have been modified after the most recent node group * change * * This method should be used only on replicated, owner selected factory services * * For xenon based applications, use {@link ServiceHost#registerForServiceAvailability(CompletionHandler, boolean, String...)} * with boolean set to true. */ public static void checkServiceAvailability(CompletionHandler ch, Service s) { checkServiceAvailability(ch, s.getHost(), s.getSelfLink(), s.getPeerNodeSelectorPath()); }
private void logTransactionConflict(Operation request, ServiceDocument currentState) { this.service .getHost() .log(Level.INFO, "Transaction %s conflicts on service %s: operation: %s, current state transaction: %s", request.getTransactionId(), this.service.getSelfLink(), request.getAction(), currentState.documentTransactionId); }
public static DeferredResult<List<ProjectEntry>> getDirectlyAssignedProjectRolesForUser( Service requestorService, Principal principal) { return getUserState(requestorService, principal.id).thenCompose(userState -> { if ((userState == null) || (userState.userGroupLinks == null) || (userState.userGroupLinks.isEmpty())) { return DeferredResult.completed(Collections.emptyList()); } Query query = ProjectUtil.buildQueryProjectsFromGroups(userState.userGroupLinks); return new QueryByPages<>(requestorService.getHost(), query, ProjectState.class, null) .collectDocuments(Collectors.toList()) .thenApply( (projects) -> buildProjectEntries(projects, userState.userGroupLinks)); }); }
public static URI buildSessionURI(Service service, AuthorizationContext ctx) { return createInventoryUri(service.getHost(), UriUtils.buildUriPath(FACTORY_LINK, Utils.computeHash(ctx.getToken()))); }
@Override public FilterReturnCode processRequest(Operation op, OperationProcessingContext context) { context.setSuspendConsumer(o -> { this.service.getHost().run(() -> { this.service.handleRequest(op, OperationProcessingStage.EXECUTING_SERVICE_HANDLER); }); }); return FilterReturnCode.SUSPEND_PROCESSING; } }
@Override public FilterReturnCode processRequest(Operation op, OperationProcessingContext context) { context.setSuspendConsumer(o -> { this.service.getHost().run(() -> { this.service.handleRequest(op, OperationProcessingStage.EXECUTING_SERVICE_HANDLER); }); }); return FilterReturnCode.SUSPEND_PROCESSING; } }