/**
   * Resolve the dependencies. Copies jars to the impl/lib part of the bundle and file/directory
   * dependencies to the bundle.
   *
   * @param config context configuration
   * @throws IOException
   * @throws URISyntaxException
   */
  public void resolveDependencies(Map<String, Object> config)
      throws IOException, URISyntaxException {
    for (BOperatorInvocation op : operatorToJarDependencies.keySet()) {
      ArrayList<String> jars = new ArrayList<String>();

      for (Path pa : operatorToJarDependencies.get(op)) {
        String jarName = resolveDependency(pa, config);
        jars.add("impl/lib/" + jarName);
      }

      String[] jarPaths = jars.toArray(new String[jars.size()]);
      op.setParameter("jar", jarPaths);
    }

    ArrayList<String> jars = new ArrayList<String>();
    for (Path dep : globalDependencies) {
      if (previouslyCopiedDependencies.containsKey(dep)) {
        continue;
      }
      String jarName = resolveDependency(dep, config);
      jars.add("impl/lib/" + jarName);
    }

    List<BOperator> ops = topology.builder().getOps();
    if (jars.size() != 0) {
      for (BOperator op : ops) {
        if (op instanceof BOperatorInvocation) {
          BOperatorInvocation bop = (BOperatorInvocation) op;
          if (Functional.class.isAssignableFrom(bop.op().getOperatorClass())) {
            JSONObject params = (JSONObject) bop.json().get("parameters");
            JSONObject op_jars = (JSONObject) params.get("jar");
            if (null == op_jars) {
              JSONObject val = new OrderedJSONObject();
              val.put("value", new JSONArray());
              params.put("jar", val);
              op_jars = val;
            }
            JSONArray value = (JSONArray) op_jars.get("value");
            for (String jar : jars) {
              value.add(jar);
            }
          }
        }
      }
    }

    for (Artifact dep : globalFileDependencies) resolveFileDependency(dep, config);
  }
예제 #2
0
 protected SPLStream addMatchingOutput(BOperatorInvocation bop, Type tupleType) {
   return new SPLStreamImpl(this, bop.addOutput(getSchema()));
 }