public class PartitionManagerImpl extends Object implements PartitionManager
PartitionManager services based on Infinispan cache.
This implementation uses a consistent hashing strategy https://en.wikipedia.org/wiki/Consistent_hashing
as a method to partition triggers across nodes.
It needs three caches added into Wildfly/JBoss configuration files.
standalone.xml:
[...]
| Modifier and Type | Class and Description |
|---|---|
class |
PartitionManagerImpl.NewDataListener |
class |
PartitionManagerImpl.NewTriggerListener |
static class |
PartitionManagerImpl.NotifyData
Auxiliary class to store in the cache an operation for a Data/Event
Used internally in the context of the PartitionManager services.
|
static class |
PartitionManagerImpl.NotifyTrigger
Auxiliary class to store in the cache an operation for a Trigger.
|
class |
PartitionManagerImpl.PartitionChangeListener |
static class |
PartitionManagerImpl.PartitionEntry
Auxiliary class to store in the cache a Trigger entry.
|
class |
PartitionManagerImpl.TopologyChangeListener
Auxiliary interface to add Infinispan listener to the caches
|
PartitionManager.Operation| Modifier and Type | Field and Description |
|---|---|
static String |
BUCKETS |
static String |
CURRENT |
static String |
PARTITION_CHANGE |
static String |
PREVIOUS |
| Constructor and Description |
|---|
PartitionManagerImpl() |
| Modifier and Type | Method and Description |
|---|---|
Integer |
calculateNewEntry(PartitionManagerImpl.PartitionEntry newEntry,
Map<Integer,Integer> buckets)
Distribute a new entry across buckets using a consistent hashing strategy.
|
Map<PartitionManagerImpl.PartitionEntry,Integer> |
calculatePartition(List<PartitionManagerImpl.PartitionEntry> entries,
Map<Integer,Integer> buckets)
Distribute triggers on nodes using a consistent hashing strategy.
|
protected Map<String,Map<String,List<String>>> |
getAddedRemovedPartition(Map<PartitionManagerImpl.PartitionEntry,Integer> previous,
Map<PartitionManagerImpl.PartitionEntry,Integer> current,
Integer node) |
Map<String,List<String>> |
getNodePartition(Map<PartitionManagerImpl.PartitionEntry,Integer> partition,
Integer node)
Return the entries assigned for a node into a partition.
|
void |
init() |
boolean |
isDistributed()
Detects if PartitionManager is deployed on a distributed scenario.
|
void |
notifyData(Collection<Data> data)
Notify partition manager when a new collection of data has been received.
|
void |
notifyData(Data data)
Notify partition manager when a new data has been received.
|
void |
notifyEvent(Event event)
Notify partition manager when a new event has been received.
|
void |
notifyEvents(Collection<Event> events)
Notify partition manager when a new collection of events has been received.
|
void |
notifyTrigger(PartitionManager.Operation operation,
String tenantId,
String triggerId)
Notify partition manager when a trigger, dampening or condition has been added,updated or removed.
|
void |
registerDataListener(PartitionDataListener dataListener)
Register a listener to process patition events linked with data or events.
|
void |
registerTriggerListener(PartitionTriggerListener triggerListener)
Register a listener to process partition events linked with triggers.
|
Map<Integer,Integer> |
updateBuckets(Map<Integer,Integer> oldBuckets,
List<Integer> members)
Update a nodes table.
|
public static final String BUCKETS
public static final String PREVIOUS
public static final String CURRENT
public static final String PARTITION_CHANGE
public boolean isDistributed()
PartitionManagerPartitionTriggerListener and PartitionDataListener are ignored on non-distributed scenario.
PartitionManager.notifyTrigger(org.hawkular.alerts.engine.service.PartitionManager.Operation, java.lang.String, java.lang.String), PartitionManager.notifyData(org.hawkular.alerts.api.model.data.Data) and
PartitionManager.notifyEvent(org.hawkular.alerts.api.model.event.Event) are ignored on non-distributed scenario.isDistributed in interface PartitionManager@PostConstruct public void init()
public void notifyTrigger(PartitionManager.Operation operation, String tenantId, String triggerId)
PartitionManagernotifyTrigger in interface PartitionManageroperation - type of operation performed on the triggertenantId - Tenant where Trigger is storedtriggerId - Trigger idpublic void registerTriggerListener(PartitionTriggerListener triggerListener)
PartitionManagerregisterTriggerListener in interface PartitionManagertriggerListener - the listenerpublic void notifyData(Data data)
PartitionManagernotifyData in interface PartitionManagerdata - the new data received by the enginepublic void notifyData(Collection<Data> data)
PartitionManagernotifyData in interface PartitionManagerdata - the new data received by the enginepublic void notifyEvent(Event event)
PartitionManagernotifyEvent in interface PartitionManagerevent - the new event received by the enginepublic void notifyEvents(Collection<Event> events)
PartitionManagernotifyEvents in interface PartitionManagerevents - the new events received by the enginepublic void registerDataListener(PartitionDataListener dataListener)
PartitionManagerregisterDataListener in interface PartitionManagerdataListener - the listenerpublic Map<Integer,Integer> updateBuckets(Map<Integer,Integer> oldBuckets, List<Integer> members)
oldBuckets - the old table used as input for the calculationmembers - a new list of memberspublic Map<PartitionManagerImpl.PartitionEntry,Integer> calculatePartition(List<PartitionManagerImpl.PartitionEntry> entries, Map<Integer,Integer> buckets)
entries - a list of entries to distributebuckets - a table of nodespublic Integer calculateNewEntry(PartitionManagerImpl.PartitionEntry newEntry, Map<Integer,Integer> buckets)
newEntry - the new entry to distributebuckets - a table of nodespublic Map<String,List<String>> getNodePartition(Map<PartitionManagerImpl.PartitionEntry,Integer> partition, Integer node)
partition - the partition used internallynode - the node to filterCopyright © 2015 Red Hat, Inc.. All rights reserved.