Class NodeManager

java.lang.Object
org.apache.iotdb.confignode.manager.node.NodeManager

public class NodeManager extends Object
NodeManager manages cluster node addition and removal requests.
  • Field Details

    • HEARTBEAT_INTERVAL

      public static final long HEARTBEAT_INTERVAL
    • nodeInfo

      protected final NodeInfo nodeInfo
  • Constructor Details

  • Method Details

    • getSystemConfiguration

      public DataSet getSystemConfiguration()
      Get system configurations.
      Returns:
      ConfigurationResp. The TSStatus will be set to SUCCESS_STATUS.
    • registerDataNode

      public DataSet registerDataNode(TDataNodeRegisterReq req)
      Register DataNode.
      Parameters:
      req - TDataNodeRegisterReq
      Returns:
      DataNodeConfigurationDataSet. The TSStatus will be set to TSStatusCode.SUCCESS_STATUS when register success.
    • updateDataNodeIfNecessary

      public TDataNodeRestartResp updateDataNodeIfNecessary(TDataNodeRestartReq req)
    • removeDataNode

      public DataSet removeDataNode(RemoveDataNodePlan removeDataNodePlan)
      Removes the specified DataNodes.
      Parameters:
      removeDataNodePlan - the plan detailing which DataNodes to remove
      Returns:
      DataNodeToStatusResp, where the TSStatus will be SUCCEED_STATUS if the request is accepted, or DATANODE_NOT_EXIST if any DataNode does not exist.
    • registerConfigNode

      public TConfigNodeRegisterResp registerConfigNode(TConfigNodeRegisterReq req)
    • updateConfigNodeIfNecessary

      public TSStatus updateConfigNodeIfNecessary(int configNodeId, TNodeVersionInfo versionInfo)
    • getRegisteredAINodeInfoList

      public List<TAINodeInfo> getRegisteredAINodeInfoList()
    • getRegisteredAINodes

      public List<TAINodeConfiguration> getRegisteredAINodes()
      Returns:
      All registered AINodes
    • getRegisteredAINode

      public TAINodeConfiguration getRegisteredAINode(int aiNodeId)
    • registerAINode

      public DataSet registerAINode(TAINodeRegisterReq req)
      Register AINode. Use synchronized to make sure
      Parameters:
      req - TAINodeRegisterReq
      Returns:
      AINodeConfigurationDataSet. The TSStatus will be set to TSStatusCode.SUCCESS_STATUS when register success.
    • removeAINode

      public TSStatus removeAINode(RemoveAINodePlan removeAINodePlan)
      Remove AINodes.
      Parameters:
      removeAINodePlan - removeDataNodePlan
    • updateAINodeIfNecessary

      public TAINodeRestartResp updateAINodeIfNecessary(TAINodeRestartReq req)
    • getAINodeConfiguration

      public AINodeConfigurationResp getAINodeConfiguration(GetAINodeConfigurationPlan req)
    • getDataNodeConfiguration

      public DataNodeConfigurationResp getDataNodeConfiguration(GetDataNodeConfigurationPlan req)
      Get TDataNodeConfiguration.
      Parameters:
      req - GetDataNodeConfigurationPlan
      Returns:
      The specific DataNode's configuration or all DataNodes' configuration if dataNodeId in GetDataNodeConfigurationPlan is -1
    • getRegisteredNodeCount

      public int getRegisteredNodeCount()
      Only leader use this interface.
      Returns:
      The number of registered Nodes
    • getRegisteredDataNodeCount

      public int getRegisteredDataNodeCount()
      Only leader use this interface.
      Returns:
      The number of registered DataNodes
    • getRegisteredDataNodes

      public List<TDataNodeConfiguration> getRegisteredDataNodes()
      Only leader use this interface.
      Returns:
      All registered DataNodes
    • getRegisteredDataNode

      public TDataNodeConfiguration getRegisteredDataNode(int dataNodeId)
      Only leader use this interface.

      Notice: The result will be an empty TDataNodeConfiguration if the specified DataNode doesn't register

      Parameters:
      dataNodeId - The specified DataNode's index
      Returns:
      The specified registered DataNode
    • getRegisteredDataNodeLocations

      public Map<Integer,TDataNodeLocation> getRegisteredDataNodeLocations()
    • getRegisteredConfigNodeLocations

      public Map<Integer,TConfigNodeLocation> getRegisteredConfigNodeLocations()
    • getRegisteredDataNodeInfoList

      public List<TDataNodeInfo> getRegisteredDataNodeInfoList()
    • getDataNodeCpuCoreCount

      public int getDataNodeCpuCoreCount()
    • getRegisteredConfigNodes

      public List<TConfigNodeLocation> getRegisteredConfigNodes()
    • getNodeVersionInfo

      public Map<Integer,TNodeVersionInfo> getNodeVersionInfo()
    • getRegisteredConfigNodeInfoList

      public List<TConfigNodeInfo> getRegisteredConfigNodeInfoList()
    • applyConfigNode

      public void applyConfigNode(TConfigNodeLocation configNodeLocation, TNodeVersionInfo versionInfo)
      Only leader use this interface, record the new ConfigNode's information.
      Parameters:
      configNodeLocation - The new ConfigNode.
      versionInfo - The new ConfigNode's versionInfo.
    • checkConfigNodeBeforeRemove

      public TSStatus checkConfigNodeBeforeRemove(RemoveConfigNodePlan removeConfigNodePlan)
      Only leader use this interface, check the ConfigNode before remove it.
      Parameters:
      removeConfigNodePlan - RemoveConfigNodePlan
    • merge

      public List<TSStatus> merge()
    • flush

      public List<TSStatus> flush(TFlushReq req)
    • flushOnSpecificDN

      public List<TSStatus> flushOnSpecificDN(TFlushReq req, Map<Integer,TDataNodeLocation> dataNodeLocationMap)
    • clearCache

      public List<TSStatus> clearCache()
    • setConfiguration

      public List<TSStatus> setConfiguration(TSetConfigurationReq req)
    • startRpairData

      public List<TSStatus> startRpairData()
    • stopRepairData

      public List<TSStatus> stopRepairData()
    • submitLoadConfigurationTask

      public List<TSStatus> submitLoadConfigurationTask()
    • showConfiguration

      public TShowConfigurationResp showConfiguration(int nodeId)
    • setSystemStatus

      public List<TSStatus> setSystemStatus(String status)
    • setDataNodeStatus

      public TSStatus setDataNodeStatus(TSetDataNodeStatusReq setDataNodeStatusReq)
    • killQuery

      public TSStatus killQuery(String queryId, int dataNodeId)
      Kill read on DataNode.
      Parameters:
      queryId - the id of specific read need to be killed, it will be NULL if kill all queries
      dataNodeId - the DataNode obtains target read, -1 means we will kill all queries on all DataNodes
    • filterConfigNodeThroughStatus

      public List<TConfigNodeLocation> filterConfigNodeThroughStatus(NodeStatus... status)
      Filter ConfigNodes through the specified NodeStatus.
      Parameters:
      status - The specified NodeStatus
      Returns:
      Filtered ConfigNodes with the specified NodeStatus
    • filterDataNodeThroughStatus

      public List<TDataNodeConfiguration> filterDataNodeThroughStatus(NodeStatus... status)
      Filter DataNodes through the specified NodeStatus.
      Parameters:
      status - The specified NodeStatus
      Returns:
      Filtered DataNodes with the specified NodeStatus
    • getLowestLoadDataNode

      public Optional<TDataNodeLocation> getLowestLoadDataNode()
      Get the DataNodeLocation of the DataNode which has the lowest loadScore.
      Returns:
      TDataNodeLocation with the lowest loadScore
    • getLowestLoadDataNode

      public TDataNodeLocation getLowestLoadDataNode(Set<Integer> nodes)
      Get the DataNodeLocation which has the lowest loadScore within input.
      Returns:
      TDataNodeLocation with the lowest loadScore