use of com.openshift.restclient.api.capabilities.IScalable in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method scaleDeployment.
protected void scaleDeployment(ExecutionEvent event, String name, IReplicationController rc, int replicas) {
if (replicas >= 0) {
new Job(NLS.bind("Scaling {0} deployment to {1}...", name, replicas)) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
return rc.accept(new CapabilityVisitor<IScalable, IStatus>() {
@Override
public IStatus visit(IScalable capability) {
capability.scaleTo(replicas);
return Status.OK_STATUS;
}
}, new Status(Status.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Scaling is not supported for this resource"));
} catch (Exception e) {
String message = NLS.bind("Unable to scale {0}", name);
OpenShiftUIActivator.getDefault().getLogger().logError(message, e);
return new Status(Status.ERROR, OpenShiftUIActivator.PLUGIN_ID, message, e);
}
}
}.schedule();
}
}
Aggregations