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
Modifier and TypeClassDescriptionstatic class
ConfigSubscription.ConfigState<T extends com.yahoo.config.ConfigInstance>
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
True if someone has set thereloadedGeneration
number by callingreload(long)
and hence wants to force a given generation programmatically.void
close()
boolean
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 idThe class of the subscription's desiredConfigInstance
The 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 configboolean
isClosed()
boolean
isConfigChangedAndReset
(Long requiredGen) Called fromConfigSubscriber
when the changed status of this config is propagated to the clientsabstract boolean
nextConfig
(long timeout) Polls this subscription for a change.void
reload
(long generation) Force this into the given generation, used in testingprotected void
setConfigIfChanged
(T config) protected void
setConfigIncGen
(T config) Used byFileConfigSubscription
andConfigSetSubscription
void
Called by for example network threads to signal that the user thread should throw this exception immediatelyabstract boolean
subscribe
(long timeout) Will block until the nextnextConfig(long)
is guaranteed to return an answer (or throw) immediately (i.e.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 fromConfigSubscriber
when the changed status of this config is propagated to the clients -
setConfigIncGen
Used byFileConfigSubscription
andConfigSetSubscription
-
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
exception
changed. If true, theconfig
field 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 thereloadedGeneration
number 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
-