Package com.cloudera.cdk.morphline.api

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


      String jsonFactoryClassName = getConfigs().getString(config, "jsonFactory", null);
      if (jsonFactoryClassName != null) {
        try {
          jsonFactory = (JsonFactory) Class.forName(jsonFactoryClassName).newInstance();
        } catch (Exception e) {
          throw new MorphlineCompilationException("Cannot create instance", config, e);
        }
      }
     
      String objectMapperClassName = getConfigs().getString(config, "objectMapper", null);
      ObjectMapper objectMapper = null;
      if (objectMapperClassName != null) {
        try {
          objectMapper = (ObjectMapper) Class.forName(objectMapperClassName).newInstance();
        } catch (Exception e) {
          throw new MorphlineCompilationException("Cannot create instance", config, e);
        }
      } else {
        objectMapper = new ObjectMapper(jsonFactory);
      }
     
      String outputClassName = getConfigs().getString(config, "outputClass", JsonNode.class.getName());
      Class outputClass;
      try {
        outputClass = Class.forName(outputClassName);
      } catch (ClassNotFoundException e) {
        throw new MorphlineCompilationException("Class not found", config, e);
      }
     
      reader = objectMapper.reader(outputClass);
      validateArguments();
    }
View Full Code Here


      SolrLocator locator = new SolrLocator(solrLocatorConfig, context);
      LOG.debug("solrLocator: {}", locator);
      IndexSchema schema = locator.getIndexSchema();
      FieldType fieldType = schema.getFieldTypeByName(solrFieldType);
      if (fieldType == null) {
        throw new MorphlineCompilationException("Missing Solr field type in schema.xml for name: " + solrFieldType, config);
      }
      this.analyzer = fieldType.getAnalyzer();
      Preconditions.checkNotNull(analyzer);
      try { // register CharTermAttribute for later (implicit) reuse
        this.token = analyzer.tokenStream("content", reader).addAttribute(CharTermAttribute.class);
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot create token stream", config, e);
      }
      Preconditions.checkNotNull(token);
      validateArguments();
    }
View Full Code Here

      this.inputFieldName = getConfigs().getString(config, "inputField");
     
      this.outputFieldName = getConfigs().getString(config, "outputField", null);
      this.outputFieldNames = getConfigs().getStringList(config, "outputFields", null);
      if (outputFieldName == null && outputFieldNames == null) {
        throw new MorphlineCompilationException("Either outputField or outputFields must be defined", config);
      }
      if (outputFieldName != null && outputFieldNames != null) {
        throw new MorphlineCompilationException("Must not define both outputField and outputFields at the same time", config);
      }
     
      String separator = getConfigs().getString(config, "separator");
      boolean isRegex = getConfigs().getBoolean(config, "isRegex", false);
      GrokDictionaries dict = new GrokDictionaries(config, getConfigs());
View Full Code Here

    // work around the fact that SimpleDateFormat doesn't understand Unix time format
    private SimpleDateFormat getUnixTimeFormat(String format, TimeZone timeZone) {
      if (format.equals("unixTimeInMillis")) {
        if (!"UTC".equals(timeZone.getID())) {
          throw new MorphlineCompilationException("timeZone must be UTC for date format 'unixTimeInMillis'", getConfig());
        }
        return UNIX_TIME_IN_MILLIS;
      } else if (format.equals("unixTimeInSeconds")) {
        if (!"UTC".equals(timeZone.getID())) {
          throw new MorphlineCompilationException("timeZone must be UTC for date format 'unixTimeInSeconds'", getConfig());
        }
        return UNIX_TIME_IN_SECONDS;
      } else {
        return null;
      }
View Full Code Here

      }
    }
   
    private TimeZone getTimeZone(String timeZoneID) {
      if (!Arrays.asList(TimeZone.getAvailableIDs()).contains(timeZoneID)) {
        throw new MorphlineCompilationException("Unknown timezone: " + timeZoneID, getConfig());
      }
      return TimeZone.getTimeZone(timeZoneID);
    }
View Full Code Here

      }
      assert Locale.ROOT.toString().equals("");
      if (name.equals(Locale.ROOT.toString())) {
        return Locale.ROOT;
      }
      throw new MorphlineCompilationException("Unknown locale: " + name, getConfig());
    }
View Full Code Here

      Config paths = getConfigs().getConfig(config, "paths");
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(paths)) {
        String fieldName = entry.getKey();       
        String path = entry.getValue().toString().trim();
        if (path.contains("//")) {
          throw new MorphlineCompilationException("No support for descendant axis available yet", config);
        }
        if (path.startsWith("/")) {
          path = path.substring(1);
        }
        if (path.endsWith("/")) {
View Full Code Here

    if (expr.equals("*")) {
      expr = "glob:*";
    }
    int i = expr.indexOf(':');
    if (i < 0) {
      throw new MorphlineCompilationException("Illegal match expression: " + expr, config);
    }
    String type = expr.substring(0, i);
    String pattern = expr.substring(i + 1, expr.length());
    if (type.equals("literal")) {
      return new LiteralExpression(pattern);
    } else if (type.equals("regex")) {
      if (pattern.equals(".*")) {
        return new MatchAllExpression(); // optimization
      }
      return new RegexExpression(Pattern.compile(pattern));
    } else if (type.equals("glob")) {
      if (pattern.equals("*")) {
        return new MatchAllExpression(); // optimization
      }
      return new GlobExpression(pattern);
    } else {
      throw new MorphlineCompilationException("Illegal match type: " + type, config);
    }
  }
View Full Code Here

      }
      if (schemaField != null) {
        numDefinitions++;
      }
      if (numDefinitions == 0) {
        throw new MorphlineCompilationException(
          "Either schemaFile or schemaString or schemaField must be defined", config);
      }
      if (numDefinitions > 1) {
        throw new MorphlineCompilationException(
          "Must define only one of schemaFile or schemaString or schemaField at the same time", config);
      }

      if (schemaString != null) {
        this.fixedSchema = new Parser().parse(schemaString);
      } else if (schemaFile != null) {
        try {
          this.fixedSchema = new Parser().parse(new File(schemaFile));
        } catch (IOException e) {
          throw new MorphlineCompilationException(
            "Cannot parse external Avro schema file: " + schemaFile, config, e);
        }
      } else {
        this.fixedSchema = null;
      }
View Full Code Here

        String schemaFile = getConfigs().getString(config, "writerSchemaFile", null);
        if (schemaFile != null) {
          try {
            this.writerSchema = new Parser().parse(new File(schemaFile));
          } catch (IOException e) {
            throw new MorphlineCompilationException("Cannot parse external Avro writer schema file: " + schemaFile, config, e);
          }
        } else {
          this.writerSchema = null;
        }
      }
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.