Class MultiRegionTransport<S,R>
- java.lang.Object
-
- com.attivio.sdk.transport.MultiRegionTransport<S,R>
-
- All Implemented Interfaces:
ClientTransport<S>
,SelfManagedTransport<S,R>
,Transport<S,R>
public abstract class MultiRegionTransport<S,R> extends java.lang.Object implements SelfManagedTransport<S,R>
ASelfManagedTransport
that is used explicitly for sending messages from one region to another. The inclusion of this transport in the project configuration signifies that multi-region replication should be enabled on that projectSubclasses SHOULD NOT override
sendMessage(PlatformMessage, Object)
ordispatchMessage(PlatformMessage, Object)
, but onlydispatchMessage(MessageList, Object, MessageListTransportCallback)
Subclasses should use the
emitMessage(MessageList, URI)
on this class to emit messages from its receiver to the uri that was given to create the receiver. Messages should remain available for re-emission (in case of an unexpected shutdown) until the methodrelease(PlatformMessage)
is called for the message. If this practice is not followed, multi-region replication cannot be guaranteedThe scheme of this transport is fixed and SHOULD NOT BE OVEWRITTEN. This transport cannot do synchronous messaging and as such will have to support sending with a callback hook for completion. This transport is also obliged to keep track of the number of messages it has sent and received by destination.
Serialization must be handled by implementers of this class. There is an XMLSerializer utility singleton object available to sdk users that can serialize messages to xml - this should work well as a default if the implementer does not particularly care how serialization is performed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultiRegionTransport.MultiRegionIndexType
MultiRegionTransport.MultiRegionIndexType
defines which conceptual indexes are supported for multi-region replication.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLIENT_DEPENDENCY_PROP
property on PlatformMessages indicating that the message depends on the completion of a previous client.protected java.lang.String
id
An id for this multi-region transport and by extension the id of this system in the multi-region topology.static org.slf4j.Logger
LOG
static java.lang.String
REGION_SCHEME
Static scheme for allMultiRegionTransport
implementationsstatic java.lang.String
REGION_TRANSFER_NAME
property on PlatformMessages indicating the client name associated with a message transferred from another region.static java.lang.String
REGION_TRANSFER_PROPERTY
Property on PlatformMessages indicating where this message should be sent - corresponds to a messages data group
-
Constructor Summary
Constructors Constructor Description MultiRegionTransport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.Map<java.lang.String,java.lang.Long>
bytesReceivedPerDestination()
Retrieve the total bytes received per destination.abstract java.util.Map<java.lang.String,java.lang.Long>
bytesSentPerDestination()
Retrieve the total bytes sent per destination.abstract void
dispatchMessage(MessageList msg, S sender, MessageListTransportCallback acknowledgement)
Dispatches a message to a multi-region queue using a given sender and runs aBiConsumer
after a write to the queue has been attempted.void
dispatchMessage(PlatformMessage msg, S sender)
Asynchronously send a message via the provided sender with no expected return.abstract java.util.Map<java.lang.String,java.lang.Long>
docsReceivedPerDestination()
Retrieve the total documents received per destination.abstract java.util.Map<java.lang.String,java.lang.Long>
docsSentPerDestination()
Retrieve the total documents sent per destination.void
emitMessage(MessageList messageList, java.net.URI uri)
Emit a message to the Attivio internal routing and processing system for multi-region replication messages.java.util.Set<java.lang.String>
getBlackListedDataGroups()
java.util.Set<java.lang.String>
getBlackListedZones()
java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getConfiguredIndexes()
Retrieve the configured indexes by type.java.lang.String
getId()
java.lang.String
getProtocol()
Get the String protocol that this transports implements.boolean
isMaster()
abstract java.util.Map<java.lang.String,java.lang.Long>
messagesReceivedPerDestination()
Retrieve the total messages received per destination.abstract java.util.Map<java.lang.String,java.lang.Long>
messagesSentPerDestination()
Retrieve the total messages sent per destination.abstract void
release(PlatformMessage msg)
Release a message from potential re-emissionPlatformMessage
sendMessage(PlatformMessage msg, S sender)
Synchronously send a message via the provided sender.void
setBlackListedDataGroups(java.util.Set<java.lang.String> blackListedDataGroups)
void
setBlackListedZones(java.util.Set<java.lang.String> blackListedZones)
void
setConfiguredIndexes(java.util.Map<java.lang.String,java.util.List<java.lang.String>> configuredIndexes)
Sets the configured indexes by type.void
setId(java.lang.String id)
void
setMaster(boolean master)
void
setMessageEmitter(MessageEmitter manager)
Sets the MessageEmitter.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.attivio.sdk.transport.ClientTransport
createSender, getSender, shutdown, stopSender
-
Methods inherited from interface com.attivio.sdk.transport.Transport
createReceiver, initialize, prepareReceiver, setDefaultQueueSize, stopReceiver
-
-
-
-
Field Detail
-
LOG
public static final org.slf4j.Logger LOG
-
REGION_SCHEME
public static final java.lang.String REGION_SCHEME
Static scheme for allMultiRegionTransport
implementations- See Also:
- Constant Field Values
-
REGION_TRANSFER_PROPERTY
public static final java.lang.String REGION_TRANSFER_PROPERTY
Property on PlatformMessages indicating where this message should be sent - corresponds to a messages data group- See Also:
- Constant Field Values
-
CLIENT_DEPENDENCY_PROP
public static final java.lang.String CLIENT_DEPENDENCY_PROP
property on PlatformMessages indicating that the message depends on the completion of a previous client.- See Also:
- Constant Field Values
-
REGION_TRANSFER_NAME
public static final java.lang.String REGION_TRANSFER_NAME
property on PlatformMessages indicating the client name associated with a message transferred from another region.- See Also:
- Constant Field Values
-
id
protected java.lang.String id
An id for this multi-region transport and by extension the id of this system in the multi-region topology.This is meant to a be a name the identifies this system uniquely
-
-
Method Detail
-
getId
public java.lang.String getId()
-
setId
public void setId(java.lang.String id)
-
isMaster
public boolean isMaster()
-
setMaster
public void setMaster(boolean master)
-
getBlackListedDataGroups
public java.util.Set<java.lang.String> getBlackListedDataGroups()
-
setBlackListedDataGroups
public void setBlackListedDataGroups(java.util.Set<java.lang.String> blackListedDataGroups)
-
getBlackListedZones
public java.util.Set<java.lang.String> getBlackListedZones()
-
setBlackListedZones
public void setBlackListedZones(java.util.Set<java.lang.String> blackListedZones)
-
getConfiguredIndexes
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConfiguredIndexes()
Retrieve the configured indexes by type.This method is marked
JsonIgnore
to prevent serialization.- Returns:
Map
ofMultiRegionTransport.MultiRegionIndexType
key and index namesList
value
-
setConfiguredIndexes
public void setConfiguredIndexes(java.util.Map<java.lang.String,java.util.List<java.lang.String>> configuredIndexes)
Sets the configured indexes by type.This method is marked
JsonProperty
to allow deserialization.
-
getProtocol
public java.lang.String getProtocol()
Get the String protocol that this transports implements.This will register this protocol with Attivio for message delivery.
For example if this method returned "foo" then URI's of the form:
foo://someUriSyntax:8000/goes?here
would be processed using this transport. This must return a constant value and must return that value as soon as the object is constructed as the value is registered with the platform and can not be changed once registered.- Specified by:
getProtocol
in interfaceClientTransport<S>
-
sendMessage
public PlatformMessage sendMessage(PlatformMessage msg, S sender) throws TransportException
Synchronously send a message via the provided sender.- Specified by:
sendMessage
in interfaceClientTransport<S>
- Parameters:
msg
- the message to send.sender
- the sender that was chosen based on the URI that the message must be sent toThis method can block as long as is required to send the message including allowing time for the receiver to free up resources.
- Throws:
TransportException
-
dispatchMessage
public void dispatchMessage(PlatformMessage msg, S sender) throws TransportException
Asynchronously send a message via the provided sender with no expected return.- Specified by:
dispatchMessage
in interfaceClientTransport<S>
- Parameters:
msg
- the message to send.sender
- the sender that was chosen based on the URI that the message must be sent to- Throws:
TransportException
-
setMessageEmitter
public void setMessageEmitter(MessageEmitter manager)
Description copied from interface:SelfManagedTransport
Sets the MessageEmitter.This should be held onto so that received messages can be routed into the platform.
- Specified by:
setMessageEmitter
in interfaceSelfManagedTransport<S,R>
-
emitMessage
public void emitMessage(MessageList messageList, java.net.URI uri) throws TransportException
Emit a message to the Attivio internal routing and processing system for multi-region replication messages. This method should be called at least once for all messages received by this transport- Throws:
TransportException
-
dispatchMessage
public abstract void dispatchMessage(MessageList msg, S sender, MessageListTransportCallback acknowledgement)
Dispatches a message to a multi-region queue using a given sender and runs aBiConsumer
after a write to the queue has been attempted. The given acknowledgement MUST be used after any write attempt; if successful invokeMessageListTransportCallback.success(MessageList)
, otherwise invokeMessageListTransportCallback.failure(MessageList, Throwable)
The transport implementation is obligated to keep track of the
MessageList
objects sent to it so that it can pass those objects that into one of the acknowledge callback methods attempted to write (successfully or not) in the acknowledgement
-
release
public abstract void release(PlatformMessage msg)
Release a message from potential re-emissionThis method will be invoked on this transport when the message received herefrom has made it to a stage that can guarantee its resilience thus the resilience provided by this transport is no longer needed
-
docsSentPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> docsSentPerDestination()
Retrieve the total documents sent per destination.- Returns:
Map
total documents sent perString
destination
-
messagesSentPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> messagesSentPerDestination()
Retrieve the total messages sent per destination.Messages in this case mean individual messages within the
MessageList
passed in viadispatchMessage(MessageList, Object, MessageListTransportCallback)
. The number of messages in aMessageList
can be obtained usingArrayList.size()
- Returns:
Map
total messages sent perString
destination
-
docsReceivedPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> docsReceivedPerDestination()
Retrieve the total documents received per destination.- Returns:
Map
total documents received perString
destination
-
messagesReceivedPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> messagesReceivedPerDestination()
Retrieve the total messages received per destination.Messages in this case mean individual messages within the
MessageList
passed in viadispatchMessage(MessageList, Object, MessageListTransportCallback)
and subsequently received by this transport. The number of messages in aMessageList
can be obtained usingArrayList.size()
- Returns:
Map
total messages received perString
destination
-
bytesSentPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> bytesSentPerDestination()
Retrieve the total bytes sent per destination.Bytes in this case mean the byte total of individual messages within the
MessageList
passed in viadispatchMessage(MessageList, Object, MessageListTransportCallback)
. The estimated (good enough for this metric) bytes in aPlatformMessage
can be obtained usingPlatformMessage.getEstimatedSize()
- Returns:
Map
total bytes sent perString
destination
-
bytesReceivedPerDestination
public abstract java.util.Map<java.lang.String,java.lang.Long> bytesReceivedPerDestination()
Retrieve the total bytes received per destination.Bytes in this case mean the byte total of individual messages within the
MessageList
passed in viadispatchMessage(MessageList, Object, MessageListTransportCallback)
and subsequently received by this transport. The estimated (good enough for this metric) bytes in aPlatformMessage
can be obtained usingPlatformMessage.getEstimatedSize()
- Returns:
Map
total bytes retrieved perString
destination
-
-