public boolean isDone() { return driverContext.isDone(); }
@GuardedBy("exclusiveLock") private boolean isFinishedInternal() { checkLockHeld("Lock must be held to call isFinishedInternal"); boolean finished = state.get() != State.ALIVE || driverContext.isDone() || activeOperators.isEmpty() || activeOperators.get(activeOperators.size() - 1).isFinished(); if (finished) { state.compareAndSet(State.ALIVE, State.NEED_DESTRUCTION); } return finished; }
public boolean isFinished() { checkLockNotHeld("Can not check finished status while holding the driver lock"); // if we can get the lock, attempt a clean shutdown; otherwise someone else will shutdown Optional<Boolean> result = tryWithLock(this::isFinishedInternal); return result.orElseGet(() -> state.get() != State.ALIVE || driverContext.isDone()); }
@GuardedBy("exclusiveLock") private void handleMemoryRevoke() { for (int i = 0; i < activeOperators.size() && !driverContext.isDone(); i++) { Operator operator = activeOperators.get(i); if (revokingOperators.containsKey(operator)) { checkOperatorFinishedRevoking(operator); } else if (operator.getOperatorContext().isMemoryRevokingRequested()) { ListenableFuture<?> future = operator.startMemoryRevoke(); revokingOperators.put(operator, future); checkOperatorFinishedRevoking(operator); } } }
for (int i = 0; i < activeOperators.size() - 1 && !driverContext.isDone(); i++) { Operator current = activeOperators.get(i); Operator next = activeOperators.get(i + 1);
@Test(invocationCount = 1_000, timeOut = 10_000) public void testConcurrentClose() { List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT); OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), "values"); ValuesOperator source = new ValuesOperator(operatorContext, rowPagesBuilder(types) .addSequencePage(10, 20, 30, 40) .build()); Operator sink = createSinkOperator(types); Driver driver = Driver.createDriver(driverContext, source, sink); // let these threads race scheduledExecutor.submit(() -> driver.processFor(new Duration(1, TimeUnit.NANOSECONDS))); // don't want to call isFinishedInternal in processFor scheduledExecutor.submit(() -> driver.close()); while (!driverContext.isDone()) { Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MILLISECONDS); } }
public boolean isDone() { return driverContext.isDone(); }
private boolean isFinishedInternal() { checkLockHeld("Lock must be held to call isFinishedInternal"); boolean finished = state.get() != State.ALIVE || driverContext.isDone() || operators.get(operators.size() - 1).isFinished(); if (finished) { state.compareAndSet(State.ALIVE, State.NEED_DESTRUCTION); } return finished; }
public boolean isFinished() { checkLockNotHeld("Can not check finished status while holding the driver lock"); // if we can get the lock, attempt a clean shutdown; otherwise someone else will shutdown try (DriverLockResult lockResult = tryLockAndProcessPendingStateChanges(0, TimeUnit.MILLISECONDS)) { if (lockResult.wasAcquired()) { return isFinishedInternal(); } else { // did not get the lock, so we can't check operators, or destroy return state.get() != State.ALIVE || driverContext.isDone(); } } }