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

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

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

Notifications.notifyCommitTransaction介绍

[英]Notify the given command that a transaction has been committed.
[中]通知给定命令已提交事务。

代码示例

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

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

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

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

代码示例来源:origin: com.cloudera.search/search-mr

  1. public void cleanup() {
  2. Notifications.notifyCommitTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);
  4. }

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

  1. protected void commit() throws Exception {
  2. Notifications.notifyCommitTransaction(morphline);
  3. }

代码示例来源:origin: cloudera/search

  1. public void cleanup() {
  2. Notifications.notifyCommitTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);
  4. }

代码示例来源:origin: cloudera/search

  1. @Override
  2. public void cleanup(Emitter<T> emitter) {
  3. try {
  4. collector.setEmitter(emitter);
  5. Notifications.notifyCommitTransaction(morphline);
  6. Notifications.notifyShutdown(morphline);
  7. } finally {
  8. addMetricsToMRCounters(morphlineContext.getMetricRegistry());
  9. }
  10. }

代码示例来源: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. /** 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. @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. assertEquals(1, collector.getNumStartEvents());
  2. Notifications.notifyCommitTransaction(morphline);
  3. new UpdateRequest().commit(cluster.getSolrClient(), COLLECTION);

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

  1. @Test
  2. public void testTokenizeText() throws Exception {
  3. morphline = createMorphline("test-morphlines" + File.separator + "tokenizeText");
  4. for (int i = 0; i < 3; i++) {
  5. Record record = new Record();
  6. record.put(Fields.MESSAGE, "Hello World!");
  7. record.put(Fields.MESSAGE, "\nFoo@Bar.com #%()123");
  8. Record expected = record.copy();
  9. expected.getFields().putAll("tokens", Arrays.asList("hello", "world", "foo", "bar.com", "123"));
  10. collector.reset();
  11. startSession();
  12. Notifications.notifyBeginTransaction(morphline);
  13. assertTrue(morphline.process(record));
  14. assertEquals(1, collector.getNumStartEvents());
  15. Notifications.notifyCommitTransaction(morphline);
  16. assertEquals(expected, collector.getFirstRecord());
  17. }
  18. }

代码示例来源: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. @Test
  2. public void testLoadSolrWithChildDocuments() throws Exception {
  3. morphline = createMorphline("test-morphlines" + File.separator + "loadSolrWithChildDocuments");
  4. Record record = new Record();
  5. record.put(Fields.ID, "id0");
  6. startSession();
  7. Notifications.notifyBeginTransaction(morphline);
  8. assertTrue(morphline.process(record));
  9. assertEquals(1, collector.getNumStartEvents());
  10. Notifications.notifyCommitTransaction(morphline);
  11. // This parent block join returns the parent records for records
  12. // where the child documents contain "bar" in the id field.
  13. SolrDocumentList docs = query("{!parent which='content_type:parent'}id:bar").getResults();
  14. assertEquals(1, docs.size());
  15. assertEquals("id0", docs.get(0).getFirstValue(Fields.ID));
  16. docs = query("*:*").getResults();
  17. assertEquals(3, docs.size());
  18. }

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

  1. Notifications.notifyCommitTransaction(morphline);
  2. new UpdateRequest().commit(cluster.getSolrClient(), COLLECTION);

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

  1. assertEquals(Arrays.asList("hello sun", "goodbye mars"), docs.get(0).get("text"));
  2. Notifications.notifyCommitTransaction(morphline);
  3. Notifications.notifyShutdown(morphline);

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

  1. expected2.put("user_screen_name", "foo1");
  2. Notifications.notifyCommitTransaction(morphline);
  3. new UpdateRequest().commit(cluster.getSolrClient(), COLLECTION);

相关文章