/** * Use this method to start the set of services synchronously. */ public static void startServicesSynchronously( ServiceHost host, ServiceMetadata[] servicesMetadata) { startServicesSynchronously(host, tryAddPrivilegedService(host), servicesMetadata); }
/** * Creates meta-data for a {@link FactoryService}. * * @return cached ServiceMetadata */ public static ServiceMetadata factoryService(Class<? extends Service> serviceClass) { return factoryService(serviceClass, null /* factoryCreator */); }
private ServiceMetadata( boolean isFactory, Class<? extends Service> serviceClass, Supplier<FactoryService> factoryCreator) { this.isFactory = isFactory; this.serviceClass = serviceClass; this.factoryCreator = factoryCreator; // Calculate and cache the link this.link = initLink(); }
public static void startServices(ServiceHost host, boolean isSynchronousStart) throws Throwable { if (isSynchronousStart) { StartServicesHelper.startServicesSynchronously(host, SERVICES_METADATA); } else { StartServicesHelper.startServices(host, SERVICES_METADATA); } } }
/** * Use this method to start the set of services asynchronously. * * @see com.vmware.photon.controller.model.PhotonModelServices#startServices(ServiceHost) */ public static DeferredResult<Void> startServices(ServiceHost host, ServiceMetadata[] servicesMetadata) { return startServices(host, tryAddPrivilegedService(host), servicesMetadata); }
private void setMaxPossibleIpCountInSubnet(IPAddressAllocationContext context) { List<SubnetRangeState> subnetRangeStates = context.subnetRangeStates; int maxIps = 0; for (SubnetRangeState subnetRangeState : subnetRangeStates) { Long startIP = IpHelper.ipStringToLong(subnetRangeState.startIPAddress); Long endIP = IpHelper.ipStringToLong(subnetRangeState.endIPAddress); maxIps = maxIps + (int) (endIP - startIP) + 1; } context.maxPossibleIpsCount = maxIps; }
private void validate(ResourceOperationSpec body, String referer) { AssertUtil.assertTrue(body.name == null, "Cannot override 'name'. Referer: " + referer); AssertUtil.assertTrue(body.description == null, "Cannot override 'description'. Referer: " + referer); AssertUtil.assertTrue(body.adapterReference == null, "Cannot override 'adapterReference'. Referer: " + referer); AssertUtil.assertTrue(body.targetCriteria == null, "Cannot override 'targetCriteria'. Referer: " + referer); AssertUtil.assertTrue(body.schema == null, "Cannot override 'schema'. Referer: " + referer); } }
public SchemaFieldBuilder withDataType(String dataType) { AssertUtil.assertNotEmpty(dataType, "'dataType' cannot be null."); this.field.dataType = dataType; return this; }
/** * Set custom referrer to use for REST operations. * <p> * Default value, if not set, is {@code host.getUri()}. Callers are recommended to set more * pertinent value for better traceability, e.g {@link Service#getUri()}. */ public void setReferer(URI referer) { AssertUtil.assertNotNull(referer, "'referer' must be set."); this.referer = referer; }
/** * There's no guarantee that's the actual Xenon service being run. That's just a Java * instance of this service class most commonly used to call {@link Service#getStateType()}. */ public Service serviceInstance() { // Every call MUST return new service instance cause the same service // might be run on two hosts return newServiceInstance(); }
public static void startServices(ServiceHost host, boolean isSynchronousStart) throws Throwable { if (isSynchronousStart) { StartServicesHelper.startServicesSynchronously(host, SERVICES_METADATA); } else { StartServicesHelper.startServices(host, SERVICES_METADATA); } } }
/** * Use this method to start the set of services synchronously. */ public static void startServicesSynchronously( ServiceHost host, ServiceMetadata[] servicesMetadata) { startServicesSynchronously(host, tryAddPrivilegedService(host), servicesMetadata); }
/** * Use this method to start the set of services asynchronously. * * @see com.vmware.photon.controller.model.PhotonModelServices#startServices(ServiceHost) */ public static void startServices(ServiceHost host, ServiceMetadata[] servicesMetadata) { startServices(host, tryAddPrivilegedService(host), servicesMetadata); }
private int getMaxPossibleIpCountInSubnet( List<SubnetRangeService.SubnetRangeState> subnetRangeStates) { int maxIps = 0; for (SubnetRangeService.SubnetRangeState subnetRangeState : subnetRangeStates) { Long startIP = IpHelper.ipStringToLong(subnetRangeState.startIPAddress); Long endIP = IpHelper.ipStringToLong(subnetRangeState.endIPAddress); maxIps = maxIps + (int) (endIP - startIP) + 1; } return maxIps; }
/** * Sets the {@code jitterFactor} to randomly vary retry delays by. For each retry delay, a random portion of the delay * multiplied by the {@code jitterFactor} will be added or subtracted to the delay. For example: a retry delay of * {@code 100} milliseconds and a {@code jitterFactor} of {@code .25} will result in a random retry delay between * {@code 75} and {@code 125} milliseconds. */ public RetryPolicy withJitter(double jitterFactor) { AssertUtil.assertTrue(jitterFactor >= 0.0 && jitterFactor <= 1.0, "jitterFactor must be >= 0 and <= 1"); AssertUtil.assertTrue(this.delay != null, "A delay must be configured"); AssertUtil.assertTrue(this.jitter == null, "withJitter(long, timeUnit) has already been called"); this.jitterFactor = jitterFactor; return this; }
/** * Creates meta-data for a {@link FactoryService}. * * @return cached ServiceMetadata */ public static ServiceMetadata factoryService(Class<? extends Service> serviceClass) { return factoryService(serviceClass, null /* factoryCreator */); }
private ServiceMetadata( boolean isFactory, Class<? extends Service> serviceClass, Supplier<FactoryService> factoryCreator) { this.isFactory = isFactory; this.serviceClass = serviceClass; this.factoryCreator = factoryCreator; // Calculate and cache the link this.link = initLink(); }
public SchemaFieldBuilder withDataType(String dataType) { AssertUtil.assertNotEmpty(dataType, "'dataType' cannot be null."); this.field.dataType = dataType; return this; }
public static void startServices(ServiceHost host, boolean isSynchronousStart) throws Throwable { if (isSynchronousStart) { StartServicesHelper.startServicesSynchronously(host, SERVICES_METADATA); } else { StartServicesHelper.startServices(host, SERVICES_METADATA); } } }
/** * Sets the {@code delay} between retries, exponentially backing off to the {@code maxDelay} and multiplying * successive delays by the {@code delayFactor}. * * @throws NullPointerException if {@code timeUnit} is null * @throws IllegalArgumentException if {@code delay} <= 0, {@code delay} is >= {@code maxDelay}, or the * {@code delayFactor} is <= 1 * maxDuration}, if delays have already been set, or if random delays have already been set */ public RetryPolicy withBackoff(double delayFactor) { AssertUtil.assertTrue(delayFactor > 1, "delayFactor must be greater than 1"); this.delayFactor = delayFactor; return this; }