Package lumis.portal.cluster.multiserver
Class JGroupsClusterManager
- java.lang.Object
-
- lumis.portal.cluster.AbstractClusterManager
-
- lumis.portal.cluster.multiserver.JGroupsClusterManager
-
- All Implemented Interfaces:
IClusterManager
,lumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
public class JGroupsClusterManager extends AbstractClusterManager implements lumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
A ClusterManager that uses the JGroups library for communication between the cluster nodes.- Since:
- 4.0.0
- Version:
- $Revision: 25849 $ $Date: 2023-08-08 13:55:33 -0300 (Tue, 08 Aug 2023) $
-
-
Field Summary
-
Fields inherited from class lumis.portal.cluster.AbstractClusterManager
processTransmissionsReceived, serverId, WAIT_LOCAL_PROCESSING_TIMEOUT_MS
-
-
Constructor Summary
Constructors Constructor Description JGroupsClusterManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.io.Serializable>
Tcall(IClusterCommand<T> command)
Calls a cluster command execution and returns the result of the local execution.protected <T extends java.io.Serializable>
java.util.Map<IClusterMember,T>callAndWaitResponsesInternal(IClusterCallable<T> callable, long timeout)
void
destroy()
Destroys the cluster manager.IClusterConfig
getClusterConfig(ITransaction transaction)
Returns a persistent cluster configuration object.IClusterMember
getLocalMember()
Returns the current cluster member object.java.util.Collection<IClusterMember>
getMembers()
Returns a collection with information about the current members of this cluster.void
init()
Initializes the cluster manager.long
processAllPendingMessages(long lastTransmissionOrder)
Processes all pending messages in the database.void
processMessage(org.jgroups.Message message)
Processes a message.void
send(IClusterTransmission transmission)
Sends a transmission.protected <T extends java.io.Serializable>
ITransmissionResult<T>transmissionReceived(IClusterTransmission transmission)
Processes a received transmission.void
updateAck(long transmissionOrder)
Updates the acknowledgment persisted as the specified last transmission order.-
Methods inherited from class lumis.portal.cluster.AbstractClusterManager
callAndWaitResponses, createClusterCommand, createClusterCommand, createClusterMessage
-
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:IClusterManager
Initializes the cluster manager. This method should start the monitoring and connections necessary for the cluster manager to execute its communications.- Specified by:
init
in interfaceIClusterManager
- Overrides:
init
in classAbstractClusterManager
-
destroy
public void destroy()
Description copied from interface:IClusterManager
Destroys the cluster manager. This method should close all resources used by the cluster manager.- Specified by:
destroy
in interfaceIClusterManager
- Overrides:
destroy
in classAbstractClusterManager
-
transmissionReceived
protected <T extends java.io.Serializable> ITransmissionResult<T> transmissionReceived(IClusterTransmission transmission)
Description copied from class:AbstractClusterManager
Processes a received transmission. Subclasses should call this method whenever a transmission is received.AbstractClusterManager.processTransmissionsReceived
may be used to disable the processing done by this method.- Overrides:
transmissionReceived
in classAbstractClusterManager
- Parameters:
transmission
- the transmission received.
-
send
public void send(IClusterTransmission transmission)
Description copied from interface:IClusterManager
Sends a transmission.- Specified by:
send
in interfaceIClusterManager
- Parameters:
transmission
- the transmission. It must have been created using one of the factory methods available inIClusterManager
.- See Also:
IClusterManager.createClusterCommand(IClusterCallable)
,IClusterManager.createClusterMessage(String, Serializable)
-
call
public <T extends java.io.Serializable> T call(IClusterCommand<T> command) throws java.lang.Exception
Description copied from interface:IClusterManager
Calls a cluster command execution and returns the result of the local execution.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
IClusterManager.createClusterCommand(IClusterCallable)
.- Specified by:
call
in interfaceIClusterManager
- Parameters:
command
- the command to execute through the cluster.- Returns:
- the command execution outcome.
- Throws:
java.lang.Exception
- the exception thrown during command execution or other unknown exception.
-
callAndWaitResponsesInternal
protected <T extends java.io.Serializable> java.util.Map<IClusterMember,T> callAndWaitResponsesInternal(IClusterCallable<T> callable, long timeout) throws ClusterInvocationException, java.util.concurrent.TimeoutException, java.lang.InterruptedException
- Specified by:
callAndWaitResponsesInternal
in classAbstractClusterManager
- Throws:
ClusterInvocationException
java.util.concurrent.TimeoutException
java.lang.InterruptedException
- See Also:
#callAndWaitResponses(IClusterCommand, long)
-
getMembers
public java.util.Collection<IClusterMember> getMembers()
Description copied from interface:IClusterManager
Returns a collection with information about the current members of this cluster.- Specified by:
getMembers
in interfaceIClusterManager
- Returns:
- a collection with information about the current members of this cluster.
-
getLocalMember
public IClusterMember getLocalMember()
Description copied from interface:IClusterManager
Returns the current cluster member object. The object returned represents the member where this method is executed on.- Specified by:
getLocalMember
in interfaceIClusterManager
- Returns:
- this server cluster member object.
-
getClusterConfig
public IClusterConfig getClusterConfig(ITransaction transaction) throws PortalException
Description copied from interface:IClusterManager
Returns a persistent cluster configuration object. The object contains the cluster configurations, and any changes will be applied on transaction commit.- Specified by:
getClusterConfig
in interfaceIClusterManager
- Parameters:
transaction
- the transaction for persistence access.- Returns:
- a persistent cluster configuration instance.
- Throws:
PortalException
-
processAllPendingMessages
public long processAllPendingMessages(long lastTransmissionOrder)
Description copied from interface:lumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
Processes all pending messages in the database.- Specified by:
processAllPendingMessages
in interfacelumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
- Parameters:
lastTransmissionOrder
- the current last processed transmission order, or -1 if none was processed.- Returns:
- the last processed transmission order, or, if none was processed (before and during the call to this method), -1 is returned.
-
processMessage
public void processMessage(org.jgroups.Message message)
Description copied from interface:lumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
Processes a message.- Specified by:
processMessage
in interfacelumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
- Parameters:
message
- the message.
-
updateAck
public void updateAck(long transmissionOrder)
Description copied from interface:lumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
Updates the acknowledgment persisted as the specified last transmission order.- Specified by:
updateAck
in interfacelumis.portal.cluster.multiserver.MessageReceiver.IProcessMessageCallback
-
-