public class InterNodeCommunicationServiceImpl extends Object implements ApplicationEventPublisherAware, InterNodeCommunicationService, SmartInitializingSingleton
InterNodeCommunicationService
.Constructor and Description |
---|
InterNodeCommunicationServiceImpl()
Creates the inter-node communication service.
|
Modifier and Type | Method and Description |
---|---|
void |
afterSingletonsInstantiated() |
ListenableFuture<List<ChannelStatus>> |
getArchivingStatus(String targetBaseUrl)
Queries a remote server for its archiving status.
|
ListenableFuture<ChannelStatus> |
getArchivingStatusForChannel(String targetBaseUrl,
String channelName)
Queries a remote server for the archiving status of one of its channels.
|
ListenableFuture<Long> |
getCurrentSystemTime(String targetBaseUrl)
Queries a remote server for its current system time (as returned by
System.currentTimeMillis() ). |
boolean |
isInitialized()
Tells whether this communication service has initialized completely and
is ready for operation.
|
void |
onInterNodeCommunicationAuthenticationServiceInitializedEvent(InterNodeCommunicationAuthenticationServiceInitializedEvent event)
|
ListenableFuture<List<ArchiveConfigurationCommandResult>> |
runArchiveConfigurationCommands(String targetBaseUrl,
List<? extends ArchiveConfigurationCommand> commands)
Runs a list of archive-configuration commands on the specified remote
server.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAsyncRestTemplate(AsyncRestTemplate asyncRestTemplate)
Sets the async REST template to be used for making HTTP requests to
remote servers.
|
void |
setAuthenticationService(InterNodeCommunicationAuthenticationService authenticationService)
Sets the inter-node-communication authentication service used by this
service.
|
ListenableFuture<Void> |
updateChannelInformation(String targetBaseUrl,
List<ChannelMetaDataDAO.ChannelInformation> channelInformationUpdates,
List<String> missingChannels,
List<UUID> forwardToServers,
long timeStamp)
Updates the channel information cache of a remote server.
|
public InterNodeCommunicationServiceImpl()
afterSingletonsInstantiated()
before using this service.public void afterSingletonsInstantiated()
afterSingletonsInstantiated
in interface SmartInitializingSingleton
@EventListener public void onInterNodeCommunicationAuthenticationServiceInitializedEvent(InterNodeCommunicationAuthenticationServiceInitializedEvent event)
InterNodeCommunicationAuthenticationServiceInitializedEvent
s.
These events signal that the authentication service used by this service
is ready for operation. This service reacts on these events by emitting
an InterNodeCommunicationServiceInitializedEvent
in order to
signal that is is ready for operation.event
- event signalling that the authentication service is ready for
operation.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
public void setAsyncRestTemplate(AsyncRestTemplate asyncRestTemplate)
asyncRestTemplate
- async REST template to be used for making requests to remote
servers.@Autowired public void setAuthenticationService(InterNodeCommunicationAuthenticationService authenticationService)
authenticationService
- inter-node-communication authentication service for this
server.public ListenableFuture<List<ChannelStatus>> getArchivingStatus(String targetBaseUrl)
InterNodeCommunicationService
Queries a remote server for its archiving status. If the request is not successful, the returned future will throw one of the following exceptions:
NullPointerException
if targetBaseUrl
is
null
.RuntimeException
if the communication with the target server
fails (e.g. the target server does not respond or responds with an
invalid response).
The returned future returns a list containing the status of all channels
known by the target server. The list is never null
, but it
might be empty if the target server does not have any channels. The
channels are ordered by the natural order of their names.
getArchivingStatus
in interface InterNodeCommunicationService
targetBaseUrl
- base URL on which the target server shall be contacted. Must
not include a trailing slash.public ListenableFuture<ChannelStatus> getArchivingStatusForChannel(String targetBaseUrl, String channelName)
InterNodeCommunicationService
Queries a remote server for the archiving status of one of its channels. If the request is not successful, the returned future will throw one of the following exceptions:
IllegalArgumentException
if channelName
is empty.
NullPointerException
if targetBaseUrl
or
channelName
is null
.RuntimeException
if the communication with the target server
fails (e.g. the target server does not respond or responds with an
invalid response).
The returned future returns null
if the specified channel is
not known by the target server's archiving service (e.g. because it does
not exist or is registered with a different server).
getArchivingStatusForChannel
in interface InterNodeCommunicationService
targetBaseUrl
- base URL on which the target server shall be contacted. Must
not include a trailing slash.channelName
- name of the channel to be queried.null
if the channel is not known
by the target server. On failure, the future will throw an
exception.public ListenableFuture<Long> getCurrentSystemTime(String targetBaseUrl)
InterNodeCommunicationService
Queries a remote server for its current system time (as returned by
System.currentTimeMillis()
). If the request is not successful,
the returned future will throw one of the following exceptions:
NullPointerException
if targetBaseUrl
is
null
.RuntimeException
if the communication with the target server
fails (e.g. the target server does not respond or responds with an
invalid response).getCurrentSystemTime
in interface InterNodeCommunicationService
targetBaseUrl
- base URL on which the target server shall be contacted. Must
not include a trailing slash.public boolean isInitialized()
InterNodeCommunicationService
Tells whether this communication service has initialized completely and is ready for operation. The communication service is ready as soon as all of its dependencies are ready.
When this service changes to the initialized state, it publishes an
InterNodeCommunicationServiceInitializedEvent
to the application
context.
isInitialized
in interface InterNodeCommunicationService
true
if initialization has completed and this
communication service can be used, false
otherwise.public ListenableFuture<List<ArchiveConfigurationCommandResult>> runArchiveConfigurationCommands(String targetBaseUrl, List<? extends ArchiveConfigurationCommand> commands)
InterNodeCommunicationService
Runs a list of archive-configuration commands on the specified remote
server. If the execution of individual commands on the target server
fails, the corresponding ArchiveConfigurationCommandResult
will
reflect this error. However, if the whole communication process fails,
the future returned by this method will throw one of the following
exceptions:
NullPointerException
if targetBaseUrl
or
commands
is null
or commands
contains null
elements.RuntimeException
if the communication with the target server
fails (e.g. the target server does not respond or responds with an
unexpected error).runArchiveConfigurationCommands
in interface InterNodeCommunicationService
targetBaseUrl
- base URL on which the target server shall be contacted. Must
not include a trailing slash.commands
- list of commands that shall be sent to the target server.ArchiveConfigurationCommandResult
s that are returned in
the same order as the commands specified in commands
. If one or several individual commands fail, the corresponding
result will reflect this failure. However, if the whole operation
fails due to an unexpected problem, the future will throw an
exception.public ListenableFuture<Void> updateChannelInformation(String targetBaseUrl, List<ChannelMetaDataDAO.ChannelInformation> channelInformationUpdates, List<String> missingChannels, List<UUID> forwardToServers, long timeStamp)
InterNodeCommunicationService
Updates the channel information cache of a remote server. The specified
updates are sent to the remote server and it is asked to also notify the
servers listed in forwardToServers
. On failure, the future
returned by this method throws one of the following exceptions:
NullPointerException
if targetBaseUrl
,
channelInformationUpdates
, or missingChannels
is null
or channelInformationUpdates
,
missingChannels
, or forwardToServers
contains
null
elements.RuntimeException
if the communication with the target server
fails (e.g. the target server does not respond or responds with an
unexpected error).updateChannelInformation
in interface InterNodeCommunicationService
targetBaseUrl
- base URL on which the target server shall be contacted. Must
not include a trailing slash.channelInformationUpdates
- updated channel information objects.missingChannels
- names of channels that are now missing (the channel
information is null
, which typically means that
they have been deleted).forwardToServers
- servers to which the target server should forward this update.
This parameter may be null
if the target server
shall not forward this update.timeStamp
- time stamp (as returned by System.currentTimeMillis()
)
of the point in time right before the information that is part
of this update was retrieved from the database. This
information is used for conflict resolution on the target
server.Copyright © 2011–2017 aquenos GmbH. All rights reserved.