Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { doStop(); } }).build(); Entities.submit(this, task).getUnchecked();
@Override protected void doStop() { super.doStop(); // zero our workrate derived workrates. // TODO might not be enough, as policy may still be executing and have a record of historic vals; should remove policies // (also not sure we want this; implies more generally a responsibility for sensors to announce things when disconnected, // vs them just showing the last known value...) setAttribute(REQUESTS_PER_SECOND, 0D); setAttribute(AVG_REQUESTS_PER_SECOND, 0D); } }
/** @see JavaWebAppSoftwareProcessImpl#stop() */ @Override protected void doStop() { super.doStop(); // zero our workrate derived workrates. setAttribute(REQUESTS_PER_SECOND, 0D); setAttribute(AVG_REQUESTS_PER_SECOND, 0D); } }
/** * If custom behaviour is required by sub-classes, consider overriding {@link #doStop()}. */ @Override public final void stop() { // TODO There is a race where we set SERVICE_UP=false while sensor-adapter threads may still be polling. // The other thread might reset SERVICE_UP to true immediately after we set it to false here. // Deactivating adapters before setting SERVICE_UP reduces the race, and it is reduced further by setting // SERVICE_UP to false at the end of stop as well. // Perhaps we should wait until all feeds have completed here, // or do a SERVICE_STATE check before setting SERVICE_UP to true in a feed (?). if (DynamicTasks.getTaskQueuingContext() != null) { doStop(); } else { Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { doStop(); } }).build(); Entities.submit(this, task).getUnchecked(); } }