Class NodeStatusPersistence

java.lang.Object
com.nt.udc.nodemgr.shutdown.persistence.NodeStatusPersistence

public class NodeStatusPersistence extends Object
Manages the persistence of node statuses before a shutdown event. This class stores the status of running nodes in a JSON file, which can be retrieved later to restore the previous state of the nodes.
  • Constructor Details

    • NodeStatusPersistence

      public NodeStatusPersistence(Path configFile, com.nt.udc.nodemgr.OSANodeMgr nodeMgr)
  • Method Details

    • pauseNodesForShutdown

      public boolean pauseNodesForShutdown()
      Persists the statuses of all running nodes before shutting them down.

      The method retrieves the list of nodes from the node manager and filters out nodes that are running. It then serializes their statuses to a JSON file specified by configFile.

      Returns:
      true if the node statuses were successfully persisted, false otherwise.
    • resumePausedNodes

      public boolean resumePausedNodes() throws BulkOpException
      Resumes all nodes that were paused before shutdown by reading their statuses from the persisted configuration file.

      The method deserializes the JSON file containing the statuses of the nodes that were running before shutdown, and attempts to resume each paused node.

      Returns:
      true if all paused nodes were successfully resumed, false otherwise.
      Throws:
      BulkOpException - if there is a failure in resuming multiple nodes at once.