Review Board 1.7.22


Moving BlobHandler out of morphline sink and into HTTP source

Review Request #15107 - Created Oct. 31, 2013 and updated

Roshan Naik
flume-1.5
FLUME-2226
Reviewers
Flume
flume-git
- Moved BlobHandler out of morphline sink and into HTTP source along with tests. 
- Updated docs to reflect new FQCN
- Retained dummy class for old FQCN compat
Ran unit tests & some manual Test.
flume-ng-core/src/main/java/org/apache/flume/source/http/BlobHandler.java
Diff Revision 1 Diff Revision 2
This file contains only whitespace changes.
[20] 65 lines
[+20] [+] public void configure(Context context) {
66
    if (this.maxBlobLength <= 0) {
66
    if (this.maxBlobLength <= 0) {
67
      throw new ConfigurationException("Configuration parameter " + MAX_BLOB_LENGTH_KEY
67
      throw new ConfigurationException("Configuration parameter " + MAX_BLOB_LENGTH_KEY
68
          + " must be greater than zero: " + maxBlobLength);
68
          + " must be greater than zero: " + maxBlobLength);
69
    }
69
    }
70
  }
70
  }
71
  
71

   
72
  @SuppressWarnings("resource")
72
  @SuppressWarnings("resource")
73
  @Override
73
  @Override
74
  public List<Event> getEvents(HttpServletRequest request) throws Exception {
74
  public List<Event> getEvents(HttpServletRequest request) throws Exception {
75
    Map<String, String> headers = getHeaders(request);    
75
    Map<String, String> headers = getHeaders(request);
76
    InputStream in = request.getInputStream();
76
    InputStream in = request.getInputStream();
77
    try {
77
    try {
78
      ByteArrayOutputStream blob = null;
78
      ByteArrayOutputStream blob = null;
79
      byte[] buf = new byte[Math.min(maxBlobLength, DEFAULT_BUFFER_SIZE)];
79
      byte[] buf = new byte[Math.min(maxBlobLength, DEFAULT_BUFFER_SIZE)];
80
      int blobLength = 0;
80
      int blobLength = 0;
[+20] [20] 23 lines
[+20] public void configure(Context context) {
104
    if (LOGGER.isDebugEnabled()) {
104
    if (LOGGER.isDebugEnabled()) {
105
      Map requestHeaders = new HashMap();
105
      Map requestHeaders = new HashMap();
106
      Enumeration iter = request.getHeaderNames();
106
      Enumeration iter = request.getHeaderNames();
107
      while (iter.hasMoreElements()) {
107
      while (iter.hasMoreElements()) {
108
        String name = (String) iter.nextElement();
108
        String name = (String) iter.nextElement();
109
        requestHeaders.put(name, request.getHeader(name));        
109
        requestHeaders.put(name, request.getHeader(name));
110
      }
110
      }
111
      LOGGER.debug("requestHeaders: {}", requestHeaders);
111
      LOGGER.debug("requestHeaders: {}", requestHeaders);
112
    }    
112
    }
113
    Map<String, String> headers = new HashMap();
113
    Map<String, String> headers = new HashMap();
114
    if (request.getContentType() != null) {
114
    if (request.getContentType() != null) {
115
      headers.put(HTTP_CONTENT_TYPE, request.getContentType());
115
      headers.put(HTTP_CONTENT_TYPE, request.getContentType());
116
    }
116
    }
117
    Enumeration iter = request.getParameterNames();
117
    Enumeration iter = request.getParameterNames();
118
    while (iter.hasMoreElements()) {
118
    while (iter.hasMoreElements()) {
119
      String name = (String) iter.nextElement();
119
      String name = (String) iter.nextElement();
120
      headers.put(name, request.getParameter(name));        
120
      headers.put(name, request.getParameter(name));
121
    }
121
    }
122
    return headers;
122
    return headers;
123
  }
123
  }
124

    
   
124

   
125
}
125
}
flume-ng-core/src/test/java/org/apache/flume/source/http/FlumeHttpServletByteRequestWrapper.java
Diff Revision 1 Diff Revision 2
 
flume-ng-doc/sphinx/FlumeUserGuide.rst
Diff Revision 1 Diff Revision 2
 
flume-ng-sinks/flume-ng-morphline-solr-sink/src/main/java/org/apache/flume/sink/solr/morphline/BlobHandler.java
Diff Revision 1 Diff Revision 2
 
  1. flume-ng-core/src/main/java/org/apache/flume/source/http/BlobHandler.java: Loading...
  2. flume-ng-core/src/test/java/org/apache/flume/source/http/FlumeHttpServletByteRequestWrapper.java: Loading...
  3. flume-ng-doc/sphinx/FlumeUserGuide.rst: Loading...
  4. flume-ng-sinks/flume-ng-morphline-solr-sink/src/main/java/org/apache/flume/sink/solr/morphline/BlobHandler.java: Loading...