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:38 UTC
svn commit: r1156873 -
/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java
Author: esammer
Date: Fri Aug 12 00:46:38 2011
New Revision: 1156873
URL: http://svn.apache.org/viewvc?rev=1156873&view=rev
Log:
- Added LifecycleController methods that block indefinitely.
Modified:
incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java
Modified: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java?rev=1156873&r1=1156872&r2=1156873&view=diff
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java (original)
+++ incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleController.java Fri Aug 12 00:46:38 2011
@@ -10,26 +10,11 @@ public class LifecycleController {
private static final long shortestSleepDuration = 50;
private static final int maxNumberOfChecks = 5;
- /*
- * public static boolean waitForState(LifecycleAware delegate, LifecycleState
- * state, long timeout) throws InterruptedException {
- *
- * logger.debug("Waiting for state {} for delegate:{} up to {}ms", new
- * Object[] { state, delegate, timeout });
- *
- * long sleepInterval = Math.max(shortestSleepDuration, timeout /
- * maxNumberOfChecks); long deadLine = System.currentTimeMillis() + timeout;
- *
- * do { if (delegate.getLifecycleState().equals(state)) { return true; }
- *
- * logger.debug("Still want state:{} sleeping:{}ms", state, sleepInterval);
- * Thread.sleep(sleepInterval); } while (System.currentTimeMillis() <
- * deadLine);
- *
- * logger.debug("Didn't see state within timeout {}ms", timeout);
- *
- * return false; }
- */
+ public static boolean waitForState(LifecycleAware delegate,
+ LifecycleState state) throws InterruptedException {
+
+ return waitForState(delegate, state, 0);
+ }
public static boolean waitForState(LifecycleAware delegate,
LifecycleState state, long timeout) throws InterruptedException {
@@ -38,6 +23,12 @@ public class LifecycleController {
}
public static boolean waitForOneOf(LifecycleAware delegate,
+ LifecycleState[] states) throws InterruptedException {
+
+ return waitForOneOf(delegate, states, 0);
+ }
+
+ public static boolean waitForOneOf(LifecycleAware delegate,
LifecycleState[] states, long timeout) throws InterruptedException {
logger.debug("Waiting for state {} for delegate:{} up to {}ms",
@@ -57,7 +48,7 @@ public class LifecycleController {
logger.debug("Still want one of states:{} sleeping:{}ms", states,
sleepInterval);
Thread.sleep(sleepInterval);
- } while (System.currentTimeMillis() < deadLine);
+ } while (timeout == 0 || System.currentTimeMillis() < deadLine);
logger.debug("Didn't see state within timeout {}ms", timeout);