com.continuent.tungsten.common.patterns.order
Class HighWaterResource

java.lang.Object
  extended by com.continuent.tungsten.common.patterns.order.HighWaterResource
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<HighWaterResource>

public class HighWaterResource
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<HighWaterResource>

A HighWater resource allows to represent and compare replicators applied event IDs. It is especially used by session consistency/smart-scale to compared master and slave progresses.
It is composed of a epoch and a event id. The string representation being ()

Author:
Edward Archibald
See Also:
Serialized Form

Constructor Summary
HighWaterResource()
           
HighWaterResource(long epoch, java.lang.String eventId)
           
HighWaterResource(java.lang.String resourceAsString)
           
 
Method Summary
 int compareTo(HighWaterResource o)
          Compare ourselves to what is passed in.
Two uninitialized HW will be equal
An uninitialized HW is always older than an initialized one Epochs comparison is made first, then the offset.
 boolean equals(java.lang.Object obj)
           
 long getHighWaterEpoch()
           
 java.lang.String getHighWaterEventId()
           
static java.lang.String getSessionId(java.lang.String eventId)
           
 boolean isInitialized()
          Whether this HW is initialized
 void setHighWaterEpoch(long highWaterEpoch)
           
 void setHighWaterEventId(java.lang.String highWaterEventId)
           
 java.lang.String toString()
           
 void update(long epoch, java.lang.String eventId)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HighWaterResource

public HighWaterResource()

HighWaterResource

public HighWaterResource(long epoch,
                         java.lang.String eventId)

HighWaterResource

public HighWaterResource(java.lang.String resourceAsString)
Method Detail

isInitialized

public boolean isInitialized()
Whether this HW is initialized

Returns:
true if this HW's epoch is 0 or more

compareTo

public int compareTo(HighWaterResource o)
Compare ourselves to what is passed in.
Two uninitialized HW will be equal
An uninitialized HW is always older than an initialized one Epochs comparison is made first, then the offset. Session Ids, if any are ignored

Specified by:
compareTo in interface java.lang.Comparable<HighWaterResource>
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

update

public void update(long epoch,
                   java.lang.String eventId)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSessionId

public static java.lang.String getSessionId(java.lang.String eventId)

getHighWaterEpoch

public long getHighWaterEpoch()

setHighWaterEpoch

public void setHighWaterEpoch(long highWaterEpoch)

getHighWaterEventId

public java.lang.String getHighWaterEventId()

setHighWaterEventId

public void setHighWaterEventId(java.lang.String highWaterEventId)