/**
   * Refresh our groups by contacting at least one available RM per group, and retrieving the new
   * group members.
   */
  private void refreshRMGroups() {
    // Cars.
    ResourceManager carRM = AbstractRMICommand.getAvailableRM(carGroup);
    if (carRM != null) {
      // System.out.println("carRM found.");
      try {
        this.updateRMGroup(carGroup, carRM.getGroupMembers());
        // System.out.println("updated my car group with: " + carGroup);
      } catch (RemoteException e) {
        // System.out.println("Invalid carRM to refresh the car group.");
      }
    } else {
      System.out.println("no available carRM.");
    }

    // Flights.
    ResourceManager flightRM = AbstractRMICommand.getAvailableRM(flightGroup);
    if (flightRM != null) {
      // System.out.println("flightRM found.");
      try {
        this.updateRMGroup(flightGroup, flightRM.getGroupMembers());
        // System.out.println("updated my flight group with: " + flightGroup);
      } catch (RemoteException e) {
        // System.out.println("Invald flightRM to refresh the flight group.");
      }
    } else {
      System.out.println("no available flightRM.");
    }

    // Rooms.
    ResourceManager roomRM = AbstractRMICommand.getAvailableRM(roomGroup);
    if (roomRM != null) {
      // System.out.println("roomRM found.");
      try {
        this.updateRMGroup(roomGroup, roomRM.getGroupMembers());
        // System.out.println("updated my room group with: " + roomGroup);
      } catch (RemoteException e) {
        // System.out.println("Invald roomRM to refresh the room group.");
      }
    } else {
      System.out.println("no available roomRM.");
    }

    // print the group members.
    // System.out.println("RefreshRMGroups()");
    // System.out.println("car group: " + carGroup);
    // System.out.println("flight group: " + flightGroup);
    // System.out.println("room group: " + roomGroup);
  }
  private HavocadoFlesh(
      boolean isMaster,
      String myRMIServiceName,
      String groupName,
      String carMachine,
      String carRMIServiceName,
      String flightMachine,
      String flightRMIServiceName,
      String roomMachine,
      String roomRMIServiceName,
      String configFile)
      throws RemoteException, NotBoundException {
    // Create the group member.
    super(isMaster, myRMIServiceName, groupName, configFile);

    // Initialize the lock manager.
    this.lm = new LockManager(this);

    // Initialize the overseer
    this.overseer = new Overseer(this);

    // initialize the RMI service.
    ResourceManager rm = (ResourceManager) UnicastRemoteObject.exportObject(this, 0);

    // Bind the remote object's stub in the registry
    Registry registry = LocateRegistry.getRegistry();
    registry.rebind(myRMIServiceName, rm);

    if (this.isMaster) {
      if (carMachine != null
          && carRMIServiceName != null
          && flightMachine != null
          && flightRMIServiceName != null
          && roomMachine != null
          && roomRMIServiceName != null) {
        // cars.
        ResourceManager rmCars;
        registry = LocateRegistry.getRegistry(carMachine);
        rmCars = (ResourceManager) registry.lookup(carRMIServiceName);
        // this.carGroup.addAll(rmCars.getGroupMembers());
        updateRMGroup(carGroup, rmCars.getGroupMembers());

        // flights.
        ResourceManager rmFlights;
        registry = LocateRegistry.getRegistry(flightMachine);
        rmFlights = (ResourceManager) registry.lookup(flightRMIServiceName);
        // this.flightGroup.addAll(rmFlights.getGroupMembers());
        updateRMGroup(flightGroup, rmFlights.getGroupMembers());

        // rooms.
        ResourceManager rmRooms;
        registry = LocateRegistry.getRegistry(roomMachine);
        rmRooms = (ResourceManager) registry.lookup(roomRMIServiceName);
        // his.roomGroup.addAll(rmRooms.getGroupMembers());
        updateRMGroup(roomGroup, rmRooms.getGroupMembers());

        // print the group members.
        // System.out.println("car group: " + carGroup);
        // System.out.println("flight group: " + flightGroup);
        // System.out.println("room group: " + roomGroup);

      }

      // Start the overseer thread if I am a master.
      this.overseer.start();
    }

    // join the group.
    joinGroup();
  }