public Boolean call() { return getAttribute(SERVICE_UP); }}) .run()) {
protected MachineProvisioningLocation getProvisioningLocation() { return getAttribute(PROVISIONING_LOCATION); }
public void checkModifiable() { Lifecycle state = getAttribute(SERVICE_STATE); if (getAttribute(SERVICE_STATE) == Lifecycle.RUNNING) return; if (getAttribute(SERVICE_STATE) == Lifecycle.STARTING) return; // TODO this check may be redundant or even inappropriate throw new IllegalStateException("Cannot configure entity "+this+" in state "+state); }
protected void setProvisioningLocation(MachineProvisioningLocation val) { if (getAttribute(PROVISIONING_LOCATION) != null) throw new IllegalStateException("Cannot change provisioning location: existing="+getAttribute(PROVISIONING_LOCATION)+"; new="+val); setAttribute(PROVISIONING_LOCATION, val); }
@Override public void onManagementStarted() { super.onManagementStarted(); Lifecycle state = getAttribute(SERVICE_STATE); if (state != null && state != Lifecycle.CREATED) { postRebind(); } }
@Override public void onManagementStarting() { super.onManagementStarting(); Lifecycle state = getAttribute(SERVICE_STATE); if (state == Lifecycle.RUNNING) { rebind(); } else if (state != null && state != Lifecycle.CREATED) { log.warn("On start-up of {}, not (re)binding because state is {}", this, state); } else { // Expect this is a normal start() sequence (i.e. start() will subsequently be called) setAttribute(SERVICE_UP, false); setAttribute(SERVICE_STATE, Lifecycle.CREATED); } }
DynamicTasks.queue("post-restart", new Runnable() { public void run() { postStartCustom(); if (entity().getAttribute(Attributes.SERVICE_STATE) == Lifecycle.STARTING) entity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.RUNNING); }}); }
@Override public void restart() { if (((SoftwareProcessImpl)entity()).getDriver() == null) { log.debug("restart of "+entity()+" has no driver - doing machine-level restart"); super.restart(); return; } if (Strings.isEmpty(entity().getAttribute(Attributes.HOSTNAME))) { log.debug("restart of "+entity()+" has no hostname - doing machine-level restart"); super.restart(); return; } log.debug("restart of "+entity()+" appears to have driver and hostname - doing driver-level restart"); ((SoftwareProcessImpl)entity()).getDriver().restart(); DynamicTasks.queue("post-restart", new Runnable() { public void run() { postStartCustom(); if (entity().getAttribute(Attributes.SERVICE_STATE) == Lifecycle.STARTING) entity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.RUNNING); }}); }