@StableMinor(version="12.4", sinceVersion="4.1") public interface IClusterManager
A message may be sent by creating it using createClusterMessage(String, Serializable)
and sending the IClusterMessage
object returned by calling
send(IClusterTransmission)
. When received, the message generates
a ClusterMessageReceivedEvent
.
A command may be sent by creating it using createClusterCommand(Runnable)
and sending the IClusterCommand
object returned by calling
send(IClusterTransmission)
. When received, the command executes
the corresponding Runnable
code.
Either the message or the command, can be further configured before sending by using the available methods in the returned object.
IClusterMessage
,
IClusterCommand
Modifier and Type | Method and Description |
---|---|
<T extends Serializable> |
call(IClusterCommand<T> command)
Calls a cluster command execution and returns the result of the local execution.
|
<T extends Serializable> |
callAndWaitResponses(IClusterCallable<T> command,
long timeout)
Calls a cluster command execution and waits all current cluster servers to respond with their result and, then, returns an
unmodifiable map having the cluster member as the key and the execution result as the value.
|
<T extends Serializable> |
createClusterCommand(IClusterCallable<T> callable)
Creates a cluster command instance and returns it.
|
IClusterCommand<Serializable> |
createClusterCommand(Runnable runnable)
Deprecated.
since 8.0.0 replaced by
createClusterCommand(IClusterCallable) . |
IClusterMessage |
createClusterMessage(String group,
Serializable data)
Creates a cluster message instance and returns it.
|
void |
destroy()
Destroys the cluster manager.
|
IClusterConfig |
getClusterConfig(ITransaction transaction)
Returns a persistent cluster configuration object.
|
IClusterMember |
getLocalMember()
Returns the current cluster member object.
|
Collection<IClusterMember> |
getMembers()
Returns a collection with information about the current members of this cluster.
|
void |
init()
Initializes the cluster manager.
|
void |
send(IClusterTransmission transmission)
Sends a transmission.
|
void init()
void destroy()
void send(IClusterTransmission transmission)
transmission
- the transmission. It must have been created using
one of the factory methods available in IClusterManager
.createClusterCommand(IClusterCallable)
,
createClusterMessage(String, Serializable)
<T extends Serializable> T call(IClusterCommand<T> command) throws Exception
This method sends the command through the cluster and gives feedback on the local server execution, in the form of the return value and the raised exception.
It is important to notice that the command will be sent over the cluster despite its execution outcome.
The given command must have been created through createClusterCommand(IClusterCallable)
.
command
- the command to execute through the cluster.Exception
- the exception thrown during command execution or other unknown exception.<T extends Serializable> Map<IClusterMember,T> callAndWaitResponses(IClusterCallable<T> command, long timeout) throws ClusterInvocationException, TimeoutException, InterruptedException, IllegalArgumentException
If some server raises an exception, a ClusterInvocationException
will be raised locally on the server that called this method
with all exceptions that happened in the servers as suppressed.
This method has no guarantee it will execute properly if cluster members enter or leave the cluster during its execution.
If all responses couldn't be retrieved in the given timeout, a TimeoutException
will be raised.
The given command must have been created through createClusterCommand(IClusterCallable)
.
T
- the response type. it must be serializable.command
- the command to be invoked.timeout
- the timeout this method will wait the invoke finishes.ClusterInvocationException
- if some server raises an exception during the invoke.TimeoutException
- if the timeout has been reached and not all responses were returned.InterruptedException
- if the thread that called this method was interrupted.IllegalArgumentException
- if the given command is null
.IllegalArgumentException
- if the given timeout is not a positive number.Collection<IClusterMember> getMembers() throws PortalException
PortalException
IClusterMember getLocalMember()
IClusterMessage createClusterMessage(String group, Serializable data)
group
- the destination group for the message.data
- the data sent in the message.IClusterMessage
@Deprecated IClusterCommand<Serializable> createClusterCommand(Runnable runnable)
createClusterCommand(IClusterCallable)
.runnable
- the runnable that contains the command's execution. It must be serializable.IClusterCommand
<T extends Serializable> IClusterCommand<T> createClusterCommand(IClusterCallable<T> callable)
callable
- the IClusterCallable
that contains the command's execution. It must be serializable.IClusterConfig getClusterConfig(ITransaction transaction) throws PortalException
transaction
- the transaction for persistence access.PortalException
LumisXP 12.4.0.200625 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.