• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MorphlineCompilationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.kitesdk.morphline.api.MorphlineCompilationException的典型用法代码示例。如果您正苦于以下问题:Java MorphlineCompilationException类的具体用法?Java MorphlineCompilationException怎么用?Java MorphlineCompilationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MorphlineCompilationException类属于org.kitesdk.morphline.api包,在下文中一共展示了MorphlineCompilationException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configure

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Override
public void configure(Config config) {
  LOG.trace("Configuring Morphline Deriver");

  // Designate which dependency step to act upon
  if (!config.hasPath(STEP_NAME_CONFIG) || config.getString(STEP_NAME_CONFIG).trim().isEmpty()) {
    throw new RuntimeException("Missing parameter, " + STEP_NAME_CONFIG);
  } else {
    this.stepName = config.getString(STEP_NAME_CONFIG);
  }

  // Set up the Morphline configuration, the file must be located on the local file system
  this.morphlineFile = config.getString(MORPHLINE);
  this.morphlineId = config.getString(MORPHLINE_ID);

  if (this.morphlineFile == null || this.morphlineFile.trim().length() == 0) {
    throw new MorphlineCompilationException("Missing or empty Morphline File configuration parameter", null);
  }

  // Construct the StructType schema for the Rows
  List<String> fieldNames = config.getStringList(FIELD_NAMES);
  List<String> fieldTypes = config.getStringList(FIELD_TYPES);
  this.schema = RowUtils.structTypeFor(fieldNames, fieldTypes);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:25,代码来源:MorphlineDeriver.java


示例2: morphlineCompilationError

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = MorphlineCompilationException.class)
public void morphlineCompilationError(
    final @Mocked Compiler compiler
    ) throws Exception {

  new Expectations() {{
    config.getString(MorphlineTranslator.MORPHLINE); result = getResourcePath(MORPHLINE_FILE);
    config.getStringList(MorphlineTranslator.FIELD_NAMES); result = Lists.newArrayList("bar");
    config.getStringList(MorphlineTranslator.FIELD_TYPES); result = Lists.newArrayList("int");

    compiler.compile((File) any, anyString, (MorphlineContext) any, (Command) any); result = new Exception("Compilation exception");
  }};

  stringMorphline.configure(config);
  stringMorphline.translate("The Key", "The Message");
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:17,代码来源:TestMorphlineTranslator.java


示例3: TokenizeText

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
public TokenizeText(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
  super(builder, config, parent, child, context);
  this.inputFieldName = getConfigs().getString(config, "inputField");
  this.outputFieldName = getConfigs().getString(config, "outputField");      
  String solrFieldType = getConfigs().getString(config, "solrFieldType");      
  Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator");
  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.getIndexAnalyzer();
  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();
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TokenizeTextBuilder.java


示例4: TokenizeText

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
public TokenizeText(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
  super(builder, config, parent, child, context);
  this.inputFieldName = getConfigs().getString(config, "inputField");
  this.outputFieldName = getConfigs().getString(config, "outputField");      
  String solrFieldType = getConfigs().getString(config, "solrFieldType");      
  Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator");
  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();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:TokenizeTextBuilder.java


示例5: configure

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Override
public void configure(Context context) {
  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);
  }
  morphlineFileAndId = morphlineFile + "@" + morphlineId;
  
  if (morphlineContext == null) {
    FaultTolerance faultTolerance = new FaultTolerance(
        context.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), 
        context.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
        context.getString(FaultTolerance.RECOVERABLE_EXCEPTION_CLASSES));
    
    morphlineContext = new MorphlineContext.Builder()
      .setExceptionHandler(faultTolerance)
      .setMetricRegistry(SharedMetricRegistries.getOrCreate(morphlineFileAndId))
      .build();
  }
  
  Config override = ConfigFactory.parseMap(
      context.getSubProperties(MORPHLINE_VARIABLE_PARAM + "."));
  morphline = new Compiler().compile(
      new File(morphlineFile), morphlineId, morphlineContext, finalChild, override);
  
  this.mappingTimer = morphlineContext.getMetricRegistry().timer(
      MetricRegistry.name("morphline.app", Metrics.ELAPSED_TIME));
  this.numRecords = morphlineContext.getMetricRegistry().meter(
      MetricRegistry.name("morphline.app", Metrics.NUM_RECORDS));
  this.numFailedRecords = morphlineContext.getMetricRegistry().meter(
      MetricRegistry.name("morphline.app", "numFailedRecords"));
  this.numExceptionRecords = morphlineContext.getMetricRegistry().meter(
      MetricRegistry.name("morphline.app", "numExceptionRecords"));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:36,代码来源:MorphlineHandlerImpl.java


示例6: setPipeline

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
/**
 *
 * @param morphlineFile
 * @param morphlineId
 * @param collector
 * @param isProduction
 * @return
 */
public static Pipeline setPipeline(String morphlineFile, String morphlineId, Collector collector, boolean isProduction) {
  LOG.debug("Constructing Pipeline[{}#{}]", morphlineFile, morphlineId);

  // Set up the Morphline context and handler
  MorphlineContext context = new MorphlineContext.Builder()
      .setExceptionHandler(new FaultTolerance(isProduction, false))
      .build();

  // Compile the Morphline process
  Command morphline;
  try {
    morphline = new Compiler().compile(
        new File(morphlineFile),
        morphlineId,
        context,
        collector);
  } catch (Exception e) {
    throw new MorphlineCompilationException("Morphline compilation error", null, e);
  }

  // Create the pipeline wrapper
  Pipeline pipeline = new Pipeline(morphline, collector);

  // Ensure shutdown notification to Morphline commands esp in streaming environments
  JVMUtils.closeAtShutdown(pipeline);

  // Prep the pipeline
  Notifications.notifyBeginTransaction(pipeline.getMorphline());

  // Register the pipeline into the cache
  if (null == pipelineCache.get()) {
    pipelineCache.set(new HashMap<String, Pipeline>());
  }
  pipelineCache.get().put(morphlineFile + SEPARATOR + morphlineId, pipeline);

  LOG.trace("Pipeline[{}#{}] prepared", morphlineFile, morphlineId);
  return pipeline;
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:47,代码来源:MorphlineUtils.java


示例7: configure

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Override
public void configure(Config config) {
  LOG.trace("Configuring Morphline Translator");

  // Define the encoding values, if necessary
  this.keyEncoding = config.getString(ENCODING_KEY);
  this.messageEncoding = config.getString(ENCODING_MSG);

  // Set up the Morphline configuration, the file must be located on the local file system
  this.morphlineFile = config.getString(MORPHLINE);
  this.morphlineId = config.getString(MORPHLINE_ID);

  if (this.morphlineFile == null || this.morphlineFile.trim().length() == 0) {
    throw new MorphlineCompilationException("Missing or empty Morphline File configuration parameter", null);
  }

  // Construct the StructType schema for the Rows
  List<String> fieldNames = config.getStringList(FIELD_NAMES);
  List<String> fieldTypes = config.getStringList(FIELD_TYPES);
  this.doesAppendRaw = TranslatorUtils.doesAppendRaw(config);
  if (this.doesAppendRaw) {
    fieldNames.add(TranslatorUtils.getAppendRawKeyFieldName(config));
    fieldTypes.add("binary");
    fieldNames.add(TranslatorUtils.getAppendRawValueFieldName(config));
    fieldTypes.add("binary");
  }
  this.schema = RowUtils.structTypeFor(fieldNames, fieldTypes);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:29,代码来源:MorphlineTranslator.java


示例8: deriveMorphlineMapperFunctionError

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = RuntimeException.class)
public void deriveMorphlineMapperFunctionError(
    final @Mocked MorphlineUtils utils
) throws Exception {

  Map<String, Object> paramMap = new HashMap<>();
  paramMap.put(MorphlineDeriver.STEP_NAME_CONFIG, "dep1");
  paramMap.put(MorphlineDeriver.MORPHLINE, "morphline");
  paramMap.put(MorphlineDeriver.MORPHLINE_ID, "id");
  paramMap.put(MorphlineDeriver.FIELD_NAMES, Lists.newArrayList("bar"));
  paramMap.put(MorphlineDeriver.FIELD_TYPES, Lists.newArrayList("int"));
  final Config config = ConfigFactory.parseMap(paramMap);

  new Expectations() {{
    MorphlineUtils.morphlineMapper(anyString, anyString, (StructType) any); result =
        new MorphlineCompilationException("Compile exception", config);
  }};

  Dataset<Row> dataFrame = Contexts.getSparkSession().createDataFrame(
      Lists.newArrayList(RowFactory.create(1)),
      DataTypes.createStructType(Lists.newArrayList(DataTypes.createStructField("baz", DataTypes.IntegerType, false)))
  );

  Map<String, Dataset<Row>> dependencies = Maps.newHashMap();
  dependencies.put("dep1", dataFrame);

  Deriver deriver = new MorphlineDeriver();
  deriver.configure(config);

  deriver.derive(dependencies);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:32,代码来源:TestMorphlineDeriver.java


示例9: emptyMorphlineFile

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = MorphlineCompilationException.class)
public void emptyMorphlineFile() throws Exception {

  new Expectations() {{
    config.getString(MorphlineTranslator.MORPHLINE); result = "";
  }};

  stringMorphline.configure(config);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:10,代码来源:TestMorphlineTranslator.java


示例10: invalidCommand

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = MorphlineCompilationException.class)
public void invalidCommand() throws Exception {
  new Expectations() {{
    config.getString(MorphlineTranslator.ENCODING_KEY); result = "UTF-8";
    config.getString(MorphlineTranslator.ENCODING_MSG); result = "UTF-8";
    config.getString(MorphlineTranslator.MORPHLINE); result = getResourcePath(MORPHLINE_FILE);
    config.getString(MorphlineTranslator.MORPHLINE_ID); result = "invalid-command";
    config.getStringList(MorphlineTranslator.FIELD_NAMES); result = Lists.newArrayList("int", "str", "float");
    config.getStringList(MorphlineTranslator.FIELD_TYPES); result = Lists.newArrayList("int", "string", "float");
  }};

  stringMorphline.configure(config);
  stringMorphline.translate("The Key", "The Message");
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:15,代码来源:TestMorphlineTranslator.java


示例11: getSolrContentHandlerFactory

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
private static SolrContentHandlerFactory getSolrContentHandlerFactory(
    Class<? extends SolrContentHandlerFactory> factoryClass, Collection<String> dateFormats, Config config) {
  try {
    return factoryClass.getConstructor(Collection.class).newInstance(dateFormats);
  } catch (NoSuchMethodException nsme) {
    throw new MorphlineCompilationException("Unable to find valid constructor of type "
      + factoryClass.getName() + " for creating SolrContentHandler", config, nsme);
  } catch (Exception e) {
    throw new MorphlineCompilationException("Unexpected exception when trying to create SolrContentHandlerFactory of type "
      + factoryClass.getName(), config, e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SolrCellBuilder.java


示例12: getLoader

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
public DocumentLoader getLoader() {
  if (context instanceof SolrMorphlineContext) {
    DocumentLoader loader = ((SolrMorphlineContext)context).getDocumentLoader();
    if (loader != null) {
      return loader;
    }
  }
  
  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);
    }
    CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
    cloudSolrServer.setDefaultCollection(collectionName);
    cloudSolrServer.connect();
    return new SolrServerDocumentLoader(cloudSolrServer, batchSize);
  } 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);
    // SolrServer server = new ConcurrentUpdateSolrServer(solrServerUrl, solrServerQueueLength, solrServerNumThreads);
    // server.setParser(new XMLResponseParser()); // binary parser is used by default
    return new SolrServerDocumentLoader(server, batchSize);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SolrLocator.java


示例13: validateSchema

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
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);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SolrLocator.java


示例14: setPipelineFileNotFound

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = MorphlineCompilationException.class)
public void setPipelineFileNotFound() throws Exception {
  MorphlineUtils.setPipeline("file", "id", new MorphlineUtils.Collector(), true);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:5,代码来源:TestMorphlineUtils.java


示例15: missingMorphlineFile

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
@Test (expected = MorphlineCompilationException.class)
public void missingMorphlineFile() throws Exception {
  stringMorphline.configure(config);
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:5,代码来源:TestMorphlineTranslator.java


示例16: Mapping

import org.kitesdk.morphline.api.MorphlineCompilationException; //导入依赖的package包/类
public Mapping(Config config, MorphlineContext context) {
    Configs configs = new Configs();
    this.inputColumn = resolveColumnName(configs.getString(config, "inputColumn"));
    this.columnFamily = Bytes.toBytes(splitFamilyAndQualifier(inputColumn)[0]);
    
    String qualifierString = splitFamilyAndQualifier(inputColumn)[1];
    this.isWildCard = qualifierString.endsWith("*");
    if (isWildCard) {
        qualifierString = qualifierString.substring(0, qualifierString.length() - 1);
    }
    this.qualifier = Bytes.toBytes(qualifierString);
    
    String outputField = configs.getString(config, "outputField", null);
    this.outputFieldNames = configs.getStringList(config, "outputFields", null);
    if (outputField == null && outputFieldNames == null) {
      throw new MorphlineCompilationException("Either outputField or outputFields must be defined", config);
    }
    if (outputField != null && outputFieldNames != null) {
      throw new MorphlineCompilationException("Must not define both outputField and outputFields at the same time", config);
    }
    if (outputField == null) {
      this.isDynamicOutputFieldName = false;
      this.outputFieldName = null;
    } else {
      this.isDynamicOutputFieldName = outputField.endsWith("*");
      if (isDynamicOutputFieldName) {
          this.outputFieldName = outputField.substring(0, outputField.length() - 1);
      } else {
          this.outputFieldName = outputField;
      }
    }
    
    this.type = configs.getString(config, "type", "byte[]");
    if (type.equals("byte[]")) { // pass through byte[] to downstream morphline commands without conversion
        this.byteArrayMapper = new ByteArrayValueMapper() {
            @Override
            public Collection map(byte[] input) {
                return Collections.singletonList(input);
            }
        };
    } else {
        this.byteArrayMapper = ByteArrayValueMappers.getMapper(type);
    }

    LowerCaseValueSource source = new Validator<LowerCaseValueSource>().validateEnum(config,
            configs.getString(config, "source", LowerCaseValueSource.value.toString()),
            LowerCaseValueSource.class);

    if (source == LowerCaseValueSource.value) {
        if (isWildCard) {
            this.extractor = new PrefixMatchingCellExtractor(columnFamily, qualifier);
        } else {
            this.extractor = new SingleCellExtractor(columnFamily, qualifier);
        }
    } else {
        if (isWildCard) {
            this.extractor = new PrefixMatchingQualifierExtractor(columnFamily, qualifier);
        } else {
            throw new IllegalArgumentException("Can't create a non-prefix-based qualifier extractor");
        }
    }
    
    configs.validateArguments(config);
    if (context instanceof HBaseMorphlineContext) {
        ((HBaseMorphlineContext)context).getExtractors().add(this.extractor);
    }
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:68,代码来源:ExtractHBaseCellsBuilder.java



注:本文中的org.kitesdk.morphline.api.MorphlineCompilationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Restrict类代码示例发布时间:2022-05-22
下一篇:
Java Element类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap