public void actionPerformed(ObjectOutputStream oos, Message msg) throws EventHandleException {
    try {
      /* get the handler of the ServerPeer */
      ServerPeer serverpeer = (ServerPeer) gui.peer();

      /* get the message body */
      SPLeaveReplacementBody body = (SPLeaveReplacementBody) msg.getBody();

      TreeNode treeNode = body.getTreeNode();
      treeNode.setContent(body.getContent());
      SPGeneralAction.saveData(body.getContent().getData());
      treeNode.setStatus(TreeNode.ACTIVE);
      treeNode.setRole(TreeNode.MASTER);
      treeNode.addCoOwnerList(body.getPhysicalSender());
      serverpeer.addListItem(treeNode);
      SPGeneralAction.updateRotateRoutingTable(serverpeer, treeNode);

      serverpeer.setActivateStablePosition(
          new ActivateStablePosition(serverpeer, treeNode, ServerPeer.TIME_TO_STABLE_POSITION));

      ((ServerGUI) gui).updatePane(treeNode);
    } catch (Exception e) {
      e.printStackTrace();
      throw new EventHandleException(
          "Replace a super peer's position failure when it leaves network", e);
    }
  }
  public void actionPerformed(PhysicalInfo dest, Message msg)
      throws EventHandleException, IOException {
    super.actionPerformed(dest, msg);

    try {
      /* get the handler of the ServerPeer */
      ServerPeer serverpeer = (ServerPeer) gui.peer();

      /* get the message body */
      SPLBRotationPullBody body = (SPLBRotationPullBody) msg.getBody();

      TreeNode treeNode = body.getTreeNode();
      PhysicalInfo physicalSender = body.getPhysicalSender();
      boolean direction = body.getDirection();

      treeNode.setStatus(TreeNode.ACTIVE);
      treeNode.addCoOwnerList(physicalSender);

      // clean the previous slave if having
      SPGeneralAction.deleteTreeNode(serverpeer, treeNode);

      // add new node
      serverpeer.addListItem(treeNode);
      boolean result =
          SPGeneralAction.transferFakeNode(
              serverpeer, treeNode, direction, false, body.getPhysicalSender());

      if (result) {
        // ActivateStablePosition activateStablePosition =
        new ActivateStablePosition(serverpeer, treeNode, ServerPeer.TIME_TO_STABLE_POSITION);
      }
      // update GUI
      ((ServerGUI) gui).updatePane(treeNode);
    } catch (Exception e) {
      e.printStackTrace();
      throw new EventHandleException("SP_LB_ROTATION_PULL operation failure", e);
    }
  }