Package org.graylog2.plugin.cluster
Interface ClusterConfigService
- All Known Implementing Classes:
ClusterConfigServiceImpl
public interface ClusterConfigService
Service to save and retrieve cluster configuration beans.
-
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.
-
Method Details
-
get
Retrieve Java class of a certain type from the cluster configuration.- 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.
-
extractPayload
-
get
Retrieve Java class of a certain type for the given key from the cluster configuration.- 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.
-
getRaw
Retrieve raw persisted Java class.- Parameters:
key
- 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
Retrieve Java class of a certain type from the cluster configuration or return a default value in case that failed.- 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
Write a configuration bean to the cluster configuration with the specified key.- 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!
-
write
<T> void write(T payload) Write a configuration bean to the cluster configuration.- 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!
-
remove
Remove a configuration bean from the cluster configuration.- Parameters:
type
- TheClass
of the Java configuration bean to remove.- Returns:
- The number of removed entries from the cluster configuration.
-
list
List all classes of configuration beans in the database.- Returns:
- The list of Java classes being used in the database.
-