Home | History | Annotate | Download | only in concurrent

Lines Matching defs:services

74  * A manager for monitoring and controlling a set of {@linkplain Service services}. This class
76 * {@linkplain #servicesByState inspecting} a collection of {@linkplain Service services}.
82 * services are started by some mechanism besides {@link #startAsync}, the listeners will be invoked
89 * Set<Service> services = ...;
90 * ServiceManager manager = new ServiceManager(services);
94 * // Services have been initialized and are healthy, start accepting requests...
106 * // Give the services 5 seconds to stop to ensure that we are responsive to shutdown
115 * manager.startAsync(); // start all the services asynchronously
119 * <p>This class uses the ServiceManager's methods to start all of its services, to respond to
120 * service failure and to ensure that when the JVM is shutting down all the services are stopped.
140 * A listener for the aggregate state changes of the services that are under management. Users
153 * <p>This will be called at most once after all the services have entered the
154 * {@linkplain State#RUNNING running} state. If any services fail during start up or
156 * services have started {@linkplain State#RUNNING running} then this method will not be called.
161 * Called when the all of the component services have reached a terminal state, either
182 private final ImmutableList<Service> services;
185 * Constructs a new instance for managing the given services.
187 * @param services The services to manage
189 * @throws IllegalArgumentException if not all services are {@linkplain State#NEW new} or if there
190 * are any duplicate services.
192 public ServiceManager(Iterable<? extends Service> services) {
193 ImmutableList<Service> copy = ImmutableList.copyOf(services);
195 // Having no services causes the manager to behave strangely. Notably, listeners are never
198 "ServiceManager configured with no services. Is your application configured properly?",
203 this.services = copy;
210 checkArgument(service.state() == NEW, "Can only manage NEW services, %s", service);
220 * suggested that listeners are added before any of the managed services are
247 * added before any of the managed services are {@linkplain Service#startAsync started}.
265 * Initiates service {@linkplain Service#startAsync startup} on all the services being managed.
266 * It is only valid to call this method if all of the services are {@linkplain State#NEW new}.
269 * @throws IllegalStateException if any of the Services are not {@link State#NEW new} when the
273 for (Service service : services) {
277 for (Service service : services) {
284 // all services were NEW when it was called, and this has already been verified above, so we
294 * will become healthy after all the component services have reached the {@linkplain State#RUNNING
306 * than the given time. The manager will become healthy after all the component services have
311 * @throws TimeoutException if not all of the services have finished starting within the deadline
320 * Initiates service {@linkplain Service#stopAsync shutdown} if necessary on all the services
326 for (Service service : services) {
333 * Waits for the all the services to reach a terminal state. After this method returns all
334 * services will either be {@linkplain Service.State#TERMINATED terminated} or {@linkplain
342 * Waits for the all the services to reach a terminal state for no more than the given time. After
343 * this method returns all services will either be {@linkplain Service.State#TERMINATED
348 * @throws TimeoutException if not all of the services have stopped within the deadline
355 * Returns true if all services are currently in the {@linkplain State#RUNNING running} state.
358 * get detailed information about which services are not running.
361 for (Service service : services) {
370 * Provides a snapshot of the current state of all the services under management.
373 * correspond to a point in time view of the services.
380 * Returns the service load times. This value will only return startup times for services that
383 * @return Map of services and their corresponding startup time in millis, the map entries will be
392 .add("services", Collections2.filter(services, not(instanceOf(NoOpService.class))))
425 * <p>Together, they allow us to enforce that all services have their listeners installed prior
438 * Controls how long to wait for all the services to either become healthy or reach a
443 // All services have started or some service has terminated/failed.
452 * Controls how long to wait for all services to reach a terminal state.
466 * It is implicitly assumed that all the services are NEW and that they will all remain NEW
468 * responsibility to only call {@link #markReady()} if all services were new at the time this
471 ServiceManagerState(ImmutableCollection<Service> services) {
472 this.numberOfServices = services.size();
473 servicesByState.putAll(NEW, services);
510 throw new IllegalArgumentException("Services started transitioning asynchronously before "
545 throw new TimeoutException("Timeout waiting for the services to become healthy. The "
546 + "following services have not started: "
564 throw new TimeoutException("Timeout waiting for the services to stop. The following "
565 + "services have not stopped: "
711 "Expected to be healthy after starting. The following services are not running: "
785 * ensure that the {@link ServiceManager} functions properly even when it is managing no services.