Review Board 1.7.22


Fixes the problem with RollingFileSink being unable to resume on reconfiguration

Review Request #8297 - Created Nov. 30, 2012 and submitted

Roshan Naik
https://issues.apache.org/jira/browse/FLUME-1175
Reviewers
Flume
flume-git
 - nulling out outputStream in  RollingFileSink.stop()   [ here we rely on the invariant that outputStream==null  implies  serializer==null ]
 - removing superfluous calls to outputStream.flush()
ran RollingFileSink tests
flume-ng-core/src/main/java/org/apache/flume/sink/RollingFileSink.java
Revision be640bb New Change
[20] 143 lines
[+20] [+] public Status process() throws EventDeliveryException {
144
        logger.debug("Closing file {}", pathController.getCurrentFile());
144
        logger.debug("Closing file {}", pathController.getCurrentFile());
145

    
   
145

   
146
        try {
146
        try {
147
          serializer.flush();
147
          serializer.flush();
148
          serializer.beforeClose();
148
          serializer.beforeClose();
149
          outputStream.flush();

   
150
          outputStream.close();
149
          outputStream.close();
151
          sinkCounter.incrementConnectionClosedCount();
150
          sinkCounter.incrementConnectionClosedCount();
152
          shouldRotate = false;
151
          shouldRotate = false;
153
        } catch (IOException e) {
152
        } catch (IOException e) {
154
          sinkCounter.incrementConnectionFailedCount();
153
          sinkCounter.incrementConnectionFailedCount();
155
          throw new EventDeliveryException("Unable to rotate file "
154
          throw new EventDeliveryException("Unable to rotate file "
156
              + pathController.getCurrentFile() + " while delivering event", e);
155
              + pathController.getCurrentFile() + " while delivering event", e);
157
        }
156
        } finally {
158

    
   

   
159
        serializer = null;
157
          serializer = null;
160
        outputStream = null;
158
          outputStream = null;

    
   
159
        }
161
        pathController.rotate();
160
        pathController.rotate();
162
      }
161
      }
163
    }
162
    }
164

    
   
163

   
165
    if (outputStream == null) {
164
    if (outputStream == null) {
[+20] [20] 67 lines
[+20] [+] public void stop() {
233
      logger.debug("Closing file {}", pathController.getCurrentFile());
232
      logger.debug("Closing file {}", pathController.getCurrentFile());
234

    
   
233

   
235
      try {
234
      try {
236
        serializer.flush();
235
        serializer.flush();
237
        serializer.beforeClose();
236
        serializer.beforeClose();
238
        outputStream.flush();

   
239
        outputStream.close();
237
        outputStream.close();
240
        sinkCounter.incrementConnectionClosedCount();
238
        sinkCounter.incrementConnectionClosedCount();
241
      } catch (IOException e) {
239
      } catch (IOException e) {
242
        sinkCounter.incrementConnectionFailedCount();
240
        sinkCounter.incrementConnectionFailedCount();
243
        logger.error("Unable to close output stream. Exception follows.", e);
241
        logger.error("Unable to close output stream. Exception follows.", e);

    
   
242
      } finally {

    
   
243
        outputStream = null;

    
   
244
        serializer = null;
244
      }
245
      }
245
    }
246
    }
246
    if(rollInterval > 0){
247
    if(rollInterval > 0){
247
      rollService.shutdown();
248
      rollService.shutdown();
248

    
   
249

   
[+20] [20] 32 lines
  1. flume-ng-core/src/main/java/org/apache/flume/sink/RollingFileSink.java: Loading...