Review Board 1.7.22


[FLUME-1904] Add 'message' parser in ElasticSearchLogStashEventSerializer.java

Review Request #9441 - Created Feb. 14, 2013 and updated

Daisuke Kobayashi
FLUME-1904
Reviewers
Flume
flume-git
In 'appendBody', before adding "@message" field, it should check the headers if there is "message" headers.

 
flume-ng-sinks/flume-ng-elasticsearch-sink/src/main/java/org/apache/flume/sink/elasticsearch/ElasticSearchLogStashEventSerializer.java
Revision 3638368 New Change
[20] 80 lines
[+20] [+] public XContentBuilder getContentBuilder(Event event) throws IOException {
81
    return builder;
81
    return builder;
82
  }
82
  }
83

    
   
83

   
84
  private void appendBody(XContentBuilder builder, Event event)
84
  private void appendBody(XContentBuilder builder, Event event)
85
      throws IOException, UnsupportedEncodingException {
85
      throws IOException, UnsupportedEncodingException {

    
   
86
	Map<String, String> headers = Maps.newHashMap(event.getHeaders());
86
    byte[] body = event.getBody();
87
    byte[] body = event.getBody();

    
   
88
    String message = headers.get("message");

    
   
89
    if(!!StringUtils.isBlank(message)

    
   
90
			&& StringUtils.isBlank(headers.get("@message"))){
87
    ContentBuilderUtil.appendField(builder, "@message", body);
91
		ContentBuilderUtil.appendField(builder, "@message", body);
88
  }
92
    }

    
   
93
  }
89

    
   
94

   
90
  private void appendHeaders(XContentBuilder builder, Event event)
95
  private void appendHeaders(XContentBuilder builder, Event event)
91
      throws IOException {
96
      throws IOException {
92
    Map<String, String> headers = Maps.newHashMap(event.getHeaders());
97
    Map<String, String> headers = Maps.newHashMap(event.getHeaders());
93

    
   
98

   
[+20] [20] 52 lines
flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java
Revision 9dff4b0 New Change
 
  1. flume-ng-sinks/flume-ng-elasticsearch-sink/src/main/java/org/apache/flume/sink/elasticsearch/ElasticSearchLogStashEventSerializer.java: Loading...
  2. flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java: Loading...