Class StampTable

java.lang.Object
com.jalios.jstore.StampTable
All Implemented Interfaces:
Cloneable

public class StampTable extends Object implements Cloneable
This class contains a set of stamp (one per urid). It is typically used to maintain progress tables. A progress table represents the advancement of a replica according the other replica of the group.
Author:
Olivier Dedieu
  • Constructor Details

    • StampTable

      public StampTable()
    • StampTable

      public StampTable(StampTable other)
    • StampTable

      public StampTable(Stamp... stamps)
  • Method Details

    • getMap

      public Map<String,Stamp> getMap()
      Returns:
      the map (urid, stamp)
      Since:
      jcms-4.1
    • clone

      public Object clone()
      Overrides:
      clone in class Object
      Returns:
      the cloned StampTable
      Since:
      jcms-4.1
    • putStamp

      public void putStamp(Stamp stamp)
      Puts this stamp in the StampTable
      Parameters:
      stamp - the stamp to be added
      Since:
      jcms-4.1
    • getStamp

      public Stamp getStamp(String urid)
      Returns the stamps to which this StampTable maps the specified urid. Returns null if the StampTable contains no mapping for this urid.
      Parameters:
      urid - urid whose associated stamp is to be returned.
      Returns:
      the stamp associated to the given urid.
      Since:
      jcms-4.1
    • getRealStamp

      public Stamp getRealStamp(String urid)
      Returns the stamp to which this StampTable maps the specified urid. Returns the zero-stamp (i.e. Stamp(urid, 0)) if the StampTable contains no mapping for this
      Parameters:
      urid - urid whose associated stamp is to be returned.
      Returns:
      the stamp to which this StampTable maps the specified urid
      Since:
      jcms-4.1
    • compareStamp

      public int compareStamp(Stamp stamp)
      Compares the given stamp with the ones in the table.
      Parameters:
      stamp - the stamp to be compared
      Returns:
      a negative integer, zero, or a positive integer as the stamp of the table is less than, equal to, or greater than the specified stamp.
      Since:
      jcms-4.1
    • compareLogEntry

      public int compareLogEntry(LogEntry logEntry)
      Compares the given stamp of the logEntry with the ones in the table.
      Parameters:
      logEntry - the logEntry to be compared
      Returns:
      a negative integer, zero, or a positive integer as the stamp of the table is less than, equal to, or greater than the specified stamp.
      Since:
      jcms-4.1
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Returns:
      true of the given obj is StampTable with exactly the same value as this StampTable
      Since:
      jcms-4.1
    • isGreaterThan

      public boolean isGreaterThan(StampTable other, boolean isStrict)
      Checks if this StampTable is greater than the given one.
      Parameters:
      other - the other table to be compared
      isStrict - true if strict comparison
      Returns:
      true if this StampTable is greater than the given one
      Since:
      jcms-4.1
      See Also:
    • isGreaterThan

      public boolean isGreaterThan(StampTable other, boolean isStrict, String uridToIgnore)
      Checks if this StampTable is greater than the given one.
      ST1 is greater than ST2 if ST1 not equals to ST2 and foreach urid in ST2, there exists a stamp in ST1 greater or equals than the one in ST2.
      ST1 is stricly greater than ST2 if foreach urid in ST2, there exists a stamp in ST1 strictly greater than the one in ST2.
      Parameters:
      other - the other table to be compared
      isStrict - true if strict comparison
      uridToIgnore - this urid will be ignored for the comparison (can be null)
      Returns:
      true if this StampTable is greater than the given one
      Since:
      jcms-4.1
    • isLesserThan

      public boolean isLesserThan(StampTable other, boolean isStrict)
      Checks if this StampTable is lesser than the given one.
      Parameters:
      other - the other table to be compared
      isStrict - true if strict comparison
      Returns:
      true if this StampTable is lesser than the given one
      Since:
      jcms-4.1
      See Also:
    • isLesserThan

      public boolean isLesserThan(StampTable other, boolean isStrict, String uridToIgnore)
      Checks if this StampTable is lesser than the given one.
      Parameters:
      other - the other table to be compared
      isStrict - true if strict comparison
      uridToIgnore - this urid will be ignored for the comparison (can be null)
      Returns:
      true if this StampTable is lesser than the given one
      Since:
      jcms-4.1
      See Also:
    • isGreaterThan

      public boolean isGreaterThan(Stamp stamp, boolean isStrict)
      Check if this StampTable contains at least one stamp greater than the given stamp.
      Parameters:
      stamp - the stamp to be compared
      isStrict - true if strict comparison
      Returns:
      true if this StampTable contains at least one stamp greater than the given stamp.
      Since:
      jcms-5.0.0
      See Also:
    • isLesserThan

      public boolean isLesserThan(Stamp stamp, boolean isStrict)
      Check if all the stamps of this StampTable are lesser than the given stamp.
      Parameters:
      stamp - the stamp to be compared
      isStrict - true if strict comparison
      Returns:
      true if all the stamps of this StampTable are lesser than the given stamp.
      Since:
      jcms-5.0.0
      See Also:
    • isPartiallyGreaterThan

      public boolean isPartiallyGreaterThan(StampTable other)
      Checks if this StampTable is partially greater than the given one.
      ST1 is partially greater than ST2 if at least one stamp of ST1 is greater than the one in ST2.
      Parameters:
      other - the other table to be compared
      Returns:
      true if this StampTable is partially greater than the given one
      Since:
      jcms-5.0.1
    • isGreaterThanStamp

      public boolean isGreaterThanStamp(Stamp other, boolean isStrict)
      Checks if this StampTable contains a stamp greater than the given one.
      Parameters:
      other - the stamp to be compared
      isStrict - true if strict comparison
      Returns:
      true if this StampTable contains a stamp greater than the given one.
      Since:
      jcms-5.0.2
      See Also:
    • isLesserThanStamp

      public boolean isLesserThanStamp(Stamp other, boolean isStrict)
      Checks if this StampTable contains a stamp lesser than the given one.
      Parameters:
      other - the stamp to be compared
      isStrict - true if strict comparison
      Returns:
      true if this StampTable contains a stamp lesser than the given one.
      Since:
      jcms-5.0.2
      See Also:
    • getMinStamp

      public Stamp getMinStamp()
      Returns the smallest stamp contains in this StampTable
      Returns:
      the smallest stamp
      Since:
      jcms-4.1
      See Also:
    • getMaxStamp

      public Stamp getMaxStamp()
      Returns the highest stamp contains in this StampTable
      Returns:
      the smallest stamp
      Since:
      jcms-5.0.5
      See Also:
    • getBehindStamp

      public Stamp getBehindStamp(StampTable st)
      Gets the most behind stamp of this StampTable according the given StampTable. This stamp may be null if all stamps of the given StampTable are lesser or equals to ones of the this StampTable. May return a fake stamp (urid, 0), if the given StampTable has got a stamp.urid unknown for this StampTable.
      Parameters:
      st - the StampTable to compare with
      Returns:
      a most behind stamp.
      Since:
      jcms-4.1
    • getBehindStamp

      public Stamp getBehindStamp(StampTable st, boolean useRealStamp)
      Gets the most behind stamp of this StampTable according the given StampTable. This stamp may be null if all stamps of the given StampTable are lesser or equals to ones of the this StampTable. If useRealStamp is true, missing stamp are considered as fake stamp (urid, 0). So, it may return a fake stamp (urid, 0), if the given StampTable has got a stamp.urid unknown for this StampTable.
      Parameters:
      st - the StampTable to compare with
      useRealStamp - if true, considere missing stamp as (urid, 0)
      Returns:
      a most behind stamp.
      Since:
      jcms-4.1
    • getMinTable

      public StampTable getMinTable(StampTable st)
      Build a new StampTable for this one and the given one. For each urid contains in these 2 tables, the new StampTable contains the smallest real stamp. If an urid is missing in one the two tables, the zero-stamp is added.
      Parameters:
      st - the StampTable to used
      Returns:
      a StampTable
      Since:
      jcms-4.1
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGreatestBehindStamp

      public Stamp getGreatestBehindStamp(Stamp stamp)
      Parameters:
      stamp - the stamp for which we are looking for the closer stamp below it.
      Returns:
      the stamp of this StampTable that is the greatest table stamp lesser than the given stamp.
      Since:
      jcms-10.0.8