Package de.hybris.platform.cluster
Class DefaultBroadcastService
- java.lang.Object
-
- de.hybris.platform.cluster.DefaultBroadcastService
-
- All Implemented Interfaces:
BroadcastService
public class DefaultBroadcastService extends java.lang.Object implements BroadcastService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
DefaultBroadcastService.MethodBroadcastListener
Inner class to connect this service to all broadcast methods.protected static class
DefaultBroadcastService.MethodWrapper
-
Field Summary
Fields Modifier and Type Field Description static int
CUR_VERSION
stores the current platform version encoded as integer currently: 4.1.1.0
-
Constructor Summary
Constructors Constructor Description DefaultBroadcastService(BroadcastServiceConfiguration cfg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(RawMessage message)
Determines whether or not a specific message is being accepted.void
addTransportData(RawMessage message)
protected java.util.concurrent.ExecutorService
createMessageSendingExecutorService()
protected DefaultBroadcastService.MethodWrapper
createMethod(java.lang.String name, java.lang.Class clazz)
void
destroy()
BroadcastMethod
getBroadcastMethod(java.lang.String name)
TODO apidocjava.util.Set<java.lang.String>
getBroadcastMethodNames()
TODO apidoclong
getClusterIslandPK()
int
getClusterNodeID()
long
getDynamicClusterNodeID()
TODO apidocstatic DefaultBroadcastService
getInstance()
protected java.util.concurrent.ExecutorService
getMessageSendingExecutorService()
protected java.util.List<DefaultBroadcastService.MethodWrapper>
getMethods()
protected java.lang.String
getStartupInfo()
void
initMethods()
boolean
isClusteringEnabled()
protected boolean
isDuplicateMessage(RawMessage message)
protected boolean
isLocal(RawMessage message)
protected java.util.List<DefaultBroadcastService.MethodWrapper>
loadConfiguredMethods()
protected java.util.List<DefaultBroadcastService.MethodWrapper>
loadLoopbackMethods()
protected java.util.List<DefaultBroadcastService.MethodWrapper>
loadMethods()
protected void
processMessageFromMethod(RawMessage message, java.lang.String methodName)
void
registerBroadcastListener(BroadcastMessageListener listener, boolean remoteMessagesOnly)
TODO apidocvoid
send(RawMessage message)
TODO apidocprotected void
sendAsnychronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message, Tenant currentTenant, java.util.concurrent.ExecutorService executorService)
Sends a message using a executor service.protected void
sendSynchronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message)
Sends a message synchronously.protected void
startPingHandler()
void
unregisterBroadcastListener(BroadcastMessageListener listener)
TODO apidocprotected void
updateNodeIDsFromDatabase()
Should be called after system initialization since node IDs may have changed!
-
-
-
Field Detail
-
CUR_VERSION
public static final int CUR_VERSION
stores the current platform version encoded as integer currently: 4.1.1.0- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultBroadcastService
public DefaultBroadcastService(BroadcastServiceConfiguration cfg)
-
-
Method Detail
-
getInstance
public static DefaultBroadcastService getInstance()
-
getStartupInfo
protected java.lang.String getStartupInfo()
-
updateNodeIDsFromDatabase
protected void updateNodeIDsFromDatabase()
Should be called after system initialization since node IDs may have changed!
-
createMessageSendingExecutorService
protected java.util.concurrent.ExecutorService createMessageSendingExecutorService()
-
getMessageSendingExecutorService
protected java.util.concurrent.ExecutorService getMessageSendingExecutorService()
-
getDynamicClusterNodeID
public long getDynamicClusterNodeID()
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
getDynamicClusterNodeID
in interfaceBroadcastService
- Returns:
- the dynamic cluster node id
-
getBroadcastMethodNames
public java.util.Set<java.lang.String> getBroadcastMethodNames()
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
getBroadcastMethodNames
in interfaceBroadcastService
- Returns:
- Set
-
getBroadcastMethod
public BroadcastMethod getBroadcastMethod(java.lang.String name)
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
getBroadcastMethod
in interfaceBroadcastService
- Returns:
- BroadcastMethod
-
getMethods
protected java.util.List<DefaultBroadcastService.MethodWrapper> getMethods()
-
initMethods
public void initMethods()
-
startPingHandler
protected void startPingHandler()
-
loadMethods
protected java.util.List<DefaultBroadcastService.MethodWrapper> loadMethods()
-
loadLoopbackMethods
protected java.util.List<DefaultBroadcastService.MethodWrapper> loadLoopbackMethods()
-
loadConfiguredMethods
protected java.util.List<DefaultBroadcastService.MethodWrapper> loadConfiguredMethods()
-
createMethod
protected DefaultBroadcastService.MethodWrapper createMethod(java.lang.String name, java.lang.Class clazz)
-
registerBroadcastListener
public void registerBroadcastListener(BroadcastMessageListener listener, boolean remoteMessagesOnly)
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
registerBroadcastListener
in interfaceBroadcastService
-
unregisterBroadcastListener
public void unregisterBroadcastListener(BroadcastMessageListener listener)
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
unregisterBroadcastListener
in interfaceBroadcastService
-
getClusterIslandPK
public long getClusterIslandPK()
-
getClusterNodeID
public int getClusterNodeID()
-
isClusteringEnabled
public boolean isClusteringEnabled()
-
addTransportData
public void addTransportData(RawMessage message)
-
send
public void send(RawMessage message)
Description copied from interface:BroadcastService
TODO apidoc- Specified by:
send
in interfaceBroadcastService
-
sendSynchronously
protected void sendSynchronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message)
Sends a message synchronously.- Parameters:
methodWrapper
- the method wrappermessage
- the message to send
-
sendAsnychronously
protected void sendAsnychronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message, Tenant currentTenant, java.util.concurrent.ExecutorService executorService) throws java.util.concurrent.RejectedExecutionException
Sends a message using a executor service. In case the service is rejecting the message this method blocks and tries to send the message again until the configured wait timeout has been reached.- Parameters:
methodWrapper
- the method wrappermessage
- the messagecurrentTenant
- the current tenant to be used when sendingexecutorService
- the executor service- Throws:
java.util.concurrent.RejectedExecutionException
-
accept
public boolean accept(RawMessage message)
Determines whether or not a specific message is being accepted.Currently only message from other cluster nodes (determined by their dynamic node ID) and the same cluster island PK are accepted.
- Specified by:
accept
in interfaceBroadcastService
- Parameters:
message
- the message to check- Returns:
- true if the message is being accepted
-
isDuplicateMessage
protected boolean isDuplicateMessage(RawMessage message)
-
isLocal
protected boolean isLocal(RawMessage message)
-
processMessageFromMethod
protected void processMessageFromMethod(RawMessage message, java.lang.String methodName)
-
destroy
public void destroy()
-
-