com.google.common.util.concurrent.Service.State

Here are the examples of the java api class com.google.common.util.concurrent.Service.State taken from open source projects.

1. AbstractService#checkCurrentState()

Project: guava
Source File: AbstractService.java
View license
/** Checks that the current state is equal to the expected state. */
@GuardedBy("monitor")
private void checkCurrentState(State expected) {
    State actual = state();
    if (actual != expected) {
        if (actual == FAILED) {
            // Handle this specially so that we can include the failureCause, if there is one.
            throw new IllegalStateException("Expected the service " + this + " to be " + expected + ", but the service has FAILED", failureCause());
        }
        throw new IllegalStateException("Expected the service " + this + " to be " + expected + ", but was " + actual);
    }
}

2. StreamServiceTest#assertTerminated()

Project: caliper
Source File: StreamServiceTest.java
View license
private void assertTerminated() {
    State state = service.state();
    if (state != State.TERMINATED) {
        if (state == State.FAILED) {
            throw new AssertionError(service.failureCause());
        }
        fail("Expected service to be terminated but was: " + state);
    }
}