From 0bf4eda9a8648d02de94ece50916e9c9b9b49d33 Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Mon, 23 Dec 2019 16:00:32 +0100 Subject: [PATCH 1/3] instance termination plugin api --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 5 ++-- .../api/termination/TerminationListener.java | 10 +++++++ .../api/termination/TerminationService.java | 26 +++++++++++++++++++ .../TerminationServiceFactory.java | 14 ++++++++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationListener.java create mode 100644 src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java create mode 100644 src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationServiceFactory.java diff --git a/build.gradle b/build.gradle index 256b530..d91f9a5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'org.zalando' -version '3.2.1' +version '3.3.0' apply plugin: 'java' apply plugin: 'maven' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 115e6ac..2e8a4c6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Dec 23 14:08:03 CET 2019 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME \ No newline at end of file diff --git a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationListener.java b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationListener.java new file mode 100644 index 0000000..ec9ca93 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationListener.java @@ -0,0 +1,10 @@ +package org.zalando.nakadi.plugin.api.termination; + +@FunctionalInterface +public interface TerminationListener extends Runnable { + + /** + * Listener code to be executed upon arrival of termination event. + */ + void run(); +} diff --git a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java new file mode 100644 index 0000000..5dd648c --- /dev/null +++ b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java @@ -0,0 +1,26 @@ +package org.zalando.nakadi.plugin.api.termination; + +import org.zalando.nakadi.plugin.api.exceptions.PluginException; + +/** + * Termination service provides functionality to notify user about coming Nakadi instance termination. + */ +public interface TerminationService { + + /** + * Registers lister to be executed once termination event happens. + * + * @param listenerName name of the listener + * @param terminationRunnable action to execute once termination event happens + * @throws PluginException + */ + void register(final String listenerName, final TerminationListener terminationRunnable) throws PluginException; + + /** + * Removes listener by its name. + * + * @param listenerName name of the listener + * @throws PluginException + */ + void deregister(final String listenerName) throws PluginException; +} diff --git a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationServiceFactory.java b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationServiceFactory.java new file mode 100644 index 0000000..cef193f --- /dev/null +++ b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationServiceFactory.java @@ -0,0 +1,14 @@ +package org.zalando.nakadi.plugin.api.termination; + +import org.zalando.nakadi.plugin.api.SystemProperties; +import org.zalando.nakadi.plugin.api.exceptions.PluginException; + +public interface TerminationServiceFactory { + + /** + * @param properties system properties to initialize plugin + * @return constructed ApplicationService instance + * @throws PluginException if an error occurred on plugin initialization + */ + TerminationService init(SystemProperties properties) throws PluginException; +} From 481ecc950b2393e04e7e99eab9dc1cbb9b1264cc Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Mon, 23 Dec 2019 16:15:35 +0100 Subject: [PATCH 2/3] termination status --- .../nakadi/plugin/api/termination/TerminationService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java index 5dd648c..64b6aa4 100644 --- a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java +++ b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java @@ -23,4 +23,12 @@ public interface TerminationService { * @throws PluginException */ void deregister(final String listenerName) throws PluginException; + + /** + * Current status of the termination. + * + * @throws PluginException + */ + boolean isTerminating() throws PluginException; + } From ef4cde19a131996b046ee400775eb4842cfbe18e Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Mon, 23 Dec 2019 16:21:38 +0100 Subject: [PATCH 3/3] changed api to register only --- .../plugin/api/termination/TerminationService.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java index 64b6aa4..1949450 100644 --- a/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java +++ b/src/main/java/org/zalando/nakadi/plugin/api/termination/TerminationService.java @@ -10,19 +10,10 @@ public interface TerminationService { /** * Registers lister to be executed once termination event happens. * - * @param listenerName name of the listener * @param terminationRunnable action to execute once termination event happens * @throws PluginException */ - void register(final String listenerName, final TerminationListener terminationRunnable) throws PluginException; - - /** - * Removes listener by its name. - * - * @param listenerName name of the listener - * @throws PluginException - */ - void deregister(final String listenerName) throws PluginException; + void register(final TerminationListener terminationRunnable) throws PluginException; /** * Current status of the termination.