Record Class TwoPhaseCommit

java.lang.Object
java.lang.Record
org.jgroups.admin.TwoPhaseCommit

public record TwoPhaseCommit(String key, String name, AdminHandler admin, Address dest, List<Address> targets, String prepare, String rollback, String commit, long timeout, ResponseCollector<String> rsps) extends Record
Component which is used on the sender side. Sends a PREPARE command (string) to all members, waits for the results. If a timeout occurred, or some of the results are "FAIL", then a ROLLBACK command is sent, else (if set) a COMMIT command.
Returns true or false accordingly.
Since:
5.6.0
Author:
Bela Ban
  • Constructor Details

    • TwoPhaseCommit

      public TwoPhaseCommit(String key, String name, AdminHandler admin, Address dest, List<Address> targets, String prepare, String rollback, String commit, long timeout)
    • TwoPhaseCommit

      public TwoPhaseCommit(String key, String name, AdminHandler admin, Address dest, List<Address> targets, String prepare, String rollback, String commit, long timeout, ResponseCollector<String> rsps)
      Creates an instance of a TwoPhaseCommit record class.
      Parameters:
      key - the value for the key record component
      name - the value for the name record component
      admin - the value for the admin record component
      dest - the value for the dest record component
      targets - the value for the targets record component
      prepare - the value for the prepare record component
      rollback - the value for the rollback record component
      commit - the value for the commit record component
      timeout - the value for the timeout record component
      rsps - the value for the rsps record component
  • Method Details

    • execute

      public boolean execute()
    • performRollback

      public void performRollback()
    • handleResponse

      public void handleResponse(Address sender, String rsp)
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • admin

      public AdminHandler admin()
      Returns the value of the admin record component.
      Returns:
      the value of the admin record component
    • dest

      public Address dest()
      Returns the value of the dest record component.
      Returns:
      the value of the dest record component
    • targets

      public List<Address> targets()
      Returns the value of the targets record component.
      Returns:
      the value of the targets record component
    • prepare

      public String prepare()
      Returns the value of the prepare record component.
      Returns:
      the value of the prepare record component
    • rollback

      public String rollback()
      Returns the value of the rollback record component.
      Returns:
      the value of the rollback record component
    • commit

      public String commit()
      Returns the value of the commit record component.
      Returns:
      the value of the commit record component
    • timeout

      public long timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • rsps

      public ResponseCollector<String> rsps()
      Returns the value of the rsps record component.
      Returns:
      the value of the rsps record component