org.kitesdk.morphline.base.Notifications.notifyRollbackTransaction()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.kitesdk.morphline.base.Notifications.notifyRollbackTransaction()方法的一些代码示例,展示了Notifications.notifyRollbackTransaction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notifications.notifyRollbackTransaction()方法的具体详情如下:
包路径:org.kitesdk.morphline.base.Notifications
类名称:Notifications
方法名:notifyRollbackTransaction

Notifications.notifyRollbackTransaction介绍

[英]Notify the given command that a transaction has been rolled back.
[中]通知给定命令事务已回滚。

代码示例

代码示例来源:origin: apache/flume

  1. @Override
  2. public void rollbackTransaction() {
  3. Notifications.notifyRollbackTransaction(morphline);
  4. }

代码示例来源:origin: org.apache.flume.flume-ng-sinks/flume-ng-morphline-solr-sink

  1. @Override
  2. public void rollbackTransaction() {
  3. Notifications.notifyRollbackTransaction(morphline);
  4. }

代码示例来源:origin: cloudera-labs/envelope

  1. public static List<Record> executePipeline(Pipeline pipeline, Record inputRecord, boolean errorOnEmpty) {
  2. Command morphline = pipeline.getMorphline();
  3. try {
  4. LOG.trace("Input Record: {}", inputRecord);
  5. // Process the Record
  6. Notifications.notifyStartSession(morphline);
  7. boolean success = morphline.process(inputRecord);
  8. Notifications.notifyCommitTransaction(morphline);
  9. if (!success) {
  10. throw new MorphlineRuntimeException("Morphline failed to process incoming Record: " + inputRecord);
  11. }
  12. // Collect the output
  13. List<Record> outputRecords = pipeline.getCollector().getRecords();
  14. if (errorOnEmpty && !outputRecords.iterator().hasNext()) {
  15. throw new MorphlineRuntimeException("Morphline did not produce output Record(s)");
  16. }
  17. LOG.trace("Output Record(s): {}", outputRecords);
  18. return outputRecords;
  19. } catch (RuntimeException e) {
  20. Notifications.notifyRollbackTransaction(morphline);
  21. // TODO : Review exception handling
  22. LOG.warn("Morphline failed to execute properly on incoming Record: " + inputRecord, e);
  23. throw e;
  24. }
  25. }

代码示例来源:origin: kite-sdk/kite

  1. @Test
  2. public void testNotifications() throws Exception {
  3. morphline = createMorphline("test-morphlines/pipeWithTwoBasicCommands");
  4. Notifications.notifyBeginTransaction(morphline);
  5. Notifications.notifyStartSession(morphline);
  6. Notifications.notifyCommitTransaction(morphline);
  7. Notifications.notifyRollbackTransaction(morphline);
  8. }

代码示例来源:origin: kite-sdk/kite

  1. /** Usage: java ... <morphline.conf> <dataFile1> ... <dataFileN> */
  2. public static void main(String[] args) throws IOException {
  3. // compile morphline.conf file on the fly
  4. File morphlineFile = new File(args[0]);
  5. String morphlineId = null;
  6. MorphlineContext morphlineContext = new MorphlineContext.Builder().build();
  7. Command morphline = new Compiler().compile(morphlineFile, morphlineId, morphlineContext, null);
  8. // process each input data file
  9. Notifications.notifyBeginTransaction(morphline);
  10. try {
  11. for (int i = 1; i < args.length; i++) {
  12. InputStream in = new BufferedInputStream(new FileInputStream(new File(args[i])));
  13. Record record = new Record();
  14. record.put(Fields.ATTACHMENT_BODY, in);
  15. Notifications.notifyStartSession(morphline);
  16. boolean success = morphline.process(record);
  17. if (!success) {
  18. System.out.println("Morphline failed to process record: " + record);
  19. }
  20. in.close();
  21. }
  22. Notifications.notifyCommitTransaction(morphline);
  23. } catch (RuntimeException e) {
  24. Notifications.notifyRollbackTransaction(morphline);
  25. morphlineContext.getExceptionHandler().handleException(e, null);
  26. }
  27. Notifications.notifyShutdown(morphline);
  28. }
  29. }

代码示例来源:origin: kite-sdk/kite

  1. Notifications.notifyRollbackTransaction(morphline);
  2. Notifications.notifyShutdown(morphline);

代码示例来源:origin: kite-sdk/kite

  1. @Test
  2. public void testLoadSolrBasic() throws Exception {
  3. //System.setProperty("ENV_SOLR_HOME", testSolrHome + File.separator + "collection1");
  4. morphline = createMorphline("test-morphlines" + File.separator + "loadSolrBasic");
  5. //System.clearProperty("ENV_SOLR_HOME");
  6. Record record = new Record();
  7. record.put(Fields.ID, "id0");
  8. record.put("first_name", "Nadja"); // will be sanitized
  9. startSession();
  10. Notifications.notifyBeginTransaction(morphline);
  11. assertTrue(morphline.process(record));
  12. assertEquals(1, collector.getNumStartEvents());
  13. Notifications.notifyCommitTransaction(morphline);
  14. Record expected = new Record();
  15. expected.put(Fields.ID, "id0");
  16. assertEquals(Arrays.asList(expected), collector.getRecords());
  17. assertEquals(1, queryResultSetSize("*:*"));
  18. Notifications.notifyRollbackTransaction(morphline);
  19. Notifications.notifyShutdown(morphline);
  20. }

代码示例来源:origin: kite-sdk/kite

  1. assertFalse(iter.hasNext());
  2. Notifications.notifyRollbackTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);

代码示例来源:origin: kite-sdk/kite

  1. assertFalse(iter.hasNext());
  2. Notifications.notifyRollbackTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);

代码示例来源:origin: kite-sdk/kite

  1. assertNull(docs.get(1).getFirstValue(LoadSolrBuilder.LOAD_SOLR_DELETE_BY_QUERY));
  2. Notifications.notifyRollbackTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);

相关文章