Package com.arcadedb.server.ha
Class HAServer
- java.lang.Object
-
- com.arcadedb.server.ha.HAServer
-
- All Implemented Interfaces:
ServerPlugin
public class HAServer extends Object implements ServerPlugin
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HAServer.ELECTION_STATUS
static class
HAServer.QUORUM
static class
HAServer.SERVER_ROLE
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_PORT
protected Pair<Long,String>
lastElectionVote
protected ReplicationLogFile
replicationLogFile
protected String
replicationPath
-
Constructor Summary
Constructors Constructor Description HAServer(ArcadeDBServer server, ContextConfiguration configuration)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.arcadedb.server.ServerPlugin
configure, registerAPI
-
-
-
-
Field Detail
-
DEFAULT_PORT
public static final String DEFAULT_PORT
- See Also:
- Constant Field Values
-
replicationPath
protected final String replicationPath
-
replicationLogFile
protected ReplicationLogFile replicationLogFile
-
-
Constructor Detail
-
HAServer
public HAServer(ArcadeDBServer server, ContextConfiguration configuration)
-
-
Method Detail
-
startService
public void startService()
- Specified by:
startService
in interfaceServerPlugin
-
isCurrentServer
protected boolean isCurrentServer(String serverEntry)
-
stopService
public void stopService()
- Specified by:
stopService
in interfaceServerPlugin
-
startElection
public void startElection(boolean waitForCompletion)
-
getReplica
public Leader2ReplicaNetworkExecutor getReplica(String replicaName)
-
disconnectAllReplicas
public void disconnectAllReplicas()
-
setReplicaStatus
public void setReplicaStatus(String remoteServerName, boolean online)
-
receivedResponse
public void receivedResponse(String remoteServerName, long messageNumber, Object payload)
-
receivedResponseFromForward
public void receivedResponseFromForward(long messageNumber, Object result, ErrorResponse error)
-
getReplicationLogFile
public ReplicationLogFile getReplicationLogFile()
-
getServer
public ArcadeDBServer getServer()
-
isLeader
public boolean isLeader()
-
getLeaderName
public String getLeaderName()
-
getLeader
public Replica2LeaderNetworkExecutor getLeader()
-
getServerName
public String getServerName()
-
getClusterName
public String getClusterName()
-
registerIncomingConnection
public void registerIncomingConnection(String replicaServerName, Leader2ReplicaNetworkExecutor connection)
-
getElectionStatus
public HAServer.ELECTION_STATUS getElectionStatus()
-
setElectionStatus
protected void setElectionStatus(HAServer.ELECTION_STATUS status)
-
getMessageFactory
public HAMessageFactory getMessageFactory()
-
setServerAddresses
public void setServerAddresses(String serverAddress)
-
forwardCommandToLeader
public Object forwardCommandToLeader(HACommand command, long timeout)
Forward a command to the leader server. This occurs with transactions and DDL commands. If the timeout is 0, then the request is asynchronous and the response is a Resultset containing `{"operation", "forwarded to the leader"}`- Parameters:
command
- HACommand to forwardtimeout
- Timeout in milliseconds. 0 for asynchronous commands- Returns:
- the result from the command if synchronous, otherwise a result set containing `{"operation", "forwarded to the leader"}`
-
sendCommandToReplicasNoLog
public void sendCommandToReplicasNoLog(HACommand command)
-
sendCommandToReplicasWithQuorum
public List<Object> sendCommandToReplicasWithQuorum(HACommand command, int quorum, long timeout)
-
getMessagesInQueue
public int getMessagesInQueue()
-
setReplicasHTTPAddresses
public void setReplicasHTTPAddresses(String replicasHTTPAddresses)
-
getReplicaServersHTTPAddressesList
public String getReplicaServersHTTPAddressesList()
-
removeServer
public void removeServer(String remoteServerName)
-
getOnlineServers
public int getOnlineServers()
-
getOnlineReplicas
public int getOnlineReplicas()
-
getConfiguredServers
public int getConfiguredServers()
-
getServerAddressList
public String getServerAddressList()
-
printClusterConfiguration
public void printClusterConfiguration()
-
getStats
public JSONObject getStats()
-
getServerAddress
public String getServerAddress()
-
resendMessagesToReplica
public void resendMessagesToReplica(long fromMessageNumber, String replicaName)
-
connectToLeader
public boolean connectToLeader(String serverEntry, Callable<Void,Exception> errorCallback)
-
createNetworkConnection
protected ChannelBinaryClient createNetworkConnection(String host, int port, short commandId) throws IOException
- Throws:
IOException
-
-