logging-flume icon indicating copy to clipboard operation
logging-flume copied to clipboard

Extension-friendly HttpSource

Open lucarosellini opened this issue 10 years ago • 5 comments

This patch allows third-party to developers extend HttpSource behavior easily, without having to reimplement the whole thing.

More specifically:

  • Adds an hook to customize org.mortbay.jetty.servlet.Context.
  • Delegates the HttpServlet instance creation to a protected factory method.
  • Changes FlumeHttpServlet visibility to protected, to let third party developers extend from it.
  • Adds an hook in FlumeHTTPServlet to customize HttpServletResponse before it is flushed.

We developed this patch because we had to add a custom servlet filter to the Jetty context.

Having this patch applied, a third-party developer could easily extend HttpSource like this:

public class CustomHTTPSource extends HTTPSource {

    @Override
    protected void customizeServletContext(Context context) {
        super.customizeServletContext(context);

        context.addFilter(MyCustomHttpServletFilter.class,"/*",0);
    }

    @Override
    protected HttpServlet getServlet() {
        return new KeedioFlumeHTTPServlet();
    }

    protected class KeedioFlumeHTTPServlet extends FlumeHTTPServlet{
        @Override
        protected void customizeServletResponse(HttpServletRequest request, HttpServletResponse response) {
            super.customizeServletResponse(request, response);

            response.addHeader("Accept-Encoding","...");
        }
    }
} 

lucarosellini avatar May 29 '15 07:05 lucarosellini

We don't accept pull requests. Could you please attach the patch to a jira here: https://issues.apache.org/jira/browse/FLUME ? Thanks!

harishreedharan avatar Sep 02 '15 20:09 harishreedharan

@harishreedharan attached the patch to a new jira issue: https://issues.apache.org/jira/browse/FLUME-2782

lucarosellini avatar Sep 03 '15 07:09 lucarosellini

Hi @harishreedharan, did you have the chance to take a look at this?

lucarosellini avatar Nov 05 '15 10:11 lucarosellini

This fell of my radar. Sorry! I will look at this next week.

harishreedharan avatar Nov 05 '15 22:11 harishreedharan

Can one of the admins verify this patch?

asfgit avatar Aug 17 '18 13:08 asfgit