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
Represents one active subscription to one config
- Author:
- Vegard Havdal
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfigSubscription.ConfigState<T extends com.yahoo.config.ConfigInstance> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanTrue if someone has set thereloadedGenerationnumber by callingreload(long)and hence wants to force a given generation programmatically.voidclose()booleanstatic <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 idThe class of the subscription's desiredConfigInstanceThe config state object of this subscriptionThe config definition schemaGets an exception set by for example a network thread.getKey()The config key which this subscription uses to identify its configbooleanisClosed()booleanisConfigChangedAndReset(Long requiredGen) Called fromConfigSubscriberwhen the changed status of this config is propagated to the clientsabstract booleannextConfig(long timeout) Polls this subscription for a change.voidreload(long generation) Force this into the given generation, used in testingprotected voidsetConfigIfChanged(T config) protected voidsetConfigIncGen(T config) Used byFileConfigSubscriptionandConfigSetSubscriptionvoidCalled by for example network threads to signal that the user thread should throw this exception immediatelyabstract booleansubscribe(long timeout) Will block until the nextnextConfig(long)is guaranteed to return an answer (or throw) immediately (i.e. not block)toString()
-
Field Details
-
log
-
key
-
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- aConfigKey- Returns:
- a subclass of a ConfigsSubscription
-
equals
-
isConfigChangedAndReset
Called fromConfigSubscriberwhen the changed status of this config is propagated to the clients -
setConfigIncGen
Used byFileConfigSubscriptionandConfigSetSubscription -
setConfigIfChanged
-
getConfigState
The config state object of this subscription- Returns:
- the ConfigInstance (the config) of this subscription
-
getConfigClass
The class of the subscription's desiredConfigInstance- Returns:
- the config class
-
toString
-
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 byConfigSubscriber.reload(long).- Parameters:
timeout- in milliseconds- Returns:
- false if timed out, true if generation or config or
exceptionchanged. If true, theconfigfield will be set also. has changed
-
subscribe
public abstract boolean subscribe(long timeout) Will block until the nextnextConfig(long)is guaranteed to return an answer (or throw) immediately (i.e. not block)- Parameters:
timeout- in milliseconds- Returns:
- false if timed out
-
setException
Called by for example network threads to signal that the user thread should throw this exception immediately- Parameters:
e- a 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 thereloadedGenerationnumber by callingreload(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
The config definition schema- Returns:
- the config definition for this subscription
-