Review Board 1.7.22


FLUME-1854: Application class can deadlock if stopped immediately after start

Review Request #8978 - Created Jan. 17, 2013 and submitted

Brock Noland
FLUME-1854
Reviewers
Flume
flume-git
Fixed race condition found in FLUME-1854.
Unit test added which caught this condition, if present, the majority of times.

Diff revision 2 (Latest)

1 2
1 2

  1. flume-ng-node/src/main/java/org/apache/flume/node/Application.java: Loading...
  2. flume-ng-node/src/test/java/org/apache/flume/node/TestApplication.java: Loading...
flume-ng-node/src/main/java/org/apache/flume/node/Application.java
Revision c066a1a New Change
[20] 71 lines
[+20] [+] public class Application {
72
  public Application(List<LifecycleAware> components) {
72
  public Application(List<LifecycleAware> components) {
73
    this.components = components;
73
    this.components = components;
74
    supervisor = new LifecycleSupervisor();
74
    supervisor = new LifecycleSupervisor();
75
  }
75
  }
76

    
   
76

   
77
  public void start() {
77
  public synchronized void start() {
78
    for(LifecycleAware component : components) {
78
    for(LifecycleAware component : components) {
79
      supervisor.supervise(component,
79
      supervisor.supervise(component,
80
          new SupervisorPolicy.AlwaysRestartPolicy(), LifecycleState.START);
80
          new SupervisorPolicy.AlwaysRestartPolicy(), LifecycleState.START);
81
    }
81
    }
82
  }
82
  }
83

    
   
83

   
84

    
   
84

   
85
  @Subscribe
85
  @Subscribe
86
  public synchronized void handleConfigurationEvent(MaterializedConfiguration conf) {
86
  public synchronized void handleConfigurationEvent(MaterializedConfiguration conf) {
87
    stopAllComponents();
87
    stopAllComponents();
88
    startAllComponents(conf);
88
    startAllComponents(conf);
89
  }
89
  }
90

    
   
90

   
91
  public void stop() {
91
  public synchronized void stop() {
92
    supervisor.stop();
92
    supervisor.stop();
93
    if(monitorServer != null) {
93
    if(monitorServer != null) {
94
      monitorServer.stop();
94
      monitorServer.stop();
95
    }
95
    }
96
  }
96
  }
[+20] [20] 215 lines
flume-ng-node/src/test/java/org/apache/flume/node/TestApplication.java
Revision d326312 New Change
 
  1. flume-ng-node/src/main/java/org/apache/flume/node/Application.java: Loading...
  2. flume-ng-node/src/test/java/org/apache/flume/node/TestApplication.java: Loading...