Package com.cloudera.cdk.morphline.api

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


    }
   
    String morphlineFile = context.getString(MORPHLINE_FILE_PARAM);
    String morphlineId = context.getString(MORPHLINE_ID_PARAM);
    if (morphlineFile == null || morphlineFile.trim().length() == 0) {
      throw new MorphlineCompilationException("Missing parameter: " + MORPHLINE_FILE_PARAM, null);
    }
    Config override = ConfigFactory.parseMap(context.getSubProperties(MORPHLINE_VARIABLE_PARAM + "."));
    morphline = new Compiler().compile(new File(morphlineFile), morphlineId, morphlineContext, finalChild, override);     
    morphlineFileAndId = morphlineFile + "@" + morphlineId;
  }
View Full Code Here


          } finally {
            Closeables.closeQuietly(in);
          }
        }       
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot parse UserAgent database: " + databaseFile, config, e);
      }
     
      Config outputFields = getConfigs().getConfig(config, "outputFields", ConfigFactory.empty());
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(outputFields)) {
        mappings.add(
View Full Code Here

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

    public XQuery(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) throws SaxonApiException, IOException, XMLStreamException {
      super(builder, config, parent, child, context);
     
      List<? extends Config> fragmentConfigs = getConfigs().getConfigList(config, "fragments");
      if (fragmentConfigs.size() == 0) {
        throw new MorphlineCompilationException("At least one fragment must be defined", config);
      }
      if (fragmentConfigs.size() > 1) {
        throw new MorphlineCompilationException("More than one fragment is not yet supported", config);
      }
      for (Config fragment : fragmentConfigs) {
        String fragmentPath = getConfigs().getString(fragment, "fragmentPath");
        if (!fragmentPath.equals("/")) {
          throw new MorphlineCompilationException("Non-root fragment paths are not yet supported", config);
       
       
        XQueryCompiler compiler = processor.newXQueryCompiler();
        compiler.setErrorListener(new DefaultErrorListener());
        compiler.setCompileWithTracing(isTracing);
        compiler.setLanguageVersion(getConfigs().getString(config, "languageVersion", "1.0"));
       
        XQueryExecutable executable = null;
        String query = getConfigs().getString(fragment, "queryString", null);
        if (query != null) {
          executable = compiler.compile(query);    
        }
        String queryFile = getConfigs().getString(fragment, "queryFile", null);
        if (queryFile != null) {
          executable = compiler.compile(new File(queryFile));
        }
        if (query == null && queryFile == null) {
          throw new MorphlineCompilationException("Either query or queryFile must be defined", config);
        }
        if (query != null && queryFile != null) {
          throw new MorphlineCompilationException("Must not define both query and queryFile at the same time", config);
        }
       
        XQueryEvaluator evaluator = executable.load();
        Config variables = getConfigs().getConfig(fragment, "externalVariables", ConfigFactory.empty());
        for (Map.Entry<String, Object> entry : new Configs().getEntrySet(variables)) {
View Full Code Here

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new ConvertHTML(this, config, parent, child, context);
    } catch (SAXNotRecognizedException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    } catch (SAXNotSupportedException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    }
  }
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 (zkHost != null && zkHost.length() > 0) {
      if (collectionName == null || collectionName.length() == 0) {
        throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config);
      }
      try {
        CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
        cloudSolrServer.setDefaultCollection(collectionName);
        cloudSolrServer.connect();
        return new SolrServerDocumentLoader(cloudSolrServer, batchSize);
      } catch (MalformedURLException e) {
        throw new MorphlineRuntimeException(e);
      }
    } else {
      if (solrUrl == null || solrUrl.length() == 0) {
        throw new MorphlineCompilationException("Missing parameter 'solrUrl'", config);
      }
      int solrServerNumThreads = 2;
      int solrServerQueueLength = solrServerNumThreads;
      SolrServer server = new SafeConcurrentUpdateSolrServer(solrUrl, solrServerQueueLength, solrServerNumThreads);
      // SolrServer server = new HttpSolrServer(solrServerUrl);
View Full Code Here

    // then download schema.xml and solrconfig.xml, etc from zk and use that as solrHomeDir
    String mySolrHomeDir = solrHomeDir;
    if (solrHomeDir == null || solrHomeDir.length() == 0) {
      if (zkHost == null || zkHost.length() == 0) {
        // TODO: implement download from solrUrl if specified
        throw new MorphlineCompilationException(
            "Downloading a Solr schema requires either parameter 'solrHomeDir' or parameters 'zkHost' and 'collection'",
            config);
      }
      if (collectionName == null || collectionName.length() == 0) {
        throw new MorphlineCompilationException(
            "Parameter 'zkHost' requires that you also pass parameter 'collection'", config);
      }
      ZooKeeperDownloader zki = new ZooKeeperDownloader();
      SolrZkClient zkClient = zki.getZkClient(zkHost);
      try {
        String configName = zki.readConfigName(zkClient, collectionName);
        File downloadedSolrHomeDir = zki.downloadConfigDir(zkClient, configName);
        mySolrHomeDir = downloadedSolrHomeDir.getAbsolutePath();
      } catch (KeeperException e) {
        throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
      } catch (InterruptedException e) {
        throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
      } finally {
        zkClient.close();
      }
    }
   
View Full Code Here

    }
  }
 
  private void validateSchema(IndexSchema schema) {
    if (schema.getUniqueKeyField() == null) {
      throw new MorphlineCompilationException("Solr schema.xml is missing unique key field", config);
    }
    if (!schema.getUniqueKeyField().isRequired()) {
      throw new MorphlineCompilationException("Solr schema.xml must contain a required unique key field", config);
    }
  }
View Full Code Here

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new Java(this, config, parent, child, context);
    } catch (ScriptException e) {
      throw new MorphlineCompilationException("Cannot compile script", config, e);
    }
  }
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.