Example usage for com.google.common.util.concurrent Service state

List of usage examples for com.google.common.util.concurrent Service state

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Service state.

Prototype

State state();

Source Link

Document

Returns the lifecycle state of the service.

Usage

From source file:org.invenzzia.helium.behaviors.event.StateChangeEvent.java

public final Service.State getState() {
    return this.state;
}

From source file:org.apache.twill.common.ServiceListenerAdapter.java

@Override
public void failed(Service.State from, Throwable failure) {
    // No-op
}

From source file:com.continuuity.weave.common.Services.java

/**
 * Stops a list of {@link Service} one by one. It behaves the same as
 * {@link #chainStart(com.google.common.util.concurrent.Service, com.google.common.util.concurrent.Service...)}
 * except {@link com.google.common.util.concurrent.Service#stop()} is called instead of start.
 *
 * @param firstService First service to stop.
 * @param moreServices The rest services to stop.
 * @return A {@link ListenableFuture} that will be completed when all services are stopped.
 * @see #chainStart(com.google.common.util.concurrent.Service, com.google.common.util.concurrent.Service...)
 *///from  w w  w. j  a  v  a2  s  .  c  o m
public static ListenableFuture<List<ListenableFuture<Service.State>>> chainStop(Service firstService,
        Service... moreServices) {
    return doChain(false, firstService, moreServices);
}

From source file:com.continuuity.weave.internal.ListenerExecutor.java

@Override
public void starting() {
    if (hasCalled(Service.State.STARTING)) {
        return;/*from  w ww  .  j  a v  a 2s. c  o  m*/
    }
    executor.execute(new Runnable() {
        @Override
        public void run() {
            try {
                delegate.starting();
            } catch (Throwable t) {
                LOG.warn("Exception thrown from listener", t);
            }
        }
    });
}

From source file:org.graylog.collector.services.CollectorServiceManager.java

public ImmutableMultimap<Service.State, Service> servicesByState() {
    return serviceManager.servicesByState();
}

From source file:co.cask.cdap.internal.app.runtime.ProgramControllerServiceAdapter.java

@Override
protected void doStop() throws Exception {
    if (service.state() != Service.State.TERMINATED && service.state() != Service.State.FAILED) {
        service.stopAndWait();//  w  w  w .j a  v  a  2s  .c  o m
    }
}

From source file:io.pravega.common.concurrent.ServiceShutdownListener.java

@Override
public void terminated(Service.State from) {
    if (this.terminatedCallback != null) {
        this.terminatedCallback.run();
    }//  w  w  w.  ja va 2  s .  com
}

From source file:io.pravega.common.concurrent.ServiceShutdownListener.java

@Override
public void failed(Service.State from, Throwable failure) {
    if (this.failureCallback != null) {
        this.failureCallback.accept(failure);
    }/*from  w  w w. j  ava2  s . c om*/
}

From source file:com.continuuity.weave.common.Services.java

/**
 * Performs the actual logic of chain Service start/stop.
 *///from ww w.  j  a  va 2 s . c  o m
private static ListenableFuture<List<ListenableFuture<Service.State>>> doChain(boolean doStart,
        Service firstService, Service... moreServices) {
    SettableFuture<List<ListenableFuture<Service.State>>> resultFuture = SettableFuture.create();
    List<ListenableFuture<Service.State>> result = Lists.newArrayListWithCapacity(moreServices.length + 1);

    ListenableFuture<Service.State> future = doStart ? firstService.start() : firstService.stop();
    future.addListener(
            createChainListener(future, moreServices, new AtomicInteger(0), result, resultFuture, doStart),
            Threads.SAME_THREAD_EXECUTOR);
    return resultFuture;
}

From source file:c5db.SimpleC5ModuleListener.java

@Override
public void stopping(Service.State from) {
    logger.info("Stopping module {}", module);
    onStoppingModule.run();
}