/**
  * Create this helper and {@link org.apache.zookeeper.ZooKeeper} delegate connected to the
  * specified URL string, but also set various callback {@link groovy.lang.Closure}s at once.
  *
  * @param callbacks
  * @param url
  * @throws IOException
  */
 public GroovyZooKeeperHelper(Map<String, Closure> callbacks, String url) throws IOException {
   this();
   for (String key : callbacks.keySet()) {
     try {
       getClass().getDeclaredField(key).set(this, callbacks.get(key));
     } catch (IllegalAccessException e) {
       log.error(e.getMessage(), e);
     } catch (NoSuchFieldException e) {
       log.error(e.getMessage(), e);
     }
   }
   setZookeeper(new ZooKeeper(url, DEFAULT_TIMEOUT, clientWatcher));
 }
Пример #2
0
 public static Integer getProcessID(Process p) {
   try {
     Field f = p.getClass().getDeclaredField("pid");
     f.setAccessible(true);
     Integer s = (Integer) f.get(p);
     return s;
   } catch (NoSuchFieldException e) {
     e.printStackTrace();
   } catch (SecurityException e) {
     e.printStackTrace();
   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   }
   return null;
 }