You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flume.apache.org by mp...@apache.org on 2013/06/23 22:36:57 UTC
git commit: FLUME-2076. JMX metrics support for HTTP Source.
Updated Branches:
refs/heads/trunk 2f90fd8b0 -> c059c916e
FLUME-2076. JMX metrics support for HTTP Source.
(Sravya Tirukkovalur via Mike Percy)
Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/c059c916
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/c059c916
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/c059c916
Branch: refs/heads/trunk
Commit: c059c916e32e53215dbbe55f7163c5ce833a8909
Parents: 2f90fd8
Author: Mike Percy <mp...@apache.org>
Authored: Sun Jun 23 13:35:05 2013 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Sun Jun 23 13:35:05 2013 -0700
----------------------------------------------------------------------
.../java/org/apache/flume/source/http/HTTPSource.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flume/blob/c059c916/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java
index a4c3eb3..c90f067 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java
@@ -24,6 +24,7 @@ import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.EventDrivenSource;
import org.apache.flume.conf.Configurable;
+import org.apache.flume.instrumentation.SourceCounter;
import org.apache.flume.source.AbstractSource;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
@@ -52,7 +53,7 @@ import java.util.Map;
* the server should bind. Mandatory <p> <tt>handler</tt>: the class that
* deserializes a HttpServletRequest into a list of flume events. This class
* must implement HTTPSourceHandler. Default:
- * {@linkplain JSONDeserializer}. <p> <tt>handler.*</tt> Any configuration
+ * {@linkplain JSONHandler}. <p> <tt>handler.*</tt> Any configuration
* to be passed to the handler. <p>
*
* All events deserialized from one Http request are committed to the channel in
@@ -85,6 +86,7 @@ public class HTTPSource extends AbstractSource implements
private volatile Server srv;
private volatile String host;
private HTTPSourceHandler handler;
+ private SourceCounter sourceCounter;
@Override
public void configure(Context context) {
@@ -118,6 +120,9 @@ public class HTTPSource extends AbstractSource implements
LOG.error("Error configuring HTTPSource!", ex);
Throwables.propagate(ex);
}
+ if (sourceCounter == null) {
+ sourceCounter = new SourceCounter(getName());
+ }
}
private void checkHostAndPort() {
@@ -150,6 +155,7 @@ public class HTTPSource extends AbstractSource implements
Throwables.propagate(ex);
}
Preconditions.checkArgument(srv.isRunning());
+ sourceCounter.start();
super.start();
}
@@ -162,6 +168,8 @@ public class HTTPSource extends AbstractSource implements
} catch (Exception ex) {
LOG.error("Error while stopping HTTPSource. Exception follows.", ex);
}
+ sourceCounter.stop();
+ LOG.info("Http source {} stopped. Metrics: {}", getName(), sourceCounter);
}
private class FlumeHTTPServlet extends HttpServlet {
@@ -187,6 +195,8 @@ public class HTTPSource extends AbstractSource implements
+ ex.getMessage());
return;
}
+ sourceCounter.incrementAppendBatchReceivedCount();
+ sourceCounter.addToEventReceivedCount(events.size());
try {
getChannelProcessor().processEventBatch(events);
} catch (ChannelException ex) {
@@ -207,6 +217,8 @@ public class HTTPSource extends AbstractSource implements
response.setCharacterEncoding(request.getCharacterEncoding());
response.setStatus(HttpServletResponse.SC_OK);
response.flushBuffer();
+ sourceCounter.incrementAppendBatchAcceptedCount();
+ sourceCounter.addToEventAcceptedCount(events.size());
}
@Override