public abstract class AbstractWanPublisher extends Object implements com.hazelcast.wan.WanReplicationPublisher, WanReplicationEndpoint, WanEventQueueMigrationListener
| Modifier and Type | Field and Description |
|---|---|
protected WanConfigurationContext |
configurationContext |
protected PollSynchronizerPublisherQueueContainer |
eventQueueContainer |
protected long |
lastQueueFullLogTimeMs |
protected String |
localGroupName |
protected com.hazelcast.logging.ILogger |
logger |
protected com.hazelcast.instance.Node |
node |
protected int |
queueCapacity |
protected com.hazelcast.config.WANQueueFullBehavior |
queueFullBehavior |
protected int |
queueLoggerTimePeriodMs |
protected boolean |
running |
protected com.hazelcast.config.WanPublisherState |
state |
protected WanPublisherSyncSupport |
syncSupport |
protected com.hazelcast.enterprise.wan.replication.WanElementCounter |
wanCounter |
protected String |
wanPublisherId |
protected String |
wanReplicationName |
| Constructor and Description |
|---|
AbstractWanPublisher() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCacheQueue(String name,
int partitionId,
WanReplicationEventQueue eventQueue)
Publishes all events from the
eventQueue to the WAN queue for
the given partition ID and cache name. |
void |
addMapQueue(String name,
int partitionId,
WanReplicationEventQueue eventQueue)
Publishes all events from the
eventQueue to the WAN queue for
the given partition ID and map name. |
protected void |
afterShutdown() |
void |
checkWanReplicationQueues() |
void |
clearQueues()
Clears the WAN queues and recalculates the WAN queue sizes.
|
void |
collectAllServiceNamespaces(com.hazelcast.spi.PartitionReplicationEvent event,
Set<com.hazelcast.spi.ServiceNamespace> namespaces)
Collect the namespaces of all queues that should be replicated by the replication event.
|
void |
collectReplicationData(String wanReplicationName,
com.hazelcast.spi.PartitionReplicationEvent event,
Collection<com.hazelcast.spi.ServiceNamespace> namespaces,
EWRMigrationContainer migrationDataContainer)
Collect all replication data for the specific replication event and
collection of namespaces being replicated.
|
protected abstract WanPublisherSyncSupport |
createWanSyncSupport()
Creates the instance implementing WAN sync features.
|
void |
decrementCounter(int delta,
boolean isPrimary)
Decrements the primary or backup counter by the given
delta. |
void |
destroyMapData(String mapName)
Releases all resources for the map with the given
mapName. |
int |
getCurrentBackupElementCount()
Returns the count for the number of events currently in the WAN
map/cache partition queues for partitions for which this node is
a backup replica.
|
int |
getCurrentElementCount()
Returns the count for the number of events currently in the WAN
map/cache partition queues for partitions owned by this node.
|
protected int |
getPartitionId(Object key)
Returns the partition ID for the partition owning the
key |
PublisherQueueContainer |
getPublisherQueueContainer()
Returns the WAN event queue container for this publisher.
|
com.hazelcast.monitor.LocalWanPublisherStats |
getStats()
Gathers statistics of related
WanReplicationEndpoint instance. |
void |
init(com.hazelcast.instance.Node node,
com.hazelcast.config.WanReplicationConfig wanReplicationConfig,
com.hazelcast.config.WanPublisherConfig publisherConfig)
Initializes the endpoint using the given arguments.
|
abstract boolean |
isConnected()
Tests is there is at least one alive connection to a configured
target cluster member over WAN.
|
void |
onMigrationCommit(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
Indicates that migration is committing for a given partition
|
void |
onMigrationRollback(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
Indicates that migration is rolling back for a given partition
|
void |
onMigrationStart(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
Indicates that migration started for a given partition
|
void |
onWanQueueClearedDuringMigration(int partitionId,
int currentReplicaIndex,
int clearedQueueDepth)
Indicates that a partition's WAN event queue is cleared during
migration
|
void |
pause()
Calls to this method will pause WAN event queue polling.
|
abstract void |
publishAntiEntropyEvent(WanAntiEntropyEvent event)
Publishes a WAN anti-entropy event.
|
void |
publishReplicationEvent(String serviceName,
com.hazelcast.wan.ReplicationEventObject eventObject) |
void |
publishReplicationEvent(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
This implementation achieves ordering of keys in the same partition by
sending
EWRPutOperation to the partition owner. |
void |
publishReplicationEventBackup(String serviceName,
com.hazelcast.wan.ReplicationEventObject eventObject) |
void |
publishSyncEvent(WanSyncEvent event)
Publishes a WAN sync event for all or a specific map and for all or
some partitions.
|
void |
putBackup(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
Puts the given
wanReplicationEvent in the corresponding WAN backup
queue. |
void |
removeBackup(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
Remove the oldest replication event from the replication queue and
decrease the backup event count.
|
void |
removeBackups(String serviceName,
String objectName,
int partitionId,
int count)
Removes a
count number of events from a WAN replication queue
belonging to the provided service, object and partition. |
void |
removeReplicationEvent(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
Updates the WAN statistics (remaining map sync events, synced partitions,
queued event count, latencies, sent events) and removes the backup events
on the replicas.
|
void |
reset()
Resets the publisher.
|
void |
resume()
This method re-enables WAN event queue polling for a paused or stopped
WanReplicationEndpoint instance. |
void |
shutdown()
Signals the publisher to shut down and clean up its resources.
|
void |
stop()
Calls to this method will stop WAN replication.
|
protected final com.hazelcast.enterprise.wan.replication.WanElementCounter wanCounter
protected volatile com.hazelcast.config.WanPublisherState state
protected volatile boolean running
protected volatile long lastQueueFullLogTimeMs
protected int queueCapacity
protected int queueLoggerTimePeriodMs
protected com.hazelcast.instance.Node node
protected com.hazelcast.logging.ILogger logger
protected String localGroupName
protected String wanPublisherId
protected String wanReplicationName
protected com.hazelcast.config.WANQueueFullBehavior queueFullBehavior
protected WanConfigurationContext configurationContext
protected PollSynchronizerPublisherQueueContainer eventQueueContainer
protected WanPublisherSyncSupport syncSupport
public void init(com.hazelcast.instance.Node node,
com.hazelcast.config.WanReplicationConfig wanReplicationConfig,
com.hazelcast.config.WanPublisherConfig publisherConfig)
WanReplicationEndpointinit in interface WanReplicationEndpointnode - the current node that tries to connectwanReplicationConfig - the replication configpublisherConfig - this endpoint will be initialized using
this WanPublisherConfig instanceprotected int getPartitionId(Object key)
keypublic void publishReplicationEvent(String serviceName, com.hazelcast.wan.ReplicationEventObject eventObject)
publishReplicationEvent in interface com.hazelcast.wan.WanReplicationPublisherpublic void publishReplicationEventBackup(String serviceName, com.hazelcast.wan.ReplicationEventObject eventObject)
publishReplicationEventBackup in interface com.hazelcast.wan.WanReplicationPublisherpublic void removeBackups(String serviceName, String objectName, int partitionId, int count)
count number of events from a WAN replication queue
belonging to the provided service, object and partition.serviceName - the service name for the WAN replication queueobjectName - the object name for the WAN replication queuepartitionId - the partition ID of the WAN replication queuecount - the number of events to remove from the queuepublic void removeReplicationEvent(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
wanReplicationEvent - the completed replication eventcom.hazelcast.nio.serialization.HazelcastSerializationException - when the event fails to serializationpublic void removeBackup(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
WanReplicationEndpointwanReplicationEvent.removeBackup in interface WanReplicationEndpointwanReplicationEvent - the completed wan eventpublic void putBackup(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
WanReplicationEndpointwanReplicationEvent in the corresponding WAN backup
queue.putBackup in interface WanReplicationEndpointwanReplicationEvent - the WAN eventpublic PublisherQueueContainer getPublisherQueueContainer()
WanReplicationEndpointgetPublisherQueueContainer in interface WanReplicationEndpointpublic void addMapQueue(String name, int partitionId, WanReplicationEventQueue eventQueue)
WanReplicationEndpointeventQueue to the WAN queue for
the given partition ID and map name.addMapQueue in interface WanReplicationEndpointname - the name of the map to which to publish topartitionId - the partition to which to publish toeventQueue - the event queue from which events are publishedpublic void addCacheQueue(String name, int partitionId, WanReplicationEventQueue eventQueue)
WanReplicationEndpointeventQueue to the WAN queue for
the given partition ID and cache name.addCacheQueue in interface WanReplicationEndpointname - the name of the cache to which to publish topartitionId - the partition to which to publish toeventQueue - the event queue from which events are publishedpublic final void shutdown()
WanReplicationEndpointshutdown in interface WanReplicationEndpointprotected void afterShutdown()
public void pause()
WanReplicationEndpointWanReplicationEndpoint instance.
WAN events will still be offered to WAN replication queues but they won't be polled. This means that the queues might eventually fill up and start dropping events.
Calling this method on already paused WanReplicationEndpoint
instances will have no effect.
pause in interface WanReplicationEndpointWanReplicationEndpoint.resume()public void stop()
WanReplicationEndpointWanReplicationEndpoint.pause() method, an endpoint which is stopped
will not enqueue events. This method will not clear the WAN queues, though.
This means that once this method returns, there might still be some WAN
events enqueued but these events will not be replicated until the publisher
is resumed.
Calling this method on already stopped WanReplicationEndpoint
instances will have no effect.
stop in interface WanReplicationEndpointWanReplicationEndpoint.resume()public void resume()
WanReplicationEndpointWanReplicationEndpoint instance.
Calling this method on already running WanReplicationEndpoint
instances will have no effect.
resume in interface WanReplicationEndpointWanReplicationEndpoint.pause(),
WanReplicationEndpoint.stop()public com.hazelcast.monitor.LocalWanPublisherStats getStats()
WanReplicationEndpointWanReplicationEndpoint instance. This method will always return the
same instance.getStats in interface WanReplicationEndpointLocalWanPublisherStatspublic abstract boolean isConnected()
true if there is at least one alive connection, false otherwisepublic void checkWanReplicationQueues()
checkWanReplicationQueues in interface com.hazelcast.wan.WanReplicationPublisherpublic void publishReplicationEvent(com.hazelcast.wan.WanReplicationEvent wanReplicationEvent)
EWRPutOperation to the partition owner. The partition ID
is equal to the partition for the key contained in the wanReplicationEvent.publishReplicationEvent in interface com.hazelcast.wan.WanReplicationPublisherwanReplicationEvent - the WAN event to publishpublic void publishSyncEvent(WanSyncEvent event)
WanReplicationEndpointpublishSyncEvent in interface WanReplicationEndpointevent - the WAN sync requestpublic abstract void publishAntiEntropyEvent(WanAntiEntropyEvent event)
event - the WAN anti-entropy eventpublic void destroyMapData(String mapName)
mapName.mapName - the map namepublic void clearQueues()
WanReplicationEndpointclearQueues in interface WanReplicationEndpointpublic void decrementCounter(int delta,
boolean isPrimary)
delta.delta - the delta by which we need to decrement the counterisPrimary - true if the primary WAN event queue counter needs to be decremented,
false if the backup WAN event queue counter needs to be decrementedpublic void onMigrationStart(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
WanEventQueueMigrationListeneronMigrationStart in interface WanEventQueueMigrationListenerpartitionId - the partition being migratedcurrentReplicaIndex - the current replica index of the partitionnewReplicaIndex - the new replica index if the partitionpublic void onMigrationCommit(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
WanEventQueueMigrationListeneronMigrationCommit in interface WanEventQueueMigrationListenerpartitionId - the partition being migratedcurrentReplicaIndex - the current replica index of the partitionnewReplicaIndex - the new replica index if the partitionpublic void onMigrationRollback(int partitionId,
int currentReplicaIndex,
int newReplicaIndex)
WanEventQueueMigrationListeneronMigrationRollback in interface WanEventQueueMigrationListenerpartitionId - the partition being migratedcurrentReplicaIndex - the current replica index of the partitionnewReplicaIndex - the new replica index if the partitionpublic void onWanQueueClearedDuringMigration(int partitionId,
int currentReplicaIndex,
int clearedQueueDepth)
WanEventQueueMigrationListeneronWanQueueClearedDuringMigration in interface WanEventQueueMigrationListenerpartitionId - the partition being migratedcurrentReplicaIndex - the current replica index of the partitionclearedQueueDepth - the depth of the migrated WAN queuepublic void reset()
public int getCurrentElementCount()
public int getCurrentBackupElementCount()
public void collectAllServiceNamespaces(com.hazelcast.spi.PartitionReplicationEvent event,
Set<com.hazelcast.spi.ServiceNamespace> namespaces)
WanReplicationEndpointcollectAllServiceNamespaces in interface WanReplicationEndpointevent - the replication eventnamespaces - the set in which namespaces should be addedpublic void collectReplicationData(String wanReplicationName, com.hazelcast.spi.PartitionReplicationEvent event, Collection<com.hazelcast.spi.ServiceNamespace> namespaces, EWRMigrationContainer migrationDataContainer)
WanReplicationEndpointcollectReplicationData in interface WanReplicationEndpointwanReplicationName - the WAN replication name in the hazelcast
configuration for this endpointevent - the replication eventnamespaces - the object namespaces which are being
replicatedmigrationDataContainer - the container for the migration dataprotected abstract WanPublisherSyncSupport createWanSyncSupport()
null.Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.