Package com.cloudera.cdk.morphline.api

Examples of com.cloudera.cdk.morphline.api.MorphlineCompilationException


      super(builder, config, parent, child, context);
     
      Command devNull = new DropRecordBuilder().build(null, this, null, context); // pipes into /dev/null
      List<Command> conditions = buildCommandChain(config, "conditions", devNull, true);
      if (conditions.size() == 0) {
        throw new MorphlineCompilationException("Missing conditions", config);
      } else {
        this.conditionChain = conditions.get(0);
      }

      List<Command> thenCommands = buildCommandChain(config, "then", child, true);
View Full Code Here


              .formatFor(locale);
             
          reporter = reporterBuilder.build(outputDir);
          outputDir.mkdirs();
          if (!outputDir.isDirectory()) {
            throw new MorphlineCompilationException("Directory not found: " + outputDir, config);
          }
          if (!outputDir.canWrite()) {
            throw new MorphlineCompilationException("Directory not writeable: " + outputDir, config);
          }
          reporter.start(frequency, TimeUnit.NANOSECONDS);
          reporters.put(outputDir, reporter);
        }
      }
View Full Code Here

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new DetectMimeType(this, config, parent, child, context);
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot instantiate command", config, e, this);
    } catch (MimeTypeException e) {
      throw new MorphlineCompilationException("Cannot instantiate command", config, e, this);
    }
  }
View Full Code Here

        if (inputStreams.size() > 0) {
          MimeTypes mimeTypes = MimeTypesFactory.create(inputStreams.toArray(new InputStream[inputStreams.size()]));
          ServiceLoader loader = new ServiceLoader();
          this.detector = new DefaultDetector(mimeTypes, loader);
        } else {
          throw new MorphlineCompilationException("Missing specification for MIME type mappings", config);
        }     
      } finally {
        for (InputStream in : inputStreams) {
          Closeables.closeQuietly(in);
        }
View Full Code Here

      this.inputFieldName = getConfigs().getString(config, "inputField");
      this.databaseFile = new File(getConfigs().getString(config, "database", "GeoLite2-City.mmdb"));
      try {
        this.databaseReader = new Reader(databaseFile);
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot read Maxmind database: " + databaseFile, config, e);
      }
      validateArguments();
    }
View Full Code Here

   * Validates that the given value is contained in the range [min, max]
   */
  public void validateRange(Config config, T value, Comparable<T> min, Comparable<T>  max) {
    boolean isValid = min.compareTo(value) <= 0 && 0 <= max.compareTo(value);
    if (!isValid) {
      throw new MorphlineCompilationException(
        String.format("Invalid choice: '%s' (choose from {%s..%s})",
                      value,
                      min,
                      max),
        config);
View Full Code Here

      if (!Arrays.asList(choices).contains(result)) {
        throw new IllegalArgumentException();
      }
      return result;
    } catch (IllegalArgumentException e) {
      throw new MorphlineCompilationException(
        String.format("Invalid choice: '%s' (choose from {%s})",
                      value,
                      Joiner.on(",").join(choices)),
        config);
    }
View Full Code Here

      super(builder, config, parent, child, context);
      this.charset = getConfigs().getCharset(config, "charset", null);
      this.ignoreFirstLine = getConfigs().getBoolean(config, "ignoreFirstLine", false);
      String cprefix = getConfigs().getString(config, "commentPrefix", "");
      if (cprefix.length() > 1) {
        throw new MorphlineCompilationException("commentPrefix must be at most one character long: " + cprefix, config);
      }
      this.commentPrefix = (cprefix.length() > 0 ? cprefix : null);
      validateArguments();
    }
View Full Code Here

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new DownloadHdfsFile(this, config, parent, child, context);
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    }
  }
View Full Code Here

   * into finalChild. The command will have currentParent as it's parent.
   */
  protected Command buildCommand(Config cmdConfig, Command currentParent, Command finalChild) {   
    Set<Map.Entry<String, Object>> entries = cmdConfig.root().unwrapped().entrySet();
    if (entries.size() != 1) {
      throw new MorphlineCompilationException("Illegal number of entries: " + entries.size(), cmdConfig);
    }
    Map.Entry<String, Object> entry = entries.iterator().next();
    String cmdName = entry.getKey();
   
    Class cmdClass;
    LOG.trace("Building command: {}", cmdName);
    if (!cmdName.contains(".") && !cmdName.contains("/")) {
      cmdClass = getContext().getCommandBuilder(cmdName);
      if (cmdClass == null) {
        throw new MorphlineCompilationException("No command builder registered for name: " + cmdName, cmdConfig);
      }
    } else {
      String className = cmdName.replace('/', '.');
      try {
        cmdClass = Class.forName(className);
      } catch (ClassNotFoundException e) {
        throw new MorphlineCompilationException("Cannot find command class: " + className, cmdConfig, e);
      }
    }
    Object obj;
    try {
      obj = cmdClass.newInstance();
    } catch (Exception e) {
      throw new MorphlineCompilationException("Cannot instantiate command class: " + cmdClass.getName(), cmdConfig, e);
    }
    if (!(obj instanceof CommandBuilder)) {
      throw new MorphlineCompilationException("Type of command " + cmdName + " must be an instance of "
          + CommandBuilder.class.getName() + " but is: " + cmdClass.getName(), cmdConfig);
    }
    CommandBuilder builder = (CommandBuilder) obj;
    Command cmd = builder.build(cmdConfig.getConfig(cmdName), currentParent, finalChild, getContext());
    return cmd;
View Full Code Here

TOP

Related Classes of com.cloudera.cdk.morphline.api.MorphlineCompilationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.