パッケージ org.piax.gtrans.ov.ddll

クラス Node

java.lang.Object
org.piax.gtrans.ov.ddll.Node

public class Node
extends Object
a DDLL node.

this class contains an implementation of DDLL protocol.

  • フィールド詳細

    • DEFAULT_TIMEOUT

      public static int DEFAULT_TIMEOUT
    • SETR_TIMEOUT

      public static int SETR_TIMEOUT
    • DELETE_OP_TIMEOUT

      public static int DELETE_OP_TIMEOUT
    • SEARCH_OP_TIMEOUT

      public static int SEARCH_OP_TIMEOUT
    • GETSTAT_OP_TIMEOUT

      public static int GETSTAT_OP_TIMEOUT
      timeout for a response of GetStat message in msec. if the left node does not respond within this period, the left node is considered failed. TODO: change timeout adaptively
    • INS_DEL_RETRY_INTERVAL_BASE

      public static final int INS_DEL_RETRY_INTERVAL_BASE
      関連項目:
      定数フィールド値
    • MIN_FIX_INTERVAL

      public static int MIN_FIX_INTERVAL
      minimum interval of fixing To avoid rush of fixing, make minimum interval between fixing.
    • DEFAULT_CHECK_PERIOD

      public static int DEFAULT_CHECK_PERIOD
      fix処理を定期実行するための基準となる周期 (msec)
  • メソッドの詳細

    • online

      public void online()
      activate the protocol.
    • offline

      public void offline()
      inactivate the protocol.
    • isOnline

      public boolean isOnline()
    • fin

      public void fin()
    • getMyLink

      public Link getMyLink()
    • getKey

      public DdllKey getKey()
    • getMode

      public Node.Mode getMode()
    • setMode

      protected void setMode​(Node.Mode mode)
    • setCheckPeriod

      public void setCheckPeriod​(int period)
    • setLeft

      protected void setLeft​(Link left)
    • setLeftNum

      protected void setLeftNum​(LinkSeq lNum)
    • getLeft

      public Link getLeft()
    • getRight

      public Link getRight()
    • setRight

      protected void setRight​(Link right)
    • setRightNum

      protected void setRightNum​(LinkSeq rNum)
    • setRef

      protected void setRef​(int r)
    • getNeighborSet

      public List<Link> getNeighborSet()
    • toString

      public String toString()
      オーバーライド:
      toString クラス内 Object
    • reset

      public void reset()
      forcibly delete this node without notifying other nodes
    • lock

      public void lock()
    • unlock

      public void unlock()
    • isOrdered

      @Deprecated public static boolean isOrdered​(Comparable<?> a, Comparable<?> b, Comparable<?> c)
      推奨されていません。
    • isOrdered

      @Deprecated public static boolean isOrdered​(Comparable<?> from, boolean fromInclusive, Comparable<?> val, Comparable<?> to, boolean toInclusive)
      推奨されていません。
    • isBetween

      public boolean isBetween​(DdllKey a, DdllKey c)
    • insertAsInitialNode

      public void insertAsInitialNode()
      Insert this node as the initial node. This node becomes the first node in the network.
    • initializeConnectedNodes

      public static void initializeConnectedNodes​(List<Node> list)
    • insert

      public Node.InsertionResult insert​(Link introducer, int maxRetry) throws IllegalStateException
      insert this node to a linked-list by specifying an introducer node, which is an arbitrary node that has been inserted to the linked-list.

      note that this method may take O(N) steps for finding proper insertion point and thus, should not be used for large linked-list.

      パラメータ:
      introducer - some node that has been inserted to a linked-list
      maxRetry - max retry count
      戻り値:
      insertion result
      例外:
      IllegalStateException - thrown if the node is already inserted
    • insert

      insert this node to a linked-list by specifying the immediate left and right nodes.

      note that this method does not retry insertion when failed.

      パラメータ:
      pos - the insert point, which contains the immediate left and right node of this node.
      戻り値:
      insertion result
      例外:
      IllegalStateException - thrown if the node is already inserted
    • insert0

      protected Node.InsertionResult insert0​(Node.InsertPoint p)
      insert a node between two nodes specified by an Node.InsertPoint instance.
      パラメータ:
      p - insertion point
      戻り値:
      true if successfully inserted, false otherwise
    • delete

      public boolean delete​(int maxRetry) throws IllegalStateException
      delete this node from the linked-list. if the DDLL protocol fails to delete this node after maxRetry retries, the node is forcibly deleted and returns false.
      パラメータ:
      maxRetry - max retry
      戻り値:
      true if successfully deleted
      例外:
      IllegalStateException - thrown if node is not inserted
    • delete0

      protected boolean delete0() throws OfflineSendException
      delete this node from the linked-list.
      戻り値:
      true if successfully deleted
      例外:
      OfflineSendException - thrown if this node is offline
    • setR

      public void setR​(Link sender, int reqNo, Link rNew, Link rCur, LinkSeq rNewNum, int type, Object payload)
      SetR message handler.
       pseudo code:
       (A2)
       receive SetR(rnew , rcur , rnewnum , incr) from q →
         if ((s  ̸= in ∧ s  ̸= lwait) ∨ r  ̸= rcur) then send SetRNak() to q
       else send SetRAck(rnum) to q; r, rnum, ref := rnew, rnewnum, ref + incr fi
       
       
      パラメータ:
      sender - the sender of this SetR message
      reqNo - request number
      rNew - the new right link number
      rCur - the current right link that this node should have
      rNewNum - the new right link
      type - the type of SetR
      payload - the optional data transferred along with the SetR message
    • setRAck

      public void setRAck​(Link sender, int reqNo, LinkSeq zNum, Set<Link> nbrs)
      SetRAck message handler.
       pseudo code:
       (A3) receive SetRAck(znum) from q →
         if (s = jng) then s, rnum, ref := in, znum.next(), 1; send SetL(u, rnum, l) to r
           elseif (s = lvg) then s := grace; send SetL(l, rnum.next(), u) to r
           elseif (s = fix) then s := in fi
       
      パラメータ:
      sender - the sender of this SetRAck message
      reqNo - request number
      zNum - the previous right link number of the sender node
      nbrs - neighbor node set
    • setRNak

      public void setRNak​(Link sender, int reqNo, Link curR)
      SetRNak message handler.
       pseudo code:
       (A4)
       receive SetRNak() from q →
         if (s = jng) then s := jwait
         elseif (s = lvg) then s := lwait
         elseif (fixing) then fixing := false fi
       
      パラメータ:
      sender - the sender of this SetRNak message
      reqNo - request number
      curR - current right link of the sender node
    • setL

      public void setL​(Link lNew, LinkSeq lNewNum, Link prevL, Set<Link> nbrs)
    • unrefL

      public void unrefL​(Link sender)
    • setFindResult

      public void setFindResult​(int reqNo, Link left, Link right)
    • setFindNext

      public void setFindNext​(int reqNo, Link next, Link prevKey)
    • findNearest

      public void findNearest​(Link sender, int reqNo, DdllKey searchKey, Link prevKey)
    • getStat

      public void getStat​(Link sender, int reqNo)
    • startFix

      public void startFix​(Link failed, boolean force)
      start fixing a single failed link.
      パラメータ:
      failed - the failed link.
      force - true if you want to check the left node even if it is not equals to `failed'.
    • startFix

      public void startFix​(Link failed)
    • startFix

      public void startFix​(Collection<Link> failedLinks)
      start fixing set of failed links.
      パラメータ:
      failedLinks - the failed links.
    • startfix

      public void startfix​(Collection<Link> failedLinks, Object payload)
    • startfix

      public void startfix​(Collection<Link> failedLinks, Object payload, boolean force)
      start fixing `failedLinks'. `payload' is piggy-backed by SetR message if it is non-null.
      パラメータ:
      failedLinks - the failed links.
      payload - the payload object.
      force - true if you want to check the left node even if it is not contained in `failedLinks'.