@ThreadSafe public class ClusteredJournal extends MessageConsumer<ClusteredJournal.DeltaMessage> implements ChangeJournal
ChangeJournal
implementation which runs in a cluster and which attempts to reconcile with other members of the cluster
on startup in order to retrieve missed/lost records.Modifier and Type | Class and Description |
---|---|
protected static class |
ClusteredJournal.DeltaMessage |
ChangeJournal.Records
Modifier | Constructor and Description |
---|---|
|
ClusteredJournal(LocalJournal localJournal,
ClusteringService clusteringService)
Creates a new clustered journal
|
protected |
ClusteredJournal(LocalJournal localJournal,
ClusteringService clusteringService,
int reconciliationMaxWaitTime) |
Modifier and Type | Method and Description |
---|---|
void |
addRecords(JournalRecord... records)
Adds one or more journal records to a journal.
|
ChangeJournal.Records |
allRecords(boolean descendingOrder)
Returns all the records this journal holds
|
Iterator<NodeKey> |
changedNodesSince(long timestamp)
Returns the node keys which are part of change sets that are newer or equal to a given timestamp.
|
protected ClusteringService |
clusteringService() |
protected String |
clusterName() |
void |
consume(ClusteredJournal.DeltaMessage message)
Consumes a payload of the given type.
|
String |
journalId()
Returns the id of this change journal.
|
JournalRecord |
lastRecord()
Returns the last record from the journal.
|
protected LocalJournal |
localJournal() |
void |
notify(ChangeSet changeSet)
Notifies a listener of the given changes.
|
protected boolean |
reconciliationCompleted() |
ChangeJournal.Records |
recordsNewerThan(LocalDateTime changeSetTime,
boolean inclusive,
boolean descendingOrder)
Returns all records that have changesets which are newer than a given timestamp.
|
void |
removeOldRecords()
Removes older entries.
|
void |
shutdown()
Stops the journal.
|
void |
start()
Starts this journal instance.
|
boolean |
started()
Checks if this journal is active (i.e. can accept requests) or not.
|
getPayloadType
public ClusteredJournal(LocalJournal localJournal, ClusteringService clusteringService)
localJournal
- the local ChangeJournal
which willclusteringService
- an ClusteringService
instance.protected ClusteredJournal(LocalJournal localJournal, ClusteringService clusteringService, int reconciliationMaxWaitTime)
public void notify(ChangeSet changeSet)
ChangeSetListener
notify
in interface ChangeSetListener
changeSet
- a non-null
ChangeSet
public void start() throws Exception
ChangeJournal
start
in interface ChangeJournal
Exception
- if anything fails during startpublic void shutdown()
ChangeJournal
shutdown
in interface ChangeJournal
public void removeOldRecords()
ChangeJournal
removeOldRecords
in interface ChangeJournal
public ChangeJournal.Records allRecords(boolean descendingOrder)
ChangeJournal
allRecords
in interface ChangeJournal
descendingOrder
- flag which indicates whether the entriesChangeJournal.Records
instancepublic JournalRecord lastRecord()
ChangeJournal
lastRecord
in interface ChangeJournal
JournalRecord
instance or null
if the journal is empty.public ChangeJournal.Records recordsNewerThan(LocalDateTime changeSetTime, boolean inclusive, boolean descendingOrder)
ChangeJournal
recordsNewerThan
in interface ChangeJournal
changeSetTime
- the LocalDateTime
of the changes representing the lower bound; may be null indicating
that *all the records* should be returned.inclusive
- flag indicating whether the timestamp should be used inclusively or exclusivelydescendingOrder
- flag indicating if the records should be returned in ascending order (oldest to newest) or
descending order (newest to oldest)ChangeJournal.Records
instance; never null
public Iterator<NodeKey> changedNodesSince(long timestamp)
ChangeJournal
changedNodesSince
in interface ChangeJournal
timestamp
- the timestamp of the changes representing the lower bound;Iterator
of NodeKey
instances; never null
, but may contain duplicate keys if the
underlpublic void addRecords(JournalRecord... records)
ChangeJournal
addRecords
in interface ChangeJournal
records
- a JournalRecord
array.public String journalId()
ChangeJournal
journalId
in interface ChangeJournal
String
, never null
public boolean started()
ChangeJournal
started
in interface ChangeJournal
true
if the journal has started, false otherwise
public void consume(ClusteredJournal.DeltaMessage message)
MessageConsumer
consume
in class MessageConsumer<ClusteredJournal.DeltaMessage>
message
- a Serializable
payload.protected boolean reconciliationCompleted()
protected ClusteringService clusteringService()
protected LocalJournal localJournal()
protected String clusterName()
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.