flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject git commit: FLUME-1556: It would be nice if NullSink logged the number of event processed every 10K or so
Date Mon, 10 Sep 2012 22:46:32 GMT
Updated Branches:
  refs/heads/flume-1.3.0 c9d0760f3 -> cf8399c89


FLUME-1556: It would be nice if NullSink logged the number of event processed every 10K or
so

(Ted Malaska via Brock Noland)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/cf8399c8
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/cf8399c8
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/cf8399c8

Branch: refs/heads/flume-1.3.0
Commit: cf8399c898c9a16770f2f7ea15af5a08ccf9db9b
Parents: c9d0760
Author: Brock Noland <brock@apache.org>
Authored: Mon Sep 10 17:45:28 2012 -0500
Committer: Brock Noland <brock@apache.org>
Committed: Mon Sep 10 17:45:43 2012 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/flume/sink/NullSink.java  |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/cf8399c8/flume-ng-core/src/main/java/org/apache/flume/sink/NullSink.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/sink/NullSink.java b/flume-ng-core/src/main/java/org/apache/flume/sink/NullSink.java
index 5cc1521..cada6ec 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/sink/NullSink.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/sink/NullSink.java
@@ -52,9 +52,11 @@ public class NullSink extends AbstractSink implements Configurable {
   private static final Logger logger = LoggerFactory.getLogger(NullSink.class);
 
   private static final int DFLT_BATCH_SIZE = 100;
+  private static final int DFLT_LOG_EVERY_N_EVENTS = 10000;
 
   private CounterGroup counterGroup;
   private int batchSize = DFLT_BATCH_SIZE;
+  private int logEveryNEvents = DFLT_LOG_EVERY_N_EVENTS;
 
   public NullSink() {
     counterGroup = new CounterGroup();
@@ -66,6 +68,11 @@ public class NullSink extends AbstractSink implements Configurable {
     logger.debug(this.getName() + " " +
         "batch size set to " + String.valueOf(batchSize));
     Preconditions.checkArgument(batchSize > 0, "Batch size must be > 0");
+
+    logEveryNEvents = context.getInteger("logEveryNEvents", DFLT_LOG_EVERY_N_EVENTS);
+    logger.debug(this.getName() + " " +
+        "log event N events set to " + logEveryNEvents);
+    Preconditions.checkArgument(logEveryNEvents > 0, "logEveryNEvents must be > 0");
   }
 
   @Override
@@ -75,12 +82,16 @@ public class NullSink extends AbstractSink implements Configurable {
     Channel channel = getChannel();
     Transaction transaction = channel.getTransaction();
     Event event = null;
+    long eventCounter = counterGroup.get("events.success");
 
     try {
       transaction.begin();
       int i = 0;
       for (i = 0; i < batchSize; i++) {
         event = channel.take();
+        if (++eventCounter % logEveryNEvents == 0) {
+          logger.info("Null sink {} successful processed {} events.", getName(), eventCounter);
+        }
         if(event == null) {
           status = Status.BACKOFF;
           break;


Mime
View raw message