类 NodeManager


  • public class NodeManager
    extends java.lang.Object
    NodeManager manages cluster node addition and removal requests
    • 字段详细资料

      • HEARTBEAT_INTERVAL

        public static final long HEARTBEAT_INTERVAL
    • 构造器详细资料

      • NodeManager

        public NodeManager​(IManager configManager,
                           NodeInfo nodeInfo)
    • 方法详细资料

      • getSystemConfiguration

        public org.apache.iotdb.consensus.common.DataSet getSystemConfiguration()
        Get system configurations
        返回:
        ConfigurationResp. The TSStatus will be set to SUCCESS_STATUS.
      • registerDataNode

        public org.apache.iotdb.consensus.common.DataSet registerDataNode​(RegisterDataNodePlan registerDataNodePlan)
        Register DataNode
        参数:
        registerDataNodePlan - RegisterDataNodeReq
        返回:
        DataNodeConfigurationDataSet. The TSStatus will be set to SUCCESS_STATUS when register success, and DATANODE_ALREADY_REGISTERED when the DataNode is already exist.
      • restartDataNode

        public org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartResp restartDataNode​(org.apache.iotdb.common.rpc.thrift.TDataNodeLocation dataNodeLocation)
      • removeDataNode

        public org.apache.iotdb.consensus.common.DataSet removeDataNode​(RemoveDataNodePlan removeDataNodePlan)
        Remove DataNodes
        参数:
        removeDataNodePlan - removeDataNodePlan
        返回:
        DataNodeToStatusResp, The TSStatus will be SUCCEED_STATUS if the request is accepted, DATANODE_NOT_EXIST when some datanode does not exist.
      • updateDataNode

        public org.apache.iotdb.consensus.common.DataSet updateDataNode​(UpdateDataNodePlan updateDataNodePlan)
        Update the specified DataNode‘s location
        参数:
        updateDataNodePlan - UpdateDataNodePlan
        返回:
        TSStatus. The TSStatus will be set to SUCCESS_STATUS when update success, and DATANODE_NOT_EXIST when some datanode is not exist, UPDATE_DATANODE_FAILED when update failed.
      • registerConfigNode

        public org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterResp registerConfigNode​(org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq req)
      • restartConfigNode

        public org.apache.iotdb.common.rpc.thrift.TSStatus restartConfigNode​(org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation configNodeLocation)
      • getDataNodeConfiguration

        public DataNodeConfigurationResp getDataNodeConfiguration​(GetDataNodeConfigurationPlan req)
        Get TDataNodeConfiguration
        参数:
        req - GetDataNodeConfigurationPlan
        返回:
        The specific DataNode's configuration or all DataNodes' configuration if dataNodeId in GetDataNodeConfigurationPlan is -1
      • getRegisteredDataNodeCount

        public int getRegisteredDataNodeCount()
        Only leader use this interface
        返回:
        The number of registered DataNodes
      • getTotalCpuCoreCount

        public int getTotalCpuCoreCount()
        Only leader use this interface
        返回:
        The number of total cpu cores in online DataNodes
      • getRegisteredDataNodes

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration> getRegisteredDataNodes()
        Only leader use this interface
        返回:
        All registered DataNodes
      • getRegisteredDataNode

        public org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration getRegisteredDataNode​(int dataNodeId)
        Only leader use this interface

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

        参数:
        dataNodeId - The specified DataNode's index
        返回:
        The specified registered DataNode
      • getRegisteredDataNodeLocations

        public java.util.Map<java.lang.Integer,​org.apache.iotdb.common.rpc.thrift.TDataNodeLocation> getRegisteredDataNodeLocations()
      • getRegisteredDataNodeInfoList

        public java.util.List<org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo> getRegisteredDataNodeInfoList()
      • getRegisteredConfigNodes

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation> getRegisteredConfigNodes()
      • getRegisteredConfigNodeInfoList

        public java.util.List<org.apache.iotdb.confignode.rpc.thrift.TConfigNodeInfo> getRegisteredConfigNodeInfoList()
      • applyConfigNode

        public void applyConfigNode​(org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation configNodeLocation)
        Only leader use this interface, record the new ConfigNode's information
        参数:
        configNodeLocation - The new ConfigNode
      • checkConfigNodeBeforeRemove

        public org.apache.iotdb.common.rpc.thrift.TSStatus checkConfigNodeBeforeRemove​(RemoveConfigNodePlan removeConfigNodePlan)
        Only leader use this interface, check the ConfigNode before remove it
        参数:
        removeConfigNodePlan - RemoveConfigNodePlan
      • merge

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TSStatus> merge()
      • flush

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TSStatus> flush​(org.apache.iotdb.common.rpc.thrift.TFlushReq req)
      • clearCache

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TSStatus> clearCache()
      • loadConfiguration

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TSStatus> loadConfiguration()
      • setSystemStatus

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TSStatus> setSystemStatus​(java.lang.String status)
      • setDataNodeStatus

        public org.apache.iotdb.common.rpc.thrift.TSStatus setDataNodeStatus​(org.apache.iotdb.confignode.rpc.thrift.TSetDataNodeStatusReq setDataNodeStatusReq)
      • startHeartbeatService

        public void startHeartbeatService()
        Start the heartbeat service
      • stopHeartbeatService

        public void stopHeartbeatService()
        Stop the heartbeat service
      • getNodeCacheMap

        public java.util.Map<java.lang.Integer,​BaseNodeCache> getNodeCacheMap()
      • startUnknownDataNodeDetector

        public void startUnknownDataNodeDetector()
        Start unknownDataNodeDetector
      • stopUnknownDataNodeDetector

        public void stopUnknownDataNodeDetector()
        Stop the heartbeat service
      • removeNodeCache

        public void removeNodeCache​(int nodeId)
      • filterConfigNodeThroughStatus

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation> filterConfigNodeThroughStatus​(org.apache.iotdb.commons.cluster.NodeStatus... status)
        Filter the registered ConfigNodes through the specific NodeStatus
        参数:
        status - The specific NodeStatus
        返回:
        Filtered ConfigNodes with the specific NodeStatus
      • getNodeStatusByNodeId

        public org.apache.iotdb.commons.cluster.NodeStatus getNodeStatusByNodeId​(int nodeId)
        Get NodeStatus by nodeId
        参数:
        nodeId - The specific NodeId
        返回:
        NodeStatus of the specific node. If node does not exist, return null.
      • filterDataNodeThroughStatus

        public java.util.List<org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration> filterDataNodeThroughStatus​(org.apache.iotdb.commons.cluster.NodeStatus... status)
        Filter the registered DataNodes through the specific NodeStatus
        参数:
        status - The specific NodeStatus
        返回:
        Filtered DataNodes with the specific NodeStatus
      • getAllLoadScores

        public java.util.Map<java.lang.Integer,​java.lang.Long> getAllLoadScores()
        Get the loadScore of each DataNode
        返回:
        Map
      • getFreeDiskSpace

        public long getFreeDiskSpace​(int dataNodeId)
        Get the free disk space of the specified DataNode
        参数:
        dataNodeId - The index of the specified DataNode
        返回:
        The free disk space that sample through heartbeat, 0 if no heartbeat received
      • getLowestLoadDataNode

        public java.util.Optional<org.apache.iotdb.common.rpc.thrift.TDataNodeLocation> getLowestLoadDataNode()
        Get the DataNodeLocation of the DataNode which has the lowest loadScore
        返回:
        TDataNodeLocation with the lowest loadScore
      • getLowestLoadDataNode

        public org.apache.iotdb.common.rpc.thrift.TDataNodeLocation getLowestLoadDataNode​(java.util.Set<java.lang.Integer> nodes)
        Get the DataNodeLocation which has the lowest loadScore within input
        返回:
        TDataNodeLocation with the lowest loadScore
      • initNodeHeartbeatCache

        public void initNodeHeartbeatCache()
        Initialize the nodeCacheMap when the ConfigNode-Leader is switched