diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-07-02 11:54:43 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-07-02 11:54:43 +0200 |
commit | eb37f7dcbd89143715fbe9b838a91b296db0a3c9 (patch) | |
tree | a065cc8ffe0bee8fc9022fd32a926ff5712542c6 /config | |
parent | b4abecef92c802ee6f779dc77d4328cc6fbf22cb (diff) |
Improvements to handling of cluster removal
- Don't change health status to "initializing" when creating a new VipStatus,
as 'initializing' now requires all clusters to be up to transition to 'up',
which means that if we're already up but are missing a cluster we'll go from
'up' to 'initializing' and stay there.
- Forget up/down status for removed clusters.
- Nicer logging on ignorable reconfiguration errors.
Diffstat (limited to 'config')
-rw-r--r-- | config/src/main/java/com/yahoo/config/subscription/ConfigInstanceUtil.java | 10 | ||||
-rw-r--r-- | config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java | 27 |
2 files changed, 21 insertions, 16 deletions
diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigInstanceUtil.java b/config/src/main/java/com/yahoo/config/subscription/ConfigInstanceUtil.java index 9710ee607eb..82d02ec89f9 100644 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigInstanceUtil.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigInstanceUtil.java @@ -22,9 +22,9 @@ public class ConfigInstanceUtil { * Values that have not been explicitly set in the source builder, will be left unchanged * in the destination. * - * @param destination The builder to copy values into. - * @param source The builder to copy values from. Unset values are not copied. - * @param <BUILDER> The builder class. + * @param destination the builder to copy values into + * @param source the builder to copy values from. Unset values are not copied + * @param <BUILDER> the builder class */ public static<BUILDER extends ConfigBuilder> void setValues(BUILDER destination, BUILDER source) { try { @@ -56,9 +56,9 @@ public class ConfigInstanceUtil { setConfigId(i, configId); } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | - NoSuchFieldException | IllegalAccessException e) { + NoSuchFieldException | IllegalAccessException e) { throw new IllegalArgumentException("Failed creating new instance of '" + type.getCanonicalName() + - "' for config id '" + configId + "': " + Exceptions.toMessageString(e), e); + "' for config id '" + configId + "'", e); } return instance; } diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java index 814222989a1..dbe27e2933c 100644 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java @@ -423,21 +423,26 @@ public class ConfigSubscriber implements AutoCloseable { * @return The handle of the config * @see #startConfigThread(Runnable) */ - public <T extends ConfigInstance> ConfigHandle<T> subscribe(final SingleSubscriber<T> singleSubscriber, Class<T> configClass, String configId) { - if (!subscriptionHandles.isEmpty()) - throw new IllegalStateException("Can not start single-subscription because subscriptions were previously opened on this."); - final ConfigHandle<T> handle = subscribe(configClass, configId); - if (!nextConfig()) - throw new ConfigurationRuntimeException("Initial config of " + configClass.getName() + " failed."); + public <T extends ConfigInstance> ConfigHandle<T> subscribe(SingleSubscriber<T> singleSubscriber, Class<T> configClass, String configId) { + if ( ! subscriptionHandles.isEmpty()) + throw new IllegalStateException("Can not start single-subscription because subscriptions were previously opened on this"); + + ConfigHandle<T> handle = subscribe(configClass, configId); + + if ( ! nextConfig()) + throw new ConfigurationRuntimeException("Initial config of " + configClass.getName() + " failed"); + singleSubscriber.configure(handle.getConfig()); startConfigThread(() -> { while (!isClosed()) { try { - if (nextConfig()) { - if (handle.isChanged()) singleSubscriber.configure(handle.getConfig()); - } - } catch (Exception e) { - log.log(SEVERE, "Exception from config system, continuing config thread: " + Exceptions.toMessageString(e)); + if (nextConfig() && handle.isChanged()) + singleSubscriber.configure(handle.getConfig()); + } + catch (Exception e) { + log.log(WARNING, "Exception on applying config " + configClass.getName() + + " for config id " + configId + ": Ignoring this change: " + + Exceptions.toMessageString(e)); } } } |