コード例 #1
0
  @Override
  public String createTask(Graph<Operation, EdgeType> graph, String hostname) {
    logger.info("create task script for host:" + hostname);
    List<ByteSource> byteSources = Lists.newArrayList();
    TreeSet<Operation> imports =
        Sets.newTreeSet(
            new Comparator<Operation>() {
              @Override
              public int compare(Operation o1, Operation o2) {
                return o1.getName().compareTo(o2.getName());
              }
            });
    StringBuilder builder = new StringBuilder();
    String changeLine = System.getProperty("line.separator");

    builder.append(changeLine + "node '" + hostname + "'{" + changeLine);
    String definedContent = opBuilder.createDefineContent(graph, imports, null);
    builder.append(definedContent);
    builder.append(changeLine + "}");

    logger.debug(builder.toString());

    imports.addAll(dependedOperation(imports));
    try {
      for (Operation operation : imports) {
        if (operation.getDefineMd5() != null) {
          byteSources.add(fileService.findFile(operation.getDefineMd5()));
        }
      }
      byteSources.add(ByteSource.wrap(builder.toString().getBytes()));
      String md5Key = fileService.saveFile(ByteSource.concat(byteSources));
      logger.info("the md5key of this task script is" + md5Key);
      logger.info("create task script successful");
      return md5Key;
    } catch (IOException e) {
      logger.error("store task script file failed");
      e.printStackTrace();
    }
    return null;
  }
コード例 #2
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public Operation createOperation(
     Graph<Node, EdgeType> graph, String operationName, Map extractParams) {
   return opBuilder.createNewOperation(graph, operationName, extractParams);
 }
コード例 #3
0
 public String createClassDefinefile(
     Node node, String defineName, Map<String, ParamValue> extractParams) {
   return opBuilder.createClassDefineFileByNode(node, defineName, extractParams).get();
 }