@Override protected void postStartCustom() { entity().postDriverStart(); if (entity().connectedSensors) { // many impls aren't idempotent - though they should be! log.debug("skipping connecting sensors for "+entity()+" in driver-tasks postStartCustom because already connected (e.g. restarting)"); } else { log.debug("connecting sensors for "+entity()+" in driver-tasks postStartCustom because already connected (e.g. restarting)"); entity().connectSensors(); } entity().waitForServiceUp(); entity().postStart(); }
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); }}); }
/** * To be overridden instead of {@link #doRestart()}; sub-classes should call {@code super.doRestart()} and should * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}. */ public void doRestart() { LIFECYCLE_TASKS.restart(); } }
/** * To be overridden instead of {@link #start()}; sub-classes should call {@code super.doStart(locations)} and should * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}. */ protected void doStart(Collection<? extends Location> locations) { LIFECYCLE_TASKS.start(locations); }
/** * To be overridden instead of {@link #stop()}; sub-classes should call {@code super.doStop()} and should * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}. */ protected void doStop() { LIFECYCLE_TASKS.stop(); }
@Override protected Map<String, Object> obtainProvisioningFlags(final MachineProvisioningLocation<?> location) { return entity().obtainProvisioningFlags(location); }
@Override protected void preStartCustom(MachineLocation machine) { entity().initDriver(machine); // Note: must only apply config-sensors after adding to locations and creating driver; // otherwise can't do things like acquire free port from location, or allowing driver to set up ports super.preStartCustom(machine); ((SoftwareProcessImpl)entity()).preStart(); }
@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); }}); }
@Override protected void preStopCustom() { super.preStopCustom(); ((SoftwareProcessImpl)entity()).preStop(); }