Package com.linkedin.venice.helix
Class HelixStatusMessageChannel
- java.lang.Object
-
- com.linkedin.venice.helix.HelixStatusMessageChannel
-
- All Implemented Interfaces:
StatusMessageChannel
public class HelixStatusMessageChannel extends java.lang.Object implements StatusMessageChannel
The control message changed built on Helix message service.It will convert Venice message to helix message when sending and reverse this process when receiving.
Only one Helix message type is used, so channel is similar to a dispatcher that receive all of control messages and dispatch them to related handlers.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_SEND_MESSAGE_TIME_OUT
static java.lang.String
HELIX_MESSAGE_TYPE
static java.lang.String
VENICE_MESSAGE_CLASS
static java.lang.String
VENICE_MESSAGE_FIELD
-
Constructor Summary
Constructors Constructor Description HelixStatusMessageChannel(SafeHelixManager manager, HelixMessageChannelStats stats)
HelixStatusMessageChannel(SafeHelixManager manager, HelixMessageChannelStats stats, int timeOut)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StatusMessage
convertHelixMessageToVeniceMessage(org.apache.helix.model.Message helixMessage)
Convert Helix message to Venice Message.protected org.apache.helix.model.Message
convertVeniceMessageToHelixMessage(StatusMessage veniceMessage)
Convert Venice message to Helix message.protected <T extends StatusMessage>
StatusMessageHandlergetHandler(java.lang.Class<T> clazz)
Get the handler for given Venice message type.<T extends StatusMessage>
voidregisterHandler(java.lang.Class<T> clazz, StatusMessageHandler<T> handler)
Register a handler to handle a specific message type.void
sendToController(StatusMessage message)
Send message to controller.void
sendToController(StatusMessage message, int retryCount, long retryDurationMs)
Send message to controller.void
sendToStorageNodes(java.lang.String clusterName, StatusMessage message, java.lang.String resourceName, int retryCount)
Send message to all storage nodes in the given cluster.<T extends StatusMessage>
voidunRegisterHandler(java.lang.Class<T> clazz, StatusMessageHandler<T> handler)
Remove a handler for a specific message type.
-
-
-
Field Detail
-
DEFAULT_SEND_MESSAGE_TIME_OUT
public static final int DEFAULT_SEND_MESSAGE_TIME_OUT
- See Also:
- Constant Field Values
-
HELIX_MESSAGE_TYPE
public static final java.lang.String HELIX_MESSAGE_TYPE
- See Also:
- Constant Field Values
-
VENICE_MESSAGE_CLASS
public static final java.lang.String VENICE_MESSAGE_CLASS
- See Also:
- Constant Field Values
-
VENICE_MESSAGE_FIELD
public static final java.lang.String VENICE_MESSAGE_FIELD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HelixStatusMessageChannel
public HelixStatusMessageChannel(SafeHelixManager manager, HelixMessageChannelStats stats)
-
HelixStatusMessageChannel
public HelixStatusMessageChannel(SafeHelixManager manager, HelixMessageChannelStats stats, int timeOut)
-
-
Method Detail
-
sendToController
public void sendToController(StatusMessage message, int retryCount, long retryDurationMs)
Description copied from interface:StatusMessageChannel
Send message to controller. If met any error during the sending, retry it after retryDurationMs until retry @retryCount times.- Specified by:
sendToController
in interfaceStatusMessageChannel
retryCount
- retry how many times.retryDurationMs
- the duration between two retries.
-
sendToController
public void sendToController(StatusMessage message)
Description copied from interface:StatusMessageChannel
Send message to controller.- Specified by:
sendToController
in interfaceStatusMessageChannel
-
sendToStorageNodes
public void sendToStorageNodes(java.lang.String clusterName, StatusMessage message, java.lang.String resourceName, int retryCount)
Description copied from interface:StatusMessageChannel
Send message to all storage nodes in the given cluster. If met any error during the sending, retry it after retryDurationMs until retry @retryCount times.- Specified by:
sendToStorageNodes
in interfaceStatusMessageChannel
-
registerHandler
public <T extends StatusMessage> void registerHandler(java.lang.Class<T> clazz, StatusMessageHandler<T> handler)
Description copied from interface:StatusMessageChannel
Register a handler to handle a specific message type.- Specified by:
registerHandler
in interfaceStatusMessageChannel
-
unRegisterHandler
public <T extends StatusMessage> void unRegisterHandler(java.lang.Class<T> clazz, StatusMessageHandler<T> handler)
Description copied from interface:StatusMessageChannel
Remove a handler for a specific message type.- Specified by:
unRegisterHandler
in interfaceStatusMessageChannel
-
convertHelixMessageToVeniceMessage
protected StatusMessage convertHelixMessageToVeniceMessage(org.apache.helix.model.Message helixMessage)
Convert Helix message to Venice Message.- Parameters:
helixMessage
-- Returns:
-
convertVeniceMessageToHelixMessage
protected org.apache.helix.model.Message convertVeniceMessageToHelixMessage(StatusMessage veniceMessage)
Convert Venice message to Helix message.- Parameters:
veniceMessage
-- Returns:
-
getHandler
protected <T extends StatusMessage> StatusMessageHandler getHandler(java.lang.Class<T> clazz)
Get the handler for given Venice message type.- Type Parameters:
T
-- Parameters:
clazz
-- Returns:
-
-