@Override public boolean isRunning() { // workaround until CDAP-7479 is fixed return super.isRunning() || !getHistory(ProgramRunStatus.RUNNING).isEmpty(); }
@Override public boolean isRunning() { // workaround until CDAP-7479 is fixed return super.isRunning() || !getHistory(ProgramRunStatus.RUNNING).isEmpty(); } }
/** * Waits for the program status. * * @param status true to wait for start, false for stop * @param sleepTime time to sleep in between polling * @param timeout timeout for the polling if the status doesn't match * @param timeoutUnit unit for both sleepTime and timeout */ protected void waitForStatus(boolean status, long sleepTime, long timeout, TimeUnit timeoutUnit) throws InterruptedException { long timeoutMillis = timeoutUnit.toMillis(timeout); boolean statusMatched = status == isRunning(); long startTime = System.currentTimeMillis(); while (!statusMatched && (System.currentTimeMillis() - startTime) < timeoutMillis) { timeoutUnit.sleep(sleepTime); statusMatched = status == isRunning(); } if (!statusMatched) { throw new IllegalStateException(String.format("Program state for '%s' not as expected. Expected '%s'.", programId, status)); } }
@Override public boolean isRunning() { // workaround until CDAP-7479 is fixed return super.isRunning() || !getHistory(ProgramRunStatus.RUNNING).isEmpty(); } }
@Override public boolean isRunning() { // workaround until CDAP-7479 is fixed return super.isRunning() || !getHistory(ProgramRunStatus.RUNNING).isEmpty(); }
/** * Waits for the program status. * * @param status true to wait for start, false for stop * @param sleepTime time to sleep in between polling * @param timeout timeout for the polling if the status doesn't match * @param timeoutUnit unit for both sleepTime and timeout */ protected void waitForStatus(boolean status, long sleepTime, long timeout, TimeUnit timeoutUnit) throws InterruptedException { long timeoutMillis = timeoutUnit.toMillis(timeout); boolean statusMatched = status == isRunning(); long startTime = System.currentTimeMillis(); while (!statusMatched && (System.currentTimeMillis() - startTime) < timeoutMillis) { timeoutUnit.sleep(sleepTime); statusMatched = status == isRunning(); } if (!statusMatched) { throw new IllegalStateException(String.format("Program state for '%s' not as expected. Expected '%s'.", programId, status)); } }