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

    • Field Detail

      • log

        protected static java.util.logging.Logger log
      • key

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

        protected final java.lang.Class<T extends com.yahoo.config.ConfigInstance> configClass
    • Method Detail

      • get

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • isConfigChangedAndReset

        public boolean isConfigChangedAndReset​(java.lang.Long requiredGen)
        Called from ConfigSubscriber when the changed status of this config is propagated to the clients
      • 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 java.lang.Class<T> getConfigClass()
        The class of the subscription's desired ConfigInstance
        Returns:
        the config class
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.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​(java.lang.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 java.lang.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()
      • 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