예제 #1
0
  /**
   * get all workers heartbeats of the supervisor
   *
   * @param conf
   * @return Map<workerId, WorkerHeartbeat>
   * @throws IOException
   * @throws IOException
   */
  public Map<String, WorkerHeartbeat> readWorkerHeartbeats(Map conf) throws Exception {

    Map<String, WorkerHeartbeat> workerHeartbeats = new HashMap<String, WorkerHeartbeat>();

    // get the path: STORM-LOCAL-DIR/workers
    String path = StormConfig.worker_root(conf);

    List<String> workerIds = PathUtils.read_dir_contents(path);

    if (workerIds == null) {
      LOG.info("No worker dir under " + path);
      return workerHeartbeats;
    }

    for (String workerId : workerIds) {

      WorkerHeartbeat whb = readWorkerHeartbeat(conf, workerId);

      // ATTENTION: whb can be null
      workerHeartbeats.put(workerId, whb);
    }
    return workerHeartbeats;
  }
예제 #2
0
  private String getClassPath(String stormjar, String stormHome, Map totalConf) {

    // String classpath = JStormUtils.current_classpath() + ":" + stormjar;
    // return classpath;

    String classpath = JStormUtils.current_classpath();

    String[] classpathes = classpath.split(":");

    Set<String> classSet = new HashSet<String>();

    for (String classJar : classpathes) {
      classSet.add(classJar);
    }

    if (stormHome != null) {
      List<String> stormHomeFiles = PathUtils.read_dir_contents(stormHome);

      for (String file : stormHomeFiles) {
        if (file.endsWith(".jar")) {
          classSet.add(stormHome + File.separator + file);
        }
      }

      List<String> stormLibFiles = PathUtils.read_dir_contents(stormHome + File.separator + "lib");
      for (String file : stormLibFiles) {
        if (file.endsWith(".jar")) {
          classSet.add(stormHome + File.separator + "lib" + File.separator + file);
        }
      }
    }

    // filter jeromq.jar/jzmq.jar to avoid ZMQ.class conflict
    String filterJarKeyword = null;
    String transport_plugin_klassName = (String) totalConf.get(Config.STORM_MESSAGING_TRANSPORT);
    if (transport_plugin_klassName.equals(MQContext.class.getCanonicalName())) {
      filterJarKeyword = "jeromq";
    } else if (transport_plugin_klassName.equals("org.act.tstream.message.jeroMq.JMQContext")) {
      filterJarKeyword = "jzmq";
    }

    StringBuilder sb = new StringBuilder();
    if (filterJarKeyword != null) {
      for (String jar : classSet) {
        if (jar.contains(filterJarKeyword)) {
          continue;
        }
        sb.append(jar + ":");
      }
    } else {
      for (String jar : classSet) {
        sb.append(jar + ":");
      }
    }

    if (ConfigExtension.isEnableTopologyClassLoader(totalConf)) {
      return sb.toString().substring(0, sb.length() - 1);
    } else {
      sb.append(stormjar);
      return sb.toString();
    }
  }