Exemplo n.º 1
0
 /** Gets a proxy client for a given local virtual machine. */
 public static ProxyClient getProxyClient(LocalVirtualMachine lvm) throws IOException {
   final String key = getCacheKey(lvm);
   ProxyClient proxyClient = cache.get(key);
   if (proxyClient == null) {
     proxyClient = new ProxyClient(lvm);
     cache.put(key, proxyClient);
   }
   return proxyClient;
 }
Exemplo n.º 2
0
 /** Gets a proxy client for a given "hostname:port". */
 public static ProxyClient getProxyClient(
     String hostName, int port, String userName, String password) throws IOException {
   final String key = getCacheKey(hostName, port, userName, password);
   ProxyClient proxyClient = cache.get(key);
   if (proxyClient == null) {
     proxyClient = new ProxyClient(hostName, port, userName, password);
     cache.put(key, proxyClient);
   }
   return proxyClient;
 }
Exemplo n.º 3
0
 private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames)
     throws InstanceNotFoundException, ReflectionException, IOException {
   NameValueMap values = cachedValues.get(objName);
   if (values != null && values.keySet().containsAll(attrNames)) {
     return values;
   }
   attrNames = new TreeSet<String>(attrNames);
   Set<String> oldNames = cachedNames.get(objName);
   if (oldNames != null) {
     attrNames.addAll(oldNames);
   }
   values = new NameValueMap();
   final AttributeList attrs =
       conn.getAttributes(objName, attrNames.toArray(new String[attrNames.size()]));
   for (Attribute attr : attrs.asList()) {
     values.put(attr.getName(), attr.getValue());
   }
   cachedValues.put(objName, values);
   cachedNames.put(objName, attrNames);
   return values;
 }