public class ClusterServersDAOImpl extends Object implements ApplicationEventPublisherAware, ClusterServersDAO, SmartInitializingSingleton
cluster_servers table in the Apache Cassandra database.ClusterServersDAO.ClusterServer| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log
Logger for this object.
|
| Constructor and Description |
|---|
ClusterServersDAOImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterSingletonsInstantiated() |
ListenableFuture<Void> |
createOrUpdateServer(UUID serverId,
String serverName,
String interNodeCommunicationUrl,
Date lastOnlineTime)
Creates or updates the record for an archive server.
|
ListenableFuture<Void> |
deleteServer(UUID serverId)
Removes the server with the specified ID from the database.
|
ListenableFuture<? extends ClusterServersDAO.ClusterServer> |
getServer(UUID serverId)
Reads the server object for the specified ID from the database.
|
ListenableFuture<? extends Iterable<? extends ClusterServersDAO.ClusterServer>> |
getServers()
Reads the server objects for all servers from the database.
|
boolean |
isInitialized()
Tells whether this DAO has finished initialization and is ready to be
used.
|
void |
onCassandraProviderInitializedEvent(CassandraProviderInitializedEvent event)
Handles
CassandraProviderInitializedEvents. |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setCassandraProvider(CassandraProvider cassandraProvider)
Sets the Cassandra provider that provides access to the Apache Cassandra
database.
|
ListenableFuture<Void> |
updateServerLastOnlineTime(UUID serverId,
Date lastOnlineTime)
Updates the last-online time for an archive server.
|
protected final org.slf4j.Logger log
@EventListener @Order(value=1000) public void onCassandraProviderInitializedEvent(CassandraProviderInitializedEvent event)
CassandraProviderInitializedEvents. This event is used
when the CassandraProvider set using
setCassandraProvider(CassandraProvider) is not ready yet when
this object is initialized. In this case, some actions that usually are
performed during initialization (like creating tables, initializing
access objects) have to be deferred until the Apache Cassandra database
becomes available.event - initialization event sent by the CassandraProvider.@Autowired public void setCassandraProvider(CassandraProvider cassandraProvider)
cassandraProvider - provider that provides a connection to the Apache Cassandra
database.public void afterSingletonsInstantiated()
afterSingletonsInstantiated in interface SmartInitializingSingletonpublic void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublic ListenableFuture<Void> createOrUpdateServer(UUID serverId, String serverName, String interNodeCommunicationUrl, Date lastOnlineTime)
ClusterServersDAOserverId does not exist yet, it is created.
Otherwise, it is updated. The operation is performed in an asynchronous
way so that it will not block for network communication. The result of
the operation can be checked through the returned future.createOrUpdateServer in interface ClusterServersDAOserverId - unique ID identifying the server within the cluster. This ID
must be different for each server.serverName - name (typically the hostname) of the server. The name is used
to help the user in identifying a server. It should be unique
for each server, but this condition is not enforced.interNodeCommunicationUrl - base URL for the web-service interface of the server that can
be used by other servers within the cluster to communicate
with the server.lastOnlineTime - time the server last updated its status. This time is used by
other servers to determine if the server is online. Typically,
this parameter should be the current time when calling this
method. The last-online time needs to be updated periodically,
but the ClusterServersDAO.updateServerLastOnlineTime(UUID, Date) should
be preferred for this purpose.get() method will throw an exception.public ListenableFuture<Void> deleteServer(UUID serverId)
ClusterServersDAOdeleteServer in interface ClusterServersDAOserverId - unique identifier of the server that shall be removed from the
database.get() method will throw an exception.public ListenableFuture<? extends ClusterServersDAO.ClusterServer> getServer(UUID serverId)
ClusterServersDAOgetServer in interface ClusterServersDAOserverId - unique identifier identifying the server.get method returns
null. In case of failure, the future's
get() method will throw an exception.public ListenableFuture<? extends Iterable<? extends ClusterServersDAO.ClusterServer>> getServers()
ClusterServersDAOReads the server objects for all servers from the database. The server objects are not returned directly but through a listenable future, so that the calling code can wait for the database operation to finish asynchronously.
The iterable returned by the future is only safe for iterating once. Subsequent requests to create an iterator might result in the new iterator only returning the elements that have not been returned by a previously created iterator yet. Besides, the iterator might block while iterating, waiting for additional elements to arrive from the network.
getServers in interface ClusterServersDAOget() method will throw an exception.public boolean isInitialized()
ClusterServersDAOtrue, operations might
still fail because of transient problems.isInitialized in interface ClusterServersDAOtrue if this DAO has been initialized and is ready
to be used, false if initialization has not
completed yet.public ListenableFuture<Void> updateServerLastOnlineTime(UUID serverId, Date lastOnlineTime)
ClusterServersDAOClusterServersDAO.createOrUpdateServer(UUID, String, String, Date) method.
However, implementations might not enforce this limitation, silently
creating a partially initialized record when this method is called first.updateServerLastOnlineTime in interface ClusterServersDAOserverId - unique ID identifying the server within the cluster. This ID
must be different for each server.lastOnlineTime - time the server last updated its status. This time is used by
other servers to determine if the server is online. Typically,
this parameter should be the current time when calling this
method. The last-online time needs to be updated periodically.get() method will throw an exception.Copyright © 2011–2017 aquenos GmbH. All rights reserved.