コード例 #1
0
  /** {@inheritDoc} */
  public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval) throws MonitorException {
    VmIdentifier nvmid = null;
    try {
      nvmid = hostId.resolve(vmid);
      RemoteVm rvm = remoteHost.attachVm(vmid.getLocalVmId(), vmid.getMode());
      RemoteMonitoredVm rmvm = new RemoteMonitoredVm(rvm, nvmid, timer, interval);
      rmvm.attach();
      return rmvm;

    } catch (RemoteException e) {
      throw new MonitorException("Remote Exception attaching to " + nvmid.toString(), e);
    } catch (URISyntaxException e) {
      /*
       * the VmIdentifier is expected to be a valid and should resolve
       * easonably against the host identifier. A URISyntaxException
       * here is most likely a programming error.
       */
      throw new IllegalArgumentException("Malformed URI: " + vmid.toString(), e);
    }
  }