示例#1
0
  private void wakeup(String[] names, Configuration config, InetAddress host, int port) {
    Machine[] hosts = config.getMachines();
    HashMap hostMap = new HashMap(hosts.length);

    for (int i = 0; i < hosts.length; i++) {
      Machine hostConfig = hosts[i];
      hostMap.put(hostConfig.getName().toLowerCase(), hostConfig);
    }

    for (int i = 0; i < names.length; i++) {
      String name = names[i];
      Machine hostConfig = (Machine) hostMap.get(name.toLowerCase());
      if (null != hostConfig) {
        wakeupConfig(hostConfig);
      } else {
        try {
          wakeupEthernetAddresses(name, host, port);
        } catch (IllegalEthernetAddressException e) {
          LOG.warning(
              Messages.ERROR_MESSAGES.getFormattedString("wakeup.notAHostOrEthernetAddress", name));
        }
      }
    }
  }
示例#2
0
 private void wakeupConfig(Machine host) {
   try {
     EthernetAddress ethernetAddress = new EthernetAddress(host.getEthernetAddress());
     InetAddress hostAddress = InetAddress.getByName(host.getHost());
     WakeUpUtil.wakeup(ethernetAddress, hostAddress, host.getPort());
   } catch (IOException e) {
     System.err.println(
         Messages.ERROR_MESSAGES.getFormattedString(
             "wakeup.io", host.getHost(), String.valueOf(host.getPort())));
   } catch (IllegalEthernetAddressException e) {
     // should not happen
     System.err.println(
         Messages.ERROR_MESSAGES.getFormattedString(
             "wakeup.invalidEthernetAddress", host.getHost(), String.valueOf(host.getPort())));
   }
 }