コード例 #1
0
  /**
   * this initializes the managers that support the internal communication network.
   *
   * <p>TODO this should be refactored to use the conf file
   */
  private void startManagers() {
    if (conf == null) return;

    // start the inbound and outbound manager worker threads
    ManagementQueue.startup();

    // create manager for network changes
    networkMgr = NetworkManager.initManager(conf);

    // create manager for leader election. The number of votes (default 1)
    // is used to break ties where there are an even number of nodes.
    // electionMgr = ElectionManager.initManager(conf);
    raftMgr = RaftManager.initManager(conf, clusterConfList);
    // create manager for accepting jobs
    jobMgr = JobManager.initManager(conf);

    System.out.println(
        "---> Server.startManagers() expecting "
            + conf.getAdjacent().getAdjacentNodes().size()
            + " connections");
    // establish nearest nodes and start sending heartbeats
    heartbeatMgr = HeartbeatManager.initManager(conf);
    for (NodeDesc nn : conf.getAdjacent().getAdjacentNodes().values()) {
      HeartbeatData node =
          new HeartbeatData(nn.getNodeId(), nn.getHost(), nn.getPort(), nn.getMgmtPort());

      // fn(from, to)
      HeartbeatPusher.getInstance().connectToThisNode(conf.getNodeId(), node);
    }
    // heartbeatMgr.start();
    // manage heartbeatMgr connections
    HeartbeatPusher conn = HeartbeatPusher.getInstance();
    conn.start();

    /**
     * *** Leader Election Start 29th March
     * 2015************************************************************************* This will start
     * the monitor thread and check whether there is leader or not. If not then it will start the
     * Election. This thread is used to send appendRPC to all the followers. IF they don't receive
     * messages within a certain period then they will start election
     */
    raftMgr.startMonitor();

    logger.info("Server " + conf.getNodeId() + ", managers initialized");

    // Adding code to add all clusters

  }
コード例 #2
0
 public void release() {
   if (HeartbeatManager.getInstance() != null) HeartbeatManager.getInstance().release();
 }