Class ConfigSubscription<T extends com.yahoo.config.ConfigInstance>

java.lang.Object
com.yahoo.config.subscription.impl.ConfigSubscription<T>
Direct Known Subclasses:
ConfigSetSubscription, FileConfigSubscription, JarConfigSubscription, JRTConfigSubscription, RawConfigSubscription

public abstract class ConfigSubscription<T extends com.yahoo.config.ConfigInstance> extends Object
Represents one active subscription to one config
Author:
Vegard Havdal
  • Field Details

    • log

      protected static final Logger log
    • key

      protected final ConfigKey<T extends com.yahoo.config.ConfigInstance> key
    • configClass

      protected final Class<T extends com.yahoo.config.ConfigInstance> configClass
  • Method Details

    • get

      public static <T extends com.yahoo.config.ConfigInstance> ConfigSubscription<T> get(ConfigKey<T> key, JrtConfigRequesters requesters, ConfigSource source, TimingValues timingValues)
      Correct type of ConfigSubscription instance based on type of source or form of config id
      Parameters:
      key - a ConfigKey
      Returns:
      a subclass of a ConfigsSubscription
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • isConfigChangedAndReset

      public boolean isConfigChangedAndReset(Long requiredGen)
      Called from ConfigSubscriber when the changed status of this config is propagated to the clients
    • setConfigIncGen

      protected void setConfigIncGen(T config)
    • setConfigIfChanged

      protected void setConfigIfChanged(T config)
    • getConfigState

      public ConfigSubscription.ConfigState<T> getConfigState()
      The config state object of this subscription
      Returns:
      the ConfigInstance (the config) of this subscription
    • getConfigClass

      public Class<T> getConfigClass()
      The class of the subscription's desired ConfigInstance
      Returns:
      the config class
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getKey

      public ConfigKey<T> getKey()
      The config key which this subscription uses to identify its config
      Returns:
      the ConfigKey for this subscription
    • nextConfig

      public abstract boolean nextConfig(long timeout)
      Polls this subscription for a change. The method is guaranteed to use all of the given timeout before returning false. It will also take into account a user-set generation, that can be set by ConfigSubscriber.reload(long).
      Parameters:
      timeout - in milliseconds
      Returns:
      false if timed out, true if generation or config or exception changed. If true, the config field will be set also. has changed
    • subscribe

      public abstract boolean subscribe(long timeout)
      Will block until the next nextConfig(long) is guaranteed to return an answer (or throw) immediately (i.e. not block)
      Parameters:
      timeout - in milliseconds
      Returns:
      false if timed out
    • setException

      public void setException(RuntimeException e)
      Called by for example network threads to signal that the user thread should throw this exception immediately
      Parameters:
      e - a RuntimeException
    • getException

      public RuntimeException getException()
      Gets an exception set by for example a network thread. If not null, it indicates that it should be thrown in the user's thread immediately.
      Returns:
      a RuntimeException if there exists one
    • close

      public void close()
    • isClosed

      public boolean isClosed()
    • reload

      public void reload(long generation)
      Force this into the given generation, used in testing
      Parameters:
      generation - a config generation
    • checkReloaded

      protected boolean checkReloaded()
      True if someone has set the reloadedGeneration number by calling reload(long) and hence wants to force a given generation programmatically. If that is the case, sets the generation and flags it as changed accordingly.
      Returns:
      true if reload(long) has been called, false otherwise
    • getDefContent

      public DefContent getDefContent()
      The config definition schema
      Returns:
      the config definition for this subscription