Package org.graylog2.cluster
Class ClusterConfigServiceImpl
java.lang.Object
org.graylog2.cluster.ClusterConfigServiceImpl
- All Implemented Interfaces:
ClusterConfigService
-
Constructor Summary
ConstructorDescriptionClusterConfigServiceImpl
(MongoJackObjectMapperProvider mapperProvider, MongoConnection mongoConnection, NodeId nodeId, ChainingClassLoader chainingClassLoader, ClusterEventBus clusterEventBus) -
Method Summary
Modifier and TypeMethodDescription<T> T
extractPayload
(Object payload, Class<T> type) <T> T
Retrieve Java class of a certain type from the cluster configuration.<T> T
Retrieve Java class of a certain type for the given key from the cluster configuration.<T> T
getOrDefault
(Class<T> type, T defaultValue) Retrieve Java class of a certain type from the cluster configuration or return a default value in case that failed.Retrieve raw persisted Java class.list()
List all classes of configuration beans in the database.<T> int
Remove a configuration bean from the cluster configuration.<T> void
Write a configuration bean to the cluster configuration with the specified key.<T> void
write
(T payload) Write a configuration bean to the cluster configuration.
-
Constructor Details
-
Method Details
-
extractPayload
- Specified by:
extractPayload
in interfaceClusterConfigService
-
get
Description copied from interface:ClusterConfigService
Retrieve Java class of a certain type for the given key from the cluster configuration.- Specified by:
get
in interfaceClusterConfigService
- Type Parameters:
T
- The type of the Java configuration bean.- Parameters:
key
- The key that is used to find the cluster config object in the database.type
- TheClass
of the Java configuration bean to retrieve.- Returns:
- An instance of the requested type or
null
if it couldn't be retrieved.
-
get
Description copied from interface:ClusterConfigService
Retrieve Java class of a certain type from the cluster configuration.- Specified by:
get
in interfaceClusterConfigService
- Type Parameters:
T
- The type of the Java configuration bean.- Parameters:
type
- TheClass
of the Java configuration bean to retrieve.- Returns:
- An instance of the requested type or
null
if it couldn't be retrieved.
-
getRaw
Description copied from interface:ClusterConfigService
Retrieve raw persisted Java class.- Specified by:
getRaw
in interfaceClusterConfigService
- Parameters:
type
- The key/type that is used to find the cluster config object in the database.- Returns:
- An instance of the raw persisted Java class or
null
if it couldn't be retrieved.
-
getOrDefault
Description copied from interface:ClusterConfigService
Retrieve Java class of a certain type from the cluster configuration or return a default value in case that failed.- Specified by:
getOrDefault
in interfaceClusterConfigService
- Type Parameters:
T
- The type of the Java configuration bean.- Parameters:
type
- TheClass
of the Java configuration bean to retrieve.defaultValue
- An instance ofT
which is returned as default value.- Returns:
- An instance of the requested type.
-
write
public <T> void write(T payload) Description copied from interface:ClusterConfigService
Write a configuration bean to the cluster configuration.- Specified by:
write
in interfaceClusterConfigService
- Type Parameters:
T
- The type of the Java configuration bean.- Parameters:
payload
- The object to write to the cluster configuration. Must be serializable by Jackson!
-
write
Description copied from interface:ClusterConfigService
Write a configuration bean to the cluster configuration with the specified key.- Specified by:
write
in interfaceClusterConfigService
- Type Parameters:
T
- The type of the Java configuration bean.- Parameters:
key
- The key that is used to write the cluster config object to the database.payload
- The object to write to the cluster configuration. Must be serializable by Jackson!
-
remove
Description copied from interface:ClusterConfigService
Remove a configuration bean from the cluster configuration.- Specified by:
remove
in interfaceClusterConfigService
- Parameters:
type
- TheClass
of the Java configuration bean to remove.- Returns:
- The number of removed entries from the cluster configuration.
-
list
Description copied from interface:ClusterConfigService
List all classes of configuration beans in the database.- Specified by:
list
in interfaceClusterConfigService
- Returns:
- The list of Java classes being used in the database.
-