public MonitoredHostProvider(HostIdentifier hostId) throws MonitorException {
  this.hostId=hostId;
  this.listeners=new ArrayList<HostListener>();
  this.interval=DEFAULT_POLLING_INTERVAL;
  this.activeVms=new HashSet<Integer>();
  String rmiName;
  String sn=serverName;
  String path=hostId.getPath();
  if ((path != null) && (path.length() > 0)) {
    sn=path;
  }
  if (hostId.getPort() != -1) {
    rmiName="rmi://" + hostId.getHost() + ":"+ hostId.getPort()+ sn;
  }
 else {
    rmiName="rmi://" + hostId.getHost() + sn;
  }
  try {
    remoteHost=(RemoteHost)Naming.lookup(rmiName);
  }
 catch (  RemoteException e) {
    String message="RMI Registry not available at " + hostId.getHost();
    if (hostId.getPort() == -1) {
      message=message + ":" + java.rmi.registry.Registry.REGISTRY_PORT;
    }
 else {
      message=message + ":" + hostId.getPort();
    }
    if (e.getMessage() != null) {
      throw new MonitorException(message + "\n" + e.getMessage(),e);
    }
 else {
      throw new MonitorException(message,e);
    }
  }
catch (  NotBoundException e) {
    String message=e.getMessage();
    if (message == null)     message=rmiName;
    throw new MonitorException("RMI Server " + message + " not available",e);
  }
catch (  MalformedURLException e) {
    e.printStackTrace();
    throw new IllegalArgumentException("Malformed URL: " + rmiName);
  }
  this.vmManager=new RemoteVmManager(remoteHost);
  this.timer=new Timer(true);
}

public MonitoredHostProvider ( HostIdentifier hostId ) throws MonitorException { this . hostId = hostId ; this . listeners = new ArrayList < HostListener > ( ) ; this . interval = DEFAULT_POLLING_INTERVAL ; this . activeVms = new HashSet < Integer > ( ) ; String rmiName ; String sn = serverName ; String path = hostId . getPath ( ) ; if ( ( path != null ) && ( path . length ( ) > 0 ) ) { sn = path ; } if ( hostId . getPort ( ) != - 1 ) { rmiName = "rmi://" + hostId . getHost ( ) + ":" + hostId . getPort ( ) + sn ; } else { rmiName = "rmi://" + hostId . getHost ( ) + sn ; } try { remoteHost = ( RemoteHost ) Naming . lookup ( rmiName ) ; } catch ( RemoteException e ) { String message = "RMI Registry not available at " + hostId . getHost ( ) ; if ( hostId . getPort ( ) == - 1 ) { message = message + ":" + java . rmi . registry . Registry . REGISTRY_PORT ; } else { message = message + ":" + hostId . getPort ( ) ; } if ( e . getMessage ( ) != null ) { throw new MonitorException ( message + "\n" + e . getMessage ( ) , e ) ; } else { throw new MonitorException ( message , e ) ; } } catch ( NotBoundException e ) { String message = e . getMessage ( ) ; if ( message == null ) message = rmiName ; throw new MonitorException ( "RMI Server " + message + " not available" , e ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; throw new IllegalArgumentException ( "Malformed URL: " + rmiName ) ; } this . vmManager = new RemoteVmManager ( remoteHost ) ; this . timer = new Timer ( true ) ; }
create a monitoredhostprovider instance using the given hostidentifier .
