Review Board 1.7.22


FLUME-2042. log4jappender timeout should be configurable

Review Request #11066 - Created May 11, 2013 and submitted

Hari Shreedharan
FLUME-2042
Reviewers
Flume
flume-git
Added timeout configuration to both log4j appender and load balancing log4j appender
Added new unit tests. Ran full build, all tests pass.
flume-ng-clients/flume-ng-log4jappender/src/main/java/org/apache/flume/clients/log4jappender/LoadBalancingLog4jAppender.java
Revision 3172e21 New Change
[20] 118 lines
[+20] [+] public synchronized void append(LoggingEvent event) {
119
   *           if the LoadBalancingRpcClient cannot be instantiated.
119
   *           if the LoadBalancingRpcClient cannot be instantiated.
120
   */
120
   */
121
  @Override
121
  @Override
122
  public void activateOptions() throws FlumeException {
122
  public void activateOptions() throws FlumeException {
123
    try {
123
    try {
124
      final Properties properties = getProperties(hosts, selector, maxBackoff);
124
      final Properties properties = getProperties(hosts, selector,

    
   
125
        maxBackoff, getTimeout());
125
      rpcClient = RpcClientFactory.getInstance(properties);
126
      rpcClient = RpcClientFactory.getInstance(properties);
126
      if(layout != null) {
127
      if(layout != null) {
127
        layout.activateOptions();
128
        layout.activateOptions();
128
      }
129
      }
129
      configured = true;
130
      configured = true;
[+20] [20] 7 lines
[+20] public void activateOptions() throws FlumeException {
137
    }
138
    }
138

    
   
139

   
139
  }
140
  }
140

    
   
141

   
141
  private Properties getProperties(String hosts, String selector,
142
  private Properties getProperties(String hosts, String selector,
142
      String maxBackoff) throws FlumeException {
143
      String maxBackoff, long timeout) throws FlumeException {
143

    
   
144

   
144
    if (StringUtils.isEmpty(hosts)) {
145
    if (StringUtils.isEmpty(hosts)) {
145
      throw new FlumeException("hosts must not be null");
146
      throw new FlumeException("hosts must not be null");
146
    }
147
    }
147

    
   
148

   
[+20] [20] 22 lines
[+20] public void activateOptions() throws FlumeException {
170
      }
171
      }
171
      props.put(RpcClientConfigurationConstants.CONFIG_BACKOFF,
172
      props.put(RpcClientConfigurationConstants.CONFIG_BACKOFF,
172
          String.valueOf(true));
173
          String.valueOf(true));
173
      props.put(RpcClientConfigurationConstants.CONFIG_MAX_BACKOFF, maxBackoff);
174
      props.put(RpcClientConfigurationConstants.CONFIG_MAX_BACKOFF, maxBackoff);
174
    }
175
    }

    
   
176
    props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECT_TIMEOUT,

    
   
177
      String.valueOf(timeout));

    
   
178
    props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT,

    
   
179
      String.valueOf(timeout));
175
    return props;
180
    return props;
176
  }
181
  }
177
}
182
}
flume-ng-clients/flume-ng-log4jappender/src/main/java/org/apache/flume/clients/log4jappender/Log4jAppender.java
Revision 0ba56d3 New Change
 
flume-ng-clients/flume-ng-log4jappender/src/test/java/org/apache/flume/clients/log4jappender/TestLoadBalancingLog4jAppender.java
Revision 103bcb6 New Change
 
flume-ng-clients/flume-ng-log4jappender/src/test/java/org/apache/flume/clients/log4jappender/TestLog4jAppender.java
Revision 211837b New Change
 
  1. flume-ng-clients/flume-ng-log4jappender/src/main/java/org/apache/flume/clients/log4jappender/LoadBalancingLog4jAppender.java: Loading...
  2. flume-ng-clients/flume-ng-log4jappender/src/main/java/org/apache/flume/clients/log4jappender/Log4jAppender.java: Loading...
  3. flume-ng-clients/flume-ng-log4jappender/src/test/java/org/apache/flume/clients/log4jappender/TestLoadBalancingLog4jAppender.java: Loading...
  4. flume-ng-clients/flume-ng-log4jappender/src/test/java/org/apache/flume/clients/log4jappender/TestLog4jAppender.java: Loading...