From 7035c444b8913c6ea68822c194ed1df9bca8d7bb Mon Sep 17 00:00:00 2001 From: brycezhongqing Date: Thu, 17 Oct 2024 10:52:18 -0700 Subject: [PATCH] Restore the old constructor to avoid incompatible issue --- CHANGELOG.md | 6 +- .../balancer/servers/ZooKeeperAnnouncer.java | 55 +++++++++++++ .../servers/ZooKeeperConnectionManager.java | 81 +++++++++++++++++++ deprecate.sh | 8 ++ gradle.properties | 2 +- 5 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 deprecate.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index ec05a9b40d..84469b4c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [29.60.0] - 2024-10-17 +- Restore the old constructor to avoid incompatible issue + ## [29.59.0] - 2024-10-07 - Add support for announcing/deannoucing service only to INDIS @@ -5746,7 +5749,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.59.0...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.60.0...master +[29.60.0]: https://github.com/linkedin/rest.li/compare/v29.59.0...v29.60.0 [29.59.0]: https://github.com/linkedin/rest.li/compare/v29.58.11...v29.59.0 [29.58.11]: https://github.com/linkedin/rest.li/compare/v29.58.10...v29.58.11 [29.58.10]: https://github.com/linkedin/rest.li/compare/v29.58.9...v29.58.10 diff --git a/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperAnnouncer.java b/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperAnnouncer.java index 0a85e8547b..5b8d0e9729 100644 --- a/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperAnnouncer.java +++ b/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperAnnouncer.java @@ -141,16 +141,46 @@ public class ZooKeeperAnnouncer implements D2ServiceDiscoveryEventHelper // Field to store the dark warm-up time duration in seconds, defaults to zero private int _warmupDuration; + /** + * @deprecated Use the constructor {@link #ZooKeeperAnnouncer(LoadBalancerServer)} instead. + */ + @Deprecated + public ZooKeeperAnnouncer(ZooKeeperServer server) + { + this(server, true); + } + public ZooKeeperAnnouncer(LoadBalancerServer server) { this(server, true); } + /** + * @deprecated Use the constructor {@link #ZooKeeperAnnouncer(LoadBalancerServer, boolean)} instead. + */ + @Deprecated + public ZooKeeperAnnouncer(ZooKeeperServer server, boolean initialIsUp) + { + this(server, initialIsUp, DEFAULT_DARK_WARMUP_ENABLED, DEFAULT_DARK_WARMUP_CLUSTER_NAME, DEFAULT_DARK_WARMUP_DURATION, (ScheduledExecutorService) null); + } + public ZooKeeperAnnouncer(LoadBalancerServer server, boolean initialIsUp) { this(server, initialIsUp, DEFAULT_DARK_WARMUP_ENABLED, DEFAULT_DARK_WARMUP_CLUSTER_NAME, DEFAULT_DARK_WARMUP_DURATION, (ScheduledExecutorService) null); } + /** + * @deprecated Use the constructor {@link #ZooKeeperAnnouncer(LoadBalancerServer, boolean, boolean, String, int, ScheduledExecutorService)} instead. + */ + @Deprecated + public ZooKeeperAnnouncer(ZooKeeperServer server, boolean initialIsUp, + boolean isDarkWarmupEnabled, String warmupClusterName, int warmupDuration, + ScheduledExecutorService executorService) + { + this(server, initialIsUp, isDarkWarmupEnabled, warmupClusterName, warmupDuration, executorService, + new LogOnlyServiceDiscoveryEventEmitter()); // default to use log-only event emitter + } + public ZooKeeperAnnouncer(LoadBalancerServer server, boolean initialIsUp, boolean isDarkWarmupEnabled, String warmupClusterName, int warmupDuration, ScheduledExecutorService executorService) { @@ -158,6 +188,31 @@ public ZooKeeperAnnouncer(LoadBalancerServer server, boolean initialIsUp, new LogOnlyServiceDiscoveryEventEmitter()); // default to use log-only event emitter } + /** + * @deprecated Use the constructor {@link #ZooKeeperAnnouncer(LoadBalancerServer, boolean, boolean, String, int, ScheduledExecutorService, ServiceDiscoveryEventEmitter)} instead. + */ + @Deprecated + public ZooKeeperAnnouncer(ZooKeeperServer server, boolean initialIsUp, + boolean isDarkWarmupEnabled, String warmupClusterName, int warmupDuration, ScheduledExecutorService executorService, ServiceDiscoveryEventEmitter eventEmitter) + { + _server = server; + // initialIsUp is used for delay mark up. If it's false, there won't be markup when the announcer is started. + _isUp = initialIsUp; + _isWarmingUp = false; + _isRetryWarmup = false; + _pendingMarkDown = new ArrayDeque<>(); + _pendingMarkUp = new ArrayDeque<>(); + _pendingWarmupMarkDown = new ArrayDeque<>(); + + _isDarkWarmupEnabled = isDarkWarmupEnabled; + _warmupClusterName = warmupClusterName; + _warmupDuration = warmupDuration; + _executorService = executorService; + _eventEmitter = eventEmitter; + + server.setServiceDiscoveryEventHelper(this); + } + public ZooKeeperAnnouncer(LoadBalancerServer server, boolean initialIsUp, boolean isDarkWarmupEnabled, String warmupClusterName, int warmupDuration, ScheduledExecutorService executorService, ServiceDiscoveryEventEmitter eventEmitter) { diff --git a/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperConnectionManager.java b/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperConnectionManager.java index 7d36bc2182..59db8f72d1 100644 --- a/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperConnectionManager.java +++ b/d2/src/main/java/com/linkedin/d2/balancer/servers/ZooKeeperConnectionManager.java @@ -184,6 +184,78 @@ protected None convertResponse(None none) throws Exception } } + /** + * @deprecated, use {@link ConnectionManager#markDownAllServers(Callback)} instead. + */ + @Deprecated + @Override + public void markDownAllServers(final Callback callback) + { + Callback markDownCallback; + if (callback != null) + { + markDownCallback = callback; + } + else + { + markDownCallback = new Callback() + { + @Override + public void onError(Throwable e) + { + LOG.error("failed to mark down servers", e); + } + + @Override + public void onSuccess(None result) + { + LOG.info("mark down all servers successful"); + } + }; + } + Callback multiCallback = Callbacks.countDown(markDownCallback, _servers.length); + for (ZooKeeperAnnouncer server : _servers) + { + server.markDown(multiCallback); + } + } + + /** + * @deprecated, use {@link ConnectionManager#markUpAllServers(Callback)} instead. + */ + @Deprecated + @Override + public void markUpAllServers(final Callback callback) + { + Callback markUpCallback; + if (callback != null) + { + markUpCallback = callback; + } + else + { + markUpCallback = new Callback() + { + @Override + public void onError(Throwable e) + { + LOG.error("failed to mark up servers", e); + } + + @Override + public void onSuccess(None result) + { + LOG.info("mark up all servers successful"); + } + }; + } + Callback multiCallback = Callbacks.countDown(markUpCallback, _servers.length); + for (ZooKeeperAnnouncer server : _servers) + { + server.markUp(multiCallback); + } + } + private class Listener implements ZKPersistentConnection.EventListener { @Override @@ -295,6 +367,15 @@ public interface ZKStoreFactory> Z createStore(ZKConnection connection, String path); } + /** + * @deprecated Use {@link #ConnectionManager#getAnnouncers()} instead. + */ + @Deprecated + public ZooKeeperAnnouncer[] getAnnouncers() + { + return _servers; + } + @Override public String getAnnouncementTargetIdentifier() { diff --git a/deprecate.sh b/deprecate.sh new file mode 100644 index 0000000000..ad97da56c2 --- /dev/null +++ b/deprecate.sh @@ -0,0 +1,8 @@ +grep -o "include '[^']*'" settings.gradle | sed -e "s/^include '/com.linkedin.pegasus:/g" -e "s/'//g" | while read -r module_name ; do + if [ "$module_name" == "com.linkedin.pegasus:gradle-plugins" ] + then + echo "WARNING: $module_name cannot be deprecated due to MPPCX-7165. Skipping deprecation..." + else + mint catalog deprecate "$module_name" "$@" + fi +done diff --git a/gradle.properties b/gradle.properties index 87b5768bbd..750a98df0e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.59.0 +version=29.60.0 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true