src/jdk.jvmstat/share/classes/sun/tools/jstatd/RemoteHostImpl.java

Print this page
rev 10537 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


  51     private MonitoredHost monitoredHost;
  52     private Set<Integer> activeVms;
  53 
  54     public RemoteHostImpl() throws MonitorException {
  55         try {
  56             monitoredHost = MonitoredHost.getMonitoredHost("localhost");
  57         } catch (URISyntaxException e) { }
  58 
  59         activeVms = monitoredHost.activeVms();
  60         monitoredHost.addHostListener(this);
  61     }
  62 
  63     public RemoteVm attachVm(int lvmid, String mode)
  64                     throws RemoteException, MonitorException {
  65         Integer v = lvmid;
  66         RemoteVm stub = null;
  67         StringBuilder sb = new StringBuilder();
  68 
  69         sb.append("local://").append(lvmid).append("@localhost");
  70         if (mode != null) {
  71             sb.append("?mode=" + mode);
  72         }
  73 
  74         String vmidStr = sb.toString();
  75 
  76         try {
  77             VmIdentifier vmid = new VmIdentifier(vmidStr);
  78             MonitoredVm mvm = monitoredHost.getMonitoredVm(vmid);
  79             RemoteVmImpl rvm = new RemoteVmImpl((BufferedMonitoredVm)mvm);
  80             stub = (RemoteVm) UnicastRemoteObject.exportObject(rvm, 0);
  81         }
  82         catch (URISyntaxException e) {
  83             throw new RuntimeException("Malformed VmIdentifier URI: "
  84                                        + vmidStr, e);
  85         }
  86         return stub;
  87     }
  88 
  89     public void detachVm(RemoteVm rvm) throws RemoteException {
  90         rvm.detach();
  91     }




  51     private MonitoredHost monitoredHost;
  52     private Set<Integer> activeVms;
  53 
  54     public RemoteHostImpl() throws MonitorException {
  55         try {
  56             monitoredHost = MonitoredHost.getMonitoredHost("localhost");
  57         } catch (URISyntaxException e) { }
  58 
  59         activeVms = monitoredHost.activeVms();
  60         monitoredHost.addHostListener(this);
  61     }
  62 
  63     public RemoteVm attachVm(int lvmid, String mode)
  64                     throws RemoteException, MonitorException {
  65         Integer v = lvmid;
  66         RemoteVm stub = null;
  67         StringBuilder sb = new StringBuilder();
  68 
  69         sb.append("local://").append(lvmid).append("@localhost");
  70         if (mode != null) {
  71             sb.append("?mode=").append(mode);
  72         }
  73 
  74         String vmidStr = sb.toString();
  75 
  76         try {
  77             VmIdentifier vmid = new VmIdentifier(vmidStr);
  78             MonitoredVm mvm = monitoredHost.getMonitoredVm(vmid);
  79             RemoteVmImpl rvm = new RemoteVmImpl((BufferedMonitoredVm)mvm);
  80             stub = (RemoteVm) UnicastRemoteObject.exportObject(rvm, 0);
  81         }
  82         catch (URISyntaxException e) {
  83             throw new RuntimeException("Malformed VmIdentifier URI: "
  84                                        + vmidStr, e);
  85         }
  86         return stub;
  87     }
  88 
  89     public void detachVm(RemoteVm rvm) throws RemoteException {
  90         rvm.detach();
  91     }