You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flume.apache.org by es...@apache.org on 2011/08/12 02:46:43 UTC
svn commit: r1156875 -
/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java
Author: esammer
Date: Fri Aug 12 00:46:42 2011
New Revision: 1156875
URL: http://svn.apache.org/viewvc?rev=1156875&view=rev
Log:
- We now block on driver thread start and complain LOUDLY if we can't.
Modified:
incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java
Modified: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java?rev=1156875&r1=1156874&r2=1156875&view=diff
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java (original)
+++ incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/core/ChannelDriver.java Fri Aug 12 00:46:42 2011
@@ -27,7 +27,9 @@ public class ChannelDriver implements Li
}
@Override
- public void start(Context context) throws LifecycleException {
+ public void start(Context context) throws LifecycleException,
+ InterruptedException {
+
logger.debug("Channel driver starting:{}", this);
driverThread = new ChannelDriverThread(name);
@@ -35,9 +37,35 @@ public class ChannelDriver implements Li
driverThread.setSource(source);
driverThread.setSink(sink);
- lifecycleState = LifecycleState.START;
-
driverThread.start();
+
+ /*
+ * FIXME: We can't use LifecycleController because the driver thread isn't
+ * technically LifecycleAware.
+ */
+ while (!driverThread.getLifecycleState().equals(LifecycleState.START)
+ && !driverThread.getLifecycleState().equals(LifecycleState.ERROR)) {
+
+ logger.debug("Waiting for driver thread to start");
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ logger
+ .error(
+ "Interrupted while waiting for the driver thread to start. Likely a code error. Please report this to the developers. Exception follow.",
+ e);
+
+ lifecycleState = LifecycleState.ERROR;
+
+ driverThread.setShouldStop(true);
+ driverThread.join();
+
+ return;
+ }
+ }
+
+ lifecycleState = LifecycleState.START;
}
@Override
@@ -111,8 +139,8 @@ public class ChannelDriver implements Li
private EventSink sink;
private Context context;
- private LifecycleState lifecycleState;
- private Exception lastException;
+ volatile private LifecycleState lifecycleState;
+ volatile private Exception lastException;
private long totalEvents;
private long discardedEvents;