Class ConsensusManager

java.lang.Object
org.apache.iotdb.confignode.manager.consensus.ConsensusManager

public class ConsensusManager extends Object
ConsensusManager maintains consensus class, request will redirect to consensus layer.
  • Field Details

    • DEFAULT_CONSENSUS_GROUP_ID

      public static final ConsensusGroupId DEFAULT_CONSENSUS_GROUP_ID
      There is only one ConfigNodeGroup
  • Constructor Details

  • Method Details

    • start

      public void start() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Throws:
      IOException
    • createPeerForConsensusGroup

      public void createPeerForConsensusGroup(List<TConfigNodeLocation> configNodeLocations) throws ConsensusException
      Create peer in new node to build consensus group.
      Parameters:
      configNodeLocations - All registered ConfigNodes
      Throws:
      ConsensusException - When addPeer doesn't success
    • addConfigNodePeer

      public void addConfigNodePeer(TConfigNodeLocation configNodeLocation) throws AddPeerException
      Add a new ConfigNode Peer into ConfigRegion.
      Parameters:
      configNodeLocation - The new ConfigNode
      Throws:
      AddPeerException - When addPeer doesn't success
    • removeConfigNodePeer

      public boolean removeConfigNodePeer(TConfigNodeLocation configNodeLocation)
      Remove a ConfigNode Peer out of ConfigRegion.
      Parameters:
      configNodeLocation - config node location
      Returns:
      True if successfully removePeer. False if another ConfigNode is being removed to the ConfigRegion
    • write

      public TSStatus write(ConfigPhysicalPlan plan) throws ConsensusException
      Transmit PhysicalPlan to confignode.consensus.statemachine
      Throws:
      ConsensusException - When write doesn't success
    • read

      Transmit PhysicalPlan to confignode.consensus.statemachine
      Throws:
      ConsensusException - When read doesn't success
    • isLeader

      public boolean isLeader()
    • isLeaderReady

      public boolean isLeaderReady()
    • getLeaderLocation

      public TConfigNodeLocation getLeaderLocation()
      Returns:
      ConfigNode-leader's location if leader exists, null otherwise.
    • isLeaderExist

      public boolean isLeaderExist()
      Returns:
      true if ConfigNode-leader is elected, false otherwise.
    • confirmLeader

      public TSStatus confirmLeader()
      Confirm the current ConfigNode's leadership.
      Returns:
      SUCCESS_STATUS if the current ConfigNode is leader and has been ready yet, NEED_REDIRECTION otherwise
    • getConsensusGroupId

      public ConsensusGroupId getConsensusGroupId()
    • getConfigRegionDir

      public static String getConfigRegionDir()
    • getConsensusImpl

      public IConsensus getConsensusImpl()
    • manuallyTakeSnapshot

      public void manuallyTakeSnapshot() throws ConsensusException
      Throws:
      ConsensusException
    • isInitialized

      public boolean isInitialized()