@Override public InstanceInfo getInstanceInfo(final String service) throws ScalerException { return realScaler.getInstanceInfo(service); }
@Override public HealthResult healthCheck() { return realScaler.healthCheck(); } }
/** * Perform a scale down operation on the service bringing it to zero instances. * * @param instances information on the current number of instances of a service * @throws ScalerException if the scaling operation fails */ private void emergencyScaleDown(final int instances) throws ScalerException { LOG.info("Triggering emergency scale down of service {} to 0 due to low system resources.", serviceRef); scaler.scaleDown(serviceRef, instances); backoff = true; }
/** * {@inheritDoc} * * If this instance is the master, perform scale up, otherwise ignore. */ @Override public void scaleUp(final String service, final int amount) throws ScalerException { if ( master.get() ) { realScaler.scaleUp(service, amount); } }
/** * Perform a scale up, taking into account the maximum number of instances limitation. * * @param instances information on the current number of instances of a service * @param amount the requested number of instances to scale up by * @throws ScalerException if the scaling operation fails */ private void scaleUp(final InstanceInfo instances, final int amount) throws ScalerException { int upTarget = Math.min(maxInstances - instances.getTotalInstances(), Math.max(0, amount)); if (instances.getInstancesStaging() == 0 && upTarget > 0) { LOG.debug("Triggering scale up of service {} by amount {}", serviceRef, amount); scaler.scaleUp(serviceRef, upTarget); backoff = true; } }
/** * {@inheritDoc} * * If this instance is the master, perform scale down, otherwise ignore. */ @Override public void scaleDown(final String service, final int amount) throws ScalerException { if ( master.get() ) { realScaler.scaleDown(service, amount); } }
InstanceInfo instances = scaler.getInstanceInfo(serviceRef); if (handleMemoryLoadIssues(instances)) { return;
/** * Perform a scale down, taking into account the minimum number of instances limitation. * * @param instances information on the current number of instances of a service * @param amount the requested number of instances to scale down by * @throws ScalerException if the scaling operation fails */ private void scaleDown(final InstanceInfo instances, final int amount) throws ScalerException { int downTarget = Math.max(0, Math.min(instances.getTotalInstances() - minInstances, Math.max(0, amount))); if (downTarget > 0) { LOG.debug("Triggering scale down of service {} by amount {}", serviceRef, downTarget); scaler.scaleDown(serviceRef, downTarget); backoff = true; } }