public void validateState(ComputeDescription state) { Utils.validateState(getStateDescription(), state); if (state.environmentName == null) { state.environmentName = ComputeDescription.ENVIRONMENT_NAME_ON_PREMISE; } if (state.powerState == null) { state.powerState = PowerState.UNKNOWN; } validateBootAdapterReference(state); validateInstanceAdapterReference(state); }
@Override public void handlePut(Operation put) { try { ComputeDescription returnState = processInput(put); setState(put, returnState); put.complete(); } catch (Throwable t) { put.fail(t); } }
private ComputeDescription processInput(Operation op) { if (!op.hasBody()) { throw (new IllegalArgumentException("body is required")); } ComputeDescription state = op.getBody(ComputeDescription.class); validateState(state); return state; }
@Override public void handlePatch(Operation patch) { ComputeDescription patchBody = patch.getBody(ComputeDescription.class); ComputeDescription currentState = getState(patch); ResourceUtils.handlePatch(this, patch, currentState, getStateDescription(), ComputeDescription.class, op -> { boolean hasChanged = false;
@Override public void handleStart(Operation start) { try { processInput(start); start.complete(); } catch (Throwable t) { start.fail(t); } }
ComputeDescription template = (ComputeDescription) td; template.bootAdapterReference = UriUtils.buildUri(this.getHost(), "/bootAdapterReference"); template.powerAdapterReference = UriUtils.buildUri(this.getHost(), "/powerAdapterReference"); template.instanceAdapterReference = UriUtils.buildUri(this.getHost(), "/instanceAdapterReference"); template.healthAdapterReference = UriUtils.buildUri(this.getHost(), "/healthAdapterReference"); template.statsAdapterReference = UriUtils.buildUri(this.getHost(), "/statsAdapterReference"); template.statsAdapterReferences = Collections.singleton(UriUtils.buildUri( this.getHost(), "/customStatsAdapterReference")); template.enumerationAdapterReference = UriUtils.buildUri( this.getHost(), "/enumerationAdapterReference");
@Override public void handleDelete(Operation delete) { logInfo("Deleting ComputeDescription, Path: %s, Operation ID: %d, Referrer: %s", delete.getUri().getPath(), delete.getId(), delete.getRefererAsString()); super.handleDelete(delete); }
public static void startServices(ServiceHost host) throws Throwable { host.startFactory(new ComputeDescriptionService()); host.startFactory(new ComputeService()); host.startFactory(new ResourcePoolService()); host.startFactory(new ResourceDescriptionService()); host.startFactory(new DiskService()); host.startFactory(new SnapshotService()); host.startFactory(new NetworkInterfaceService()); host.startFactory(new NetworkInterfaceDescriptionService()); host.startFactory(new SubnetService()); host.startFactory(new SubnetRangeService()); host.startFactory(new IPAddressService()); host.startFactory(new ResourceGroupService()); host.startFactory(new NetworkService()); host.startFactory(new FirewallService()); host.startFactory(new SecurityGroupService()); host.startFactory(new StorageDescriptionService()); host.startFactory(new EndpointService()); host.startFactory(new ImageService()); host.startFactory(new InMemoryResourceMetricService()); host.startFactory(TagService.class, TagFactoryService::new); host.startFactory(new LoadBalancerDescriptionService()); host.startFactory(new LoadBalancerService()); host.startFactory(new RouterService()); } }
@Override public void handlePatch(Operation patch) { ComputeDescription currentState = getState(patch); ResourceUtils.handlePatch(patch, currentState, getStateDescription(), ComputeDescription.class, op -> { ComputeDescription patchBody = op.getBody(ComputeDescription.class);
@Override public void handleCreate(Operation start) { if (PhotonModelUtils.isFromMigration(start)) { start.complete(); return; } ComputeDescription state = processInput(start); state.documentCreationTimeMicros = Utils.getNowMicrosUtc(); ResourceUtils.populateTags(this, state) .whenCompleteNotify(start); }
ComputeDescription template = (ComputeDescription) td; template.bootAdapterReference = UriUtils.buildUri(this.getHost(), "/bootAdapterReference"); template.powerAdapterReference = UriUtils.buildUri(this.getHost(), "/powerAdapterReference"); template.instanceAdapterReference = UriUtils.buildUri(this.getHost(), "/instanceAdapterReference"); template.diskAdapterReference = UriUtils.buildUri(this.getHost(), "/diskAdapterReference"); template.healthAdapterReference = UriUtils.buildUri(this.getHost(), "/healthAdapterReference"); template.statsAdapterReference = UriUtils.buildUri(this.getHost(), "/statsAdapterReference"); template.statsAdapterReferences = Collections.singleton(UriUtils.buildUri( this.getHost(), "/customStatsAdapterReference")); template.enumerationAdapterReference = UriUtils.buildUri( this.getHost(), "/enumerationAdapterReference");
public void validateState(ComputeDescription state) { Utils.validateState(getStateDescription(), state); if (state.environmentName == null) { state.environmentName = ComputeDescription.ENVIRONMENT_NAME_ON_PREMISE; } if (state.powerState == null) { state.powerState = PowerState.UNKNOWN; } validateBootAdapterReference(state); validateInstanceAdapterReference(state); }
@Override public void handlePut(Operation put) { if (PhotonModelUtils.isFromMigration(put)) { super.handlePut(put); return; } ComputeDescription returnState = processInput(put); ResourceUtils.populateTags(this, returnState) .thenAccept(__ -> setState(put, returnState)) .whenCompleteNotify(put); }
private ComputeDescription processInput(Operation op) { if (!op.hasBody()) { throw (new IllegalArgumentException("body is required")); } ComputeDescription state = op.getBody(ComputeDescription.class); validateState(state); return state; }