E
- the type of command which will be synchronized using Paxos.public abstract class PaxosNode<E extends PaxosCommand>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
nodeID |
Constructor and Description |
---|
PaxosNode(int nodeID,
int port,
java.util.Map<java.lang.Integer,java.lang.String> nodeHostPorts) |
PaxosNode(int nodeID,
int port,
java.util.Map<java.lang.Integer,java.lang.String> nodeHostPorts,
Logger logger) |
Modifier and Type | Method and Description |
---|---|
boolean |
propose(E command)
Proposes a new command to the paxos cluster
|
void |
stop()
Stop running the node and clean up associated resources.
|
public PaxosNode(int nodeID, int port, java.util.Map<java.lang.Integer,java.lang.String> nodeHostPorts) throws java.lang.NumberFormatException, java.net.UnknownHostException, java.net.SocketException
nodeID
- the id of this paxos node in the clusterport
- the port to run the node off ofnodeHostPorts
- the hostnames and ports (colon delimited) for all nodes in the
cluster (including this one) in sorted ID orderjava.lang.NumberFormatException
- if a port number was badly formattedjava.net.UnknownHostException
- if the host can't be foundjava.net.SocketException
- if a connection could not be establishedpublic PaxosNode(int nodeID, int port, java.util.Map<java.lang.Integer,java.lang.String> nodeHostPorts, Logger logger) throws java.lang.NumberFormatException, java.net.UnknownHostException, java.net.SocketException
nodeID
- the id of this paxos node in the clusterport
- the port to run the node off ofnodeHostPorts
- the hostnames and ports (colon delimited) for all nodes in the
cluster (including this one) in sorted ID orderlogger
- the logger to use for this paxos nodejava.lang.NumberFormatException
- if a port number was badly formattedjava.net.UnknownHostException
- if the host can't be foundjava.net.SocketException
- if a connection could not be establishedpublic boolean propose(E command)
command
- the command to proposepublic void stop()