@Override
public Void apply(AppMds mds) throws Exception {
ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
ServiceSpecification serviceSpec = getServiceSpecOrFail(id, appSpec);
RuntimeSpecification runtimeSpec = serviceSpec.getRunnables().get(runnable);
if (runtimeSpec == null) {
throw new IllegalArgumentException(String.format("Runnable not found, app: %s, service: %s, runnable %s",
id.getApplication(), id.getId(), runnable));
}
ResourceSpecification resourceSpec = replaceInstanceCount(runtimeSpec.getResourceSpecification(), count);
RuntimeSpecification newRuntimeSpec = replaceResourceSpec(runtimeSpec, resourceSpec);
Preconditions.checkNotNull(newRuntimeSpec);
ApplicationSpecification newAppSpec =
replaceServiceSpec(appSpec, id.getId(), replaceRuntimeSpec(runnable, serviceSpec, newRuntimeSpec));