From 106c055744bc531d1801292ae05bffe7baf55190 Mon Sep 17 00:00:00 2001 From: "Pfifer, Justin" Date: Thu, 30 Aug 2018 08:03:18 -0700 Subject: [PATCH] Change the CoordinatorFactory deprecated methods to default Changed the CoordinatorFactory methods to be default methods. This will not require an implementer to implement the deprecated methods. Updated the documentation on the methods to indicate resolve order as a list. --- .../coordinator/CoordinatorFactory.java | 36 ++++++++++++++----- .../SchedulerCoordinatorFactory.java | 18 ---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/CoordinatorFactory.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/CoordinatorFactory.java index 09d51705..7a055bc7 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/CoordinatorFactory.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/CoordinatorFactory.java @@ -22,7 +22,7 @@ import software.amazon.kinesis.leases.ShardInfo; import software.amazon.kinesis.processor.Checkpointer; /** - * + * Used in the process of configuring and providing instances to the {@link Scheduler} */ public interface CoordinatorFactory { /** @@ -35,30 +35,48 @@ public interface CoordinatorFactory { /** * Creates GracefulShutdownCoordinator to be used by the Scheduler. * + *

Method Deprecated

*

- * Note: This method has been deprecated, and will be removed in a future release. Use the configuration in + * Note: This method has been deprecated, and will be removed in a future release. Use the configuration in * {@link CoordinatorConfig#gracefulShutdownCoordinator}. Set the - * {@link CoordinatorConfig#gracefulShutdownCoordinator} to null in order to use this method. + * {@link CoordinatorConfig#gracefulShutdownCoordinator} to null in order to use this method. *

+ *

Resolution Order

+ *
    + *
  1. {@link CoordinatorConfig#gracefulShutdownCoordinator()}
  2. + *
  3. {@link CoordinatorFactory#createGracefulShutdownCoordinator()}
  4. + *
* - * @return GracefulShutdownCoordinator + * + * @return a {@link GracefulShutdownCoordinator} that manages the process of shutting down the scheduler. */ @Deprecated - GracefulShutdownCoordinator createGracefulShutdownCoordinator(); + default GracefulShutdownCoordinator createGracefulShutdownCoordinator() { + return new GracefulShutdownCoordinator(); + } /** * Creates a WorkerStateChangeListener to be used by the Scheduler. * + *

Method Deprecated

*

- * Note: This method has been deprecated, and will be removed in a future release. Use the configuration in + * Note: This method has been deprecated, and will be removed in a future release. Use the configuration in * {@link CoordinatorConfig#workerStateChangeListener}. Set the - * {@link CoordinatorConfig#workerStateChangeListener} to null in order to use this method. + * {@link CoordinatorConfig#workerStateChangeListener} to null in order to use this method. *

* - * @return + *

Resolution Order

+ *
    + *
  1. {@link CoordinatorConfig#workerStateChangeListener()}
  2. + *
  3. {@link CoordinatorFactory#createWorkerStateChangeListener()}
  4. + *
+ * + * @return a {@link WorkerStateChangeListener} instance that will be notified for specific {@link Scheduler} steps. */ @Deprecated - WorkerStateChangeListener createWorkerStateChangeListener(); + default WorkerStateChangeListener createWorkerStateChangeListener() { + return new NoOpWorkerStateChangeListener(); + } /** * Creates a RecordProcessorChedckpointer to be used by the Scheduler. diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/SchedulerCoordinatorFactory.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/SchedulerCoordinatorFactory.java index b3aa5e4f..72f830fb 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/SchedulerCoordinatorFactory.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/coordinator/SchedulerCoordinatorFactory.java @@ -45,24 +45,6 @@ public class SchedulerCoordinatorFactory implements CoordinatorFactory { new ThreadFactoryBuilder().setNameFormat("ShardRecordProcessor-%04d").build()); } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public GracefulShutdownCoordinator createGracefulShutdownCoordinator() { - return new GracefulShutdownCoordinator(); - } - - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public WorkerStateChangeListener createWorkerStateChangeListener() { - return new NoOpWorkerStateChangeListener(); - } - static class SchedulerThreadPoolExecutor extends ThreadPoolExecutor { private static final long DEFAULT_KEEP_ALIVE = 60L; SchedulerThreadPoolExecutor(ThreadFactory threadFactory) {