public class Node extends Object
this class contains an implementation of DDLL protocol.
| 修飾子とタイプ | クラスと説明 |
|---|---|
static class |
Node.InsertionResult
a class representing a result of insertion.
|
static class |
Node.InsertPoint
a class representing an insertion point in a linked-list.
|
static class |
Node.Mode
DDLL node state
|
| 修飾子とタイプ | フィールドと説明 |
|---|---|
static int |
DEFAULT_CHECK_PERIOD
fix処理を定期実行するための基準となる周期 (msec)
|
static int |
DEFAULT_TIMEOUT |
static int |
DELETE_OP_TIMEOUT |
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.
|
static int |
INS_DEL_RETRY_INTERVAL_BASE |
static int |
MIN_FIX_INTERVAL
minimum interval of fixing
To avoid rush of fixing, make minimum interval between fixing.
|
static int |
SEARCH_OP_TIMEOUT |
static int |
SETR_TIMEOUT |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
boolean |
delete(int maxRetry)
delete this node from the linked-list.
|
protected boolean |
delete0()
delete this node from the linked-list.
|
void |
fin() |
void |
findNearest(Link sender,
int reqNo,
DdllKey searchKey,
Link prevKey) |
DdllKey |
getKey() |
Link |
getLeft() |
Node.Mode |
getMode() |
Link |
getMyLink() |
List<Link> |
getNeighborSet() |
Link |
getRight() |
void |
getStat(Link sender,
int reqNo) |
static void |
initializeConnectedNodes(List<Node> list) |
Node.InsertionResult |
insert(Link introducer,
int maxRetry)
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.
|
Node.InsertionResult |
insert(Node.InsertPoint pos)
insert this node to a linked-list by specifying the immediate left and
right nodes.
|
protected Node.InsertionResult |
insert0(Node.InsertPoint p)
insert a node between two nodes specified by an
Node.InsertPoint
instance. |
void |
insertAsInitialNode()
Insert this node as the initial node.
|
boolean |
isBetween(DdllKey a,
DdllKey c) |
boolean |
isOnline() |
static boolean |
isOrdered(Comparable<?> from,
boolean fromInclusive,
Comparable<?> val,
Comparable<?> to,
boolean toInclusive) |
static boolean |
isOrdered(Comparable<?> a,
Comparable<?> b,
Comparable<?> c) |
void |
lock() |
void |
offline()
inactivate the protocol.
|
void |
online()
activate the protocol.
|
void |
reset()
forcibly delete this node without notifying other nodes
|
void |
setCheckPeriod(int period) |
void |
setFindNext(int reqNo,
Link next,
Link prevKey) |
void |
setFindResult(int reqNo,
Link left,
Link right) |
void |
setL(Link lNew,
LinkNum lNewNum,
Link prevL,
Set<Link> nbrs) |
protected void |
setLeft(Link left) |
protected void |
setLeftNum(LinkNum lNum) |
protected void |
setMode(Node.Mode mode) |
void |
setR(Link sender,
int reqNo,
Link rNew,
Link rCur,
LinkNum rNewNum,
int type,
Object payload)
SetR message handler.
|
void |
setRAck(Link sender,
int reqNo,
LinkNum zNum,
Set<Link> nbrs)
SetRAck message handler.
|
protected void |
setRef(int r) |
protected void |
setRight(Link right) |
protected void |
setRightNum(LinkNum rNum) |
void |
setRNak(Link sender,
int reqNo,
Link curR)
SetRNak message handler.
|
void |
startFix(Collection<Link> failedLinks)
start fixing set of failed links.
|
void |
startfix(Collection<Link> failedLinks,
Object payload) |
void |
startfix(Collection<Link> failedLinks,
Object payload,
boolean force)
start fixing `failedLinks'.
|
void |
startFix(Link failed) |
void |
startFix(Link failed,
boolean force)
start fixing a single failed link.
|
String |
toString() |
void |
unlock() |
void |
unrefL(Link sender) |
public static int DEFAULT_TIMEOUT
public static int SETR_TIMEOUT
public static int DELETE_OP_TIMEOUT
public static int SEARCH_OP_TIMEOUT
public static int GETSTAT_OP_TIMEOUT
public static final int INS_DEL_RETRY_INTERVAL_BASE
public static int MIN_FIX_INTERVAL
public static int DEFAULT_CHECK_PERIOD
public void online()
public void offline()
public boolean isOnline()
public void fin()
public Link getMyLink()
public DdllKey getKey()
public Node.Mode getMode()
protected void setMode(Node.Mode mode)
public void setCheckPeriod(int period)
protected void setLeft(Link left)
protected void setLeftNum(LinkNum lNum)
public Link getLeft()
public Link getRight()
protected void setRight(Link right)
protected void setRightNum(LinkNum rNum)
protected void setRef(int r)
public void reset()
public void lock()
public void unlock()
public static boolean isOrdered(Comparable<?> a, Comparable<?> b, Comparable<?> c)
public static boolean isOrdered(Comparable<?> from, boolean fromInclusive, Comparable<?> val, Comparable<?> to, boolean toInclusive)
public void insertAsInitialNode()
public Node.InsertionResult insert(Link introducer, int maxRetry) throws IllegalStateException
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-listmaxRetry - max retry countIllegalStateException - thrown if the node is already insertedpublic Node.InsertionResult insert(Node.InsertPoint pos) throws IllegalStateException
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.IllegalStateException - thrown if the node is already insertedprotected Node.InsertionResult insert0(Node.InsertPoint p)
Node.InsertPoint
instance.p - insertion pointpublic boolean delete(int maxRetry)
throws IllegalStateException
maxRetry - max retryIllegalStateException - thrown if node is not insertedprotected boolean delete0()
throws OfflineSendException
OfflineSendException - thrown if this node is offlinepublic void setR(Link sender, int reqNo, Link rNew, Link rCur, LinkNum rNewNum, int type, Object payload)
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 messagereqNo - request numberrNew - the new right link numberrCur - the current right link that this node should haverNewNum - the new right linktype - the type of SetRpayload - the optional data transferred along with the SetR
messagepublic void setRAck(Link sender, int reqNo, LinkNum zNum, Set<Link> nbrs)
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 messagereqNo - request numberzNum - the previous right link number of the sender nodenbrs - neighbor node setpublic void setRNak(Link sender, int reqNo, Link curR)
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 messagereqNo - request numbercurR - current right link of the sender nodepublic void unrefL(Link sender)
public void getStat(Link sender, int reqNo)
public void startFix(Link failed, boolean force)
failed - the failed link.force - true if you want to check the left node even if it is
not equals to `failed'.public void startFix(Link failed)
public void startFix(Collection<Link> failedLinks)
failedLinks - the failed links.public void startfix(Collection<Link> failedLinks, Object payload)
public void startfix(Collection<Link> failedLinks, Object payload, boolean force)
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'.Copyright © 2017. All rights reserved.