Uploaded image for project: 'Flume'
  1. Flume
  2. FLUME-2782

Extension-friendly HttpSource

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6.0, 1.5.2
    • None
    • Sinks+Sources

    Description

      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:

      CustomHTTPSource.java
      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","...");
              }
          }
      } 
      

      Attachments

        1. extensible-flume-HttpSource_v2.diff
          18 kB
          Luca Rosellini
        2. extensible-flume-HttpSource.patch
          4 kB
          Luca Rosellini

        Activity

          People

            Unassigned Unassigned
            lrosellini@keedio.com Luca Rosellini
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: