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 classDefaultBroadcastService.MethodBroadcastListenerInner class to connect this service to all broadcast methods.protected static classDefaultBroadcastService.MethodWrapper
-
Field Summary
Fields Modifier and Type Field Description static intCUR_VERSIONstores 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 booleanaccept(RawMessage message)Determines whether or not a specific message is being accepted.voidaddTransportData(RawMessage message)protected java.util.concurrent.ExecutorServicecreateMessageSendingExecutorService()protected DefaultBroadcastService.MethodWrappercreateMethod(java.lang.String name, java.lang.Class clazz)voiddestroy()BroadcastMethodgetBroadcastMethod(java.lang.String name)TODO apidocjava.util.Set<java.lang.String>getBroadcastMethodNames()TODO apidoclonggetClusterIslandPK()intgetClusterNodeID()longgetDynamicClusterNodeID()TODO apidocstatic DefaultBroadcastServicegetInstance()protected java.util.concurrent.ExecutorServicegetMessageSendingExecutorService()protected java.util.List<DefaultBroadcastService.MethodWrapper>getMethods()protected java.lang.StringgetStartupInfo()voidinitMethods()booleanisClusteringEnabled()protected booleanisDuplicateMessage(RawMessage message)protected booleanisLocal(RawMessage message)protected java.util.List<DefaultBroadcastService.MethodWrapper>loadConfiguredMethods()protected java.util.List<DefaultBroadcastService.MethodWrapper>loadLoopbackMethods()protected java.util.List<DefaultBroadcastService.MethodWrapper>loadMethods()protected voidprocessMessageFromMethod(RawMessage message, java.lang.String methodName)voidregisterBroadcastListener(BroadcastMessageListener listener, boolean remoteMessagesOnly)TODO apidocvoidsend(RawMessage message)TODO apidocprotected voidsendAsnychronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message, Tenant currentTenant, java.util.concurrent.ExecutorService executorService)Sends a message using a executor service.protected voidsendSynchronously(DefaultBroadcastService.MethodWrapper methodWrapper, RawMessage message)Sends a message synchronously.protected voidstartPingHandler()voidunregisterBroadcastListener(BroadcastMessageListener listener)TODO apidocprotected voidupdateNodeIDsFromDatabase()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:BroadcastServiceTODO apidoc- Specified by:
getDynamicClusterNodeIDin interfaceBroadcastService- Returns:
- the dynamic cluster node id
-
getBroadcastMethodNames
public java.util.Set<java.lang.String> getBroadcastMethodNames()
Description copied from interface:BroadcastServiceTODO apidoc- Specified by:
getBroadcastMethodNamesin interfaceBroadcastService- Returns:
- Set
-
getBroadcastMethod
public BroadcastMethod getBroadcastMethod(java.lang.String name)
Description copied from interface:BroadcastServiceTODO apidoc- Specified by:
getBroadcastMethodin 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:BroadcastServiceTODO apidoc- Specified by:
registerBroadcastListenerin interfaceBroadcastService
-
unregisterBroadcastListener
public void unregisterBroadcastListener(BroadcastMessageListener listener)
Description copied from interface:BroadcastServiceTODO apidoc- Specified by:
unregisterBroadcastListenerin 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:BroadcastServiceTODO apidoc- Specified by:
sendin 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:
acceptin 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()
-
-