public final class ReplicationHub extends AbstractReplication
ReplicationHub
allows to share TCP/UDP connection, sockets,
buffers, worker threads for that, considerably reducing resources usage and increasing cumulative
(for all replicated containers) replication throughput. See
the corresponding section in ChronicleMap manual for more information.
Create instances of this class using this pattern:
ReplicationHub hub = ReplicationHub.builder()
.tcpTransportAndNetwork(tcpConfig)
// more configurations...
.createWithId(identifierOfThisServerWithinTheChronicleReplicationNetwork);
Then, given you prepared a builder
to create a ChronicleHash
, configure it's replication via channel of this hub like this:
ChronicleMap myMap = builder.instance()
.replicatedViaChannel(hub.createChannel(myMapChannelId))
.persistedTo(myMapFile) // optional, for this example
.create();
Modifier and Type | Class and Description |
---|---|
static class |
ReplicationHub.Builder
Builder of
ReplicationHub s. |
Modifier and Type | Method and Description |
---|---|
static ReplicationHub.Builder |
builder()
Creates and returns a new
ReplicationHub.Builder . |
ReplicationChannel |
createChannel(int channelId)
Creates a new
ReplicationChannel in this ReplicationHub with the given
identifier. |
int |
maxNumberOfChannels()
Returns the maximum number of channels could be created for
this
ReplicationHub . |
String |
toString() |
bootstrapOnlyLocalEntries, connectionListener, identifier, name, remoteNodeValidator, tcpTransportAndNetwork, udpTransport
@NotNull public static ReplicationHub.Builder builder()
ReplicationHub.Builder
.ReplicationHub.Builder
public String toString()
toString
in class AbstractReplication
public int maxNumberOfChannels()
ReplicationHub
.maxNumberOfChannels()
,
createChannel(int)
public ReplicationChannel createChannel(int channelId)
ReplicationChannel
in this ReplicationHub
with the given
identifier. Identifier shouldn't be lesser than zero and greater or equal to maxNumberOfChannels() - 1
. On a ReplicationHub
instance, ReplicationChannel
could be created only once for each possible channelId
value.channelId
- the identifier of the channel. Should be equal for replicated containers on
different nodes (servers)ReplicationChannel
instance, in fact just incapsulating the given
channelId
for this ReplicationHub
IllegalArgumentException
- if the specified channelId
is out of[0,
maxNumberOfChannels()
)
rangeIllegalStateException
- if ReplicationChannel
with the specified channelId
has already been acquired on this ReplicationHub
ReplicationChannel
Copyright © 2016. All rights reserved.