Skip to content

Commit

Permalink
Remove @Beta from Service and ServiceManager.
Browse files Browse the repository at this point in the history
This leaves `AbstractListeningExecutorService` as `@Beta`.

Fixes #3806, #3418
Relevant to #2966

(I have tweaked Jesse's initial PR to leave `AbstractExecutionThreadService.triggerShutdown` and `AbstractService.doCancelStart` as `@Beta`, since we aren't sure we like the locking behavior of the former, and we've realized that `Listener.stopping` _might_ be a reasonable substitute for both.)

RELNOTES=`util.concurrent`: Removed `@Beta` from `Service` and related classes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=305878924
  • Loading branch information
swankjesse authored and cpovirk committed Apr 10, 2020
1 parent 9537f78 commit dc46627
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 32 deletions.
Expand Up @@ -32,7 +32,6 @@
* @author Jesse Wilson
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractExecutionThreadService implements Service {
private static final Logger logger =
Expand Down Expand Up @@ -140,7 +139,14 @@ protected void shutDown() throws Exception {}
* Invoked to request the service to stop.
*
* <p>By default this method does nothing.
*
* <p>Currently, this method is invoked while holding a lock. If an implementation of this method
* blocks, it can prevent this service from changing state. If you need to performing a blocking
* operation in order to trigger shutdown, consider instead registering a listener and
* implementing {@code stopping}. Note, however, that {@code stopping} does not run at exactly the
* same times as {@code triggerShutdown}.
*/
@Beta
protected void triggerShutdown() {}

/**
Expand Down
Expand Up @@ -14,7 +14,6 @@

package com.google.common.util.concurrent;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand All @@ -31,7 +30,6 @@
* @author Chris Nokleberg
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractIdleService implements Service {

Expand Down
Expand Up @@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand Down Expand Up @@ -94,7 +93,6 @@
* @author Luke Sandberg
* @since 11.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractScheduledService implements Service {
private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
Expand Down Expand Up @@ -440,7 +438,6 @@ public final void awaitTerminated(long timeout, TimeUnit unit) throws TimeoutExc
* @author Luke Sandberg
* @since 11.0
*/
@Beta
public abstract static class CustomScheduler extends Scheduler {

/** A callable class that can reschedule itself using a {@link CustomScheduler}. */
Expand Down Expand Up @@ -567,7 +564,6 @@ final Future<?> schedule(
* @author Luke Sandberg
* @since 11.0
*/
@Beta
protected static final class Schedule {

private final long delay;
Expand Down
Expand Up @@ -47,7 +47,6 @@
* @author Luke Sandberg
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
Expand Down Expand Up @@ -235,6 +234,7 @@ protected AbstractService() {}
*
* @since 27.0
*/
@Beta
@ForOverride
protected void doCancelStart() {}

Expand Down
Expand Up @@ -14,10 +14,9 @@

package com.google.common.util.concurrent;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -52,7 +51,6 @@
* @author Luke Sandberg
* @since 9.0 (in 1.0 as {@code com.google.common.base.Service})
*/
@Beta
@DoNotMock("Create an AbstractIdleService")
@GwtIncompatible
public interface Service {
Expand Down Expand Up @@ -175,7 +173,6 @@ public interface Service {
*
* @since 9.0 (in 1.0 as {@code com.google.common.base.Service.State})
*/
@Beta // should come out of Beta when Service does
enum State {
/** A service in this state is inactive. It does minimal work and consumes minimal resources. */
NEW {
Expand Down Expand Up @@ -243,7 +240,6 @@ boolean isTerminal() {
* @author Luke Sandberg
* @since 15.0 (present as an interface in 13.0)
*/
@Beta // should come out of Beta when Service does
abstract class Listener {
/**
* Called when the service transitions from {@linkplain State#NEW NEW} to {@linkplain
Expand Down
Expand Up @@ -118,7 +118,6 @@
* @author Luke Sandberg
* @since 14.0
*/
@Beta
@GwtIncompatible
public final class ServiceManager implements ServiceManagerBridge {
private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
Expand Down Expand Up @@ -156,7 +155,6 @@ public String toString() {
* @author Luke Sandberg
* @since 15.0 (present as an interface in 14.0)
*/
@Beta // Should come out of Beta when ServiceManager does
public abstract static class Listener {
/**
* Called when the service initially becomes healthy.
Expand Down Expand Up @@ -275,7 +273,7 @@ public void addListener(Listener listener, Executor executor) {
* {@link ListenableFuture#addListener ListenableFuture.addListener}. This method is scheduled
* for deletion in October 2020.
*/
@Beta // currently redundant, but ensures we keep this @Beta when we gradate the class!
@Beta
@Deprecated
public void addListener(Listener listener) {
state.addListener(listener, directExecutor());
Expand Down
Expand Up @@ -33,7 +33,6 @@
* @author Jesse Wilson
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractExecutionThreadService implements Service {
private static final Logger logger =
Expand Down Expand Up @@ -141,7 +140,14 @@ protected void shutDown() throws Exception {}
* Invoked to request the service to stop.
*
* <p>By default this method does nothing.
*
* <p>Currently, this method is invoked while holding a lock. If an implementation of this method
* blocks, it can prevent this service from changing state. If you need to performing a blocking
* operation in order to trigger shutdown, consider instead registering a listener and
* implementing {@code stopping}. Note, however, that {@code stopping} does not run at exactly the
* same times as {@code triggerShutdown}.
*/
@Beta
protected void triggerShutdown() {}

/**
Expand Down
Expand Up @@ -14,7 +14,6 @@

package com.google.common.util.concurrent;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand All @@ -32,7 +31,6 @@
* @author Chris Nokleberg
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractIdleService implements Service {

Expand Down
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.util.concurrent.Internal.toNanosSaturated;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand Down Expand Up @@ -96,7 +95,6 @@
* @author Luke Sandberg
* @since 11.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractScheduledService implements Service {
private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
Expand Down Expand Up @@ -481,7 +479,6 @@ public final void awaitTerminated(long timeout, TimeUnit unit) throws TimeoutExc
* @author Luke Sandberg
* @since 11.0
*/
@Beta
public abstract static class CustomScheduler extends Scheduler {

/** A callable class that can reschedule itself using a {@link CustomScheduler}. */
Expand Down Expand Up @@ -607,7 +604,6 @@ final Future<?> schedule(
* @author Luke Sandberg
* @since 11.0
*/
@Beta
protected static final class Schedule {

private final long delay;
Expand Down
Expand Up @@ -48,7 +48,6 @@
* @author Luke Sandberg
* @since 1.0
*/
@Beta
@GwtIncompatible
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
Expand Down Expand Up @@ -236,6 +235,7 @@ protected AbstractService() {}
*
* @since 27.0
*/
@Beta
@ForOverride
protected void doCancelStart() {}

Expand Down
6 changes: 1 addition & 5 deletions guava/src/com/google/common/util/concurrent/Service.java
Expand Up @@ -16,10 +16,9 @@

import static com.google.common.util.concurrent.Internal.toNanosSaturated;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.time.Duration;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -55,7 +54,6 @@
* @author Luke Sandberg
* @since 9.0 (in 1.0 as {@code com.google.common.base.Service})
*/
@Beta
@DoNotMock("Create an AbstractIdleService")
@GwtIncompatible
public interface Service {
Expand Down Expand Up @@ -206,7 +204,6 @@ default void awaitTerminated(Duration timeout) throws TimeoutException {
*
* @since 9.0 (in 1.0 as {@code com.google.common.base.Service.State})
*/
@Beta // should come out of Beta when Service does
enum State {
/** A service in this state is inactive. It does minimal work and consumes minimal resources. */
NEW {
Expand Down Expand Up @@ -274,7 +271,6 @@ boolean isTerminal() {
* @author Luke Sandberg
* @since 15.0 (present as an interface in 13.0)
*/
@Beta // should come out of Beta when Service does
abstract class Listener {
/**
* Called when the service transitions from {@linkplain State#NEW NEW} to {@linkplain
Expand Down
Expand Up @@ -120,7 +120,6 @@
* @author Luke Sandberg
* @since 14.0
*/
@Beta
@GwtIncompatible
public final class ServiceManager implements ServiceManagerBridge {
private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
Expand Down Expand Up @@ -158,7 +157,6 @@ public String toString() {
* @author Luke Sandberg
* @since 15.0 (present as an interface in 14.0)
*/
@Beta // Should come out of Beta when ServiceManager does
public abstract static class Listener {
/**
* Called when the service initially becomes healthy.
Expand Down Expand Up @@ -277,7 +275,7 @@ public void addListener(Listener listener, Executor executor) {
* {@link ListenableFuture#addListener ListenableFuture.addListener}. This method is scheduled
* for deletion in October 2020.
*/
@Beta // currently redundant, but ensures we keep this @Beta when we gradate the class!
@Beta
@Deprecated
public void addListener(Listener listener) {
state.addListener(listener, directExecutor());
Expand Down

0 comments on commit dc46627

Please sign in to comment.