Skip to content

Extension-friendly HttpSource #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

lucarosellini
Copy link

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

@harishreedharan
Copy link
Contributor

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

@lucarosellini
Copy link
Author

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

@lucarosellini
Copy link
Author

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

@harishreedharan
Copy link
Contributor

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

hejiang2000 added a commit to hejiang2000/flume that referenced this pull request Jun 19, 2018
* initial

* +

* =

* +

* *

* +

* PassiveHttpSink passed unit tests

* 支持 内容头字符,尾字符,事件分隔符。

* format style
@asfgit
Copy link

asfgit commented Aug 17, 2018

Can one of the admins verify this patch?

waidr pushed a commit to waidr/flume that referenced this pull request Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants