public class PeerId extends Object implements Copiable<PeerId>, Serializable, Checksum
| 构造器和说明 |
|---|
PeerId() |
PeerId(Endpoint endpoint,
int idx) |
PeerId(Endpoint endpoint,
int idx,
int priority) |
PeerId(String ip,
int port) |
PeerId(String ip,
int port,
int idx) |
PeerId(String ip,
int port,
int idx,
int priority) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
checksum()
Calculate a checksum value for this entity.
|
PeerId |
copy()
Copy current object(deep-clone).
|
static PeerId |
emptyPeer()
Create an empty peer.
|
boolean |
equals(Object obj) |
Endpoint |
getEndpoint() |
int |
getIdx() |
String |
getIp() |
int |
getPort() |
int |
getPriority() |
int |
hashCode() |
boolean |
isEmpty()
Returns true when ip is ANY_IP, port is zero and idx is zero too.
|
boolean |
isPriorityDisabled()
To judge whether the priority election function is disabled or not in this node.
|
boolean |
isPriorityNotElected()
To judge whether this node can participate in election or not.
|
boolean |
parse(String s)
Parse peerId from string that generated by
toString()
This method can support parameter string values are below:
PeerId.parse("a:b") = new PeerId("a", "b", 0 , -1)
PeerId.parse("a:b:c") = new PeerId("a", "b", "c", -1)
PeerId.parse("a:b::d") = new PeerId("a", "b", 0, "d")
PeerId.parse("a:b:c:d") = new PeerId("a", "b", "c", "d")
|
static PeerId |
parsePeer(String s)
Parse a peer from string in the format of "ip:port:idx",
returns null if fail to parse.
|
void |
setPriority(int priority) |
String |
toString() |
public static final PeerId ANY_PEER
public PeerId()
public PeerId(Endpoint endpoint, int idx)
public PeerId(String ip, int port)
public PeerId(String ip, int port, int idx)
public PeerId(Endpoint endpoint, int idx, int priority)
public PeerId(String ip, int port, int idx, int priority)
public long checksum()
Checksumpublic static PeerId emptyPeer()
public static PeerId parsePeer(String s)
s - input string with the format of "ip:port:idx"public Endpoint getEndpoint()
public String getIp()
public int getPort()
public int getIdx()
public int getPriority()
public void setPriority(int priority)
public boolean isEmpty()
public boolean parse(String s)
toString()
This method can support parameter string values are below:
PeerId.parse("a:b") = new PeerId("a", "b", 0 , -1)
PeerId.parse("a:b:c") = new PeerId("a", "b", "c", -1)
PeerId.parse("a:b::d") = new PeerId("a", "b", 0, "d")
PeerId.parse("a:b:c:d") = new PeerId("a", "b", "c", "d")
public boolean isPriorityNotElected()
public boolean isPriorityDisabled()
Copyright © 2021. All rights reserved.