@Override protected void registerInterceptors(OperationInterceptorRegistry registry) { SchedulerPlacementZoneInterceptor.register(registry); }
public static DeferredResult<Void> handlePostOrPut(Service service, Operation op) { ResourcePoolState placementZone = op.getBody(ResourcePoolState.class); if (PlacementZoneUtil.isSchedulerPlacementZone(placementZone)) { try { AssertUtil.assertEmpty(placementZone.tagLinks, "tagLinks"); } catch (LocalizableValidationException ex) { return DeferredResult.failed(ex); } return verifyZoneContainsSingleSchedulerOrNoHost(placementZone.documentSelfLink, op, service); } else { return verifyZoneContainsNoSchedulers(placementZone.documentSelfLink, op, service); } }
/** * Registers service operation interceptors. */ protected void registerOperationInterceptors() { InUsePlacementZoneInterceptor.register(interceptors); SchedulerPlacementZoneInterceptor.register(interceptors); CompositeComponentInterceptor.register(interceptors); AuthCredentialsInterceptor.register(interceptors); UnauthorizedDeleteInterceptor.register(interceptors); ProjectInterceptor.register(interceptors); }
public static DeferredResult<Void> handlePatch(Service service, Operation op) { ResourcePoolState patchState = op.getBody(ResourcePoolState.class); Operation getOp = Operation.createGet(op.getUri()).setReferer(service.getUri()); return service.getHost().sendWithDeferredResult(getOp, ResourcePoolState.class) .thenCompose(currentState -> { AssertUtil.assertNotNull(currentState, "currentState"); ResourcePoolState rp = new ResourcePoolState(); rp.customProperties = PropertyUtils.mergeCustomProperties( currentState.customProperties, patchState.customProperties); // Now check whether the unified state is a scheduler if (PlacementZoneUtil.isSchedulerPlacementZone(rp)) { try { // shcedulers can have no tags AssertUtil.assertEmpty(currentState.tagLinks, "tagLinks"); AssertUtil.assertEmpty(patchState.tagLinks, "tagLinks"); } catch (LocalizableValidationException ex) { return DeferredResult.failed(ex); } // schedulers can have a single scheduler host at most return verifyZoneContainsSingleSchedulerOrNoHost( currentState.documentSelfLink, op, service); } else { // docker placement zones can have only docker hosts return verifyZoneContainsNoSchedulers(currentState.documentSelfLink, op, service); } }).thenAccept(ignore -> { }); }