Beispiel #1
0
 /**
  * Shutdown a specific member.
  *
  * @param m
  */
 private void shutdownMember(MemberInfo m) {
   ResourceManager rm = GroupMember.memberInfoToResourceManager(m);
   if (rm != null) {
     try {
       rm.shutdown(FORCE_SHUTDOWN);
     } catch (Exception e) {
       // do nothing.
     }
   }
 }
 /**
  * Add the contents of a custom langpack (if exist) to the previos loaded comman langpack. If not
  * exist, trace an info and do nothing more.
  *
  * @param idata install data to be used
  */
 protected void addCustomLangpack(AutomatedInstallData idata) {
   // We try to load and add a custom langpack.
   try {
     idata.langpack.add(ResourceManager.getInstance().getInputStream(LANG_FILE_NAME));
   } catch (Throwable exception) {
     Debug.trace("No custom langpack available.");
     return;
   }
   Debug.trace("Custom langpack for " + idata.localeISO3 + " available.");
 }
 /**
  * checks whether the Resource should run, i.e. it is required by at least one of the currently
  * registered features
  *
  * @return true if the Resource is required, false otherwise
  */
 public boolean isRequired() {
   if (req == null) {
     return true;
   }
   Iterator<String> it = req.iterator();
   while (it.hasNext()) {
     if (ResourceManager.reqRegistered(it.next())) {
       return true;
     }
   }
   return false;
 }
Beispiel #4
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    String string;
    string = "Naomi loves frogs lots!";
    System.out.println("Please be true! " + string.contains(" frog"));

    ResourceManager rman;
    rman = ResourceManager.newInstance();
    rman.loadResourcesFrom(new File("/C:/Users/ldigregorio/Desktop/Resources.txt"), '#');

    Resource[] resources;
    resources = new Resource[rman.getResourcesThatMatch("Code From Jarvis class").length];
    resources = rman.getResourcesThatMatch("Code From Jarvis class");

    for (int i = 0; i < resources.length; i++) {
      System.out.println(resources[i].getDescription());
      System.out.println(resources[i].getID());
      System.out.println(resources[i].getMimeType());
      System.out.println(resources[i].getSizeInBytes());
      System.out.println(resources[i].getLocation());
    }
  }
Beispiel #5
0
  /**
   * 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);
  }
Beispiel #6
0
  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();
  }