@Override public void close() { if (closed.compareAndSet(false, true)) { // wait for queue to empty and prevent anything else from being enqueued semaphore.acquireUninterruptibly(semaphoreSize); // wait for all asynchronously committing transactions to complete commiting.waitUntilZero(); if (executor != null) { executor.shutdown(); while (!executor.isTerminated()) { try { executor.awaitTermination(3, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } } } if (exceptionRef.get() != null) { throw new RuntimeException(exceptionRef.get()); } // wait for any async mutations that transactions write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); } } }
@Override CompletableFuture<Boolean> getMainOp(CommitData cd) { return env.getSharedResources().getBatchWriter() .writeMutationsAsyncFuture(createMutations(cd)).thenApply(v -> true); }
@Override public void close() { if (closed.compareAndSet(false, true)) { // wait for queue to empty and prevent anything else from being enqueued semaphore.acquireUninterruptibly(semaphoreSize); // wait for all asynchronously committing transactions to complete commiting.waitUntilZero(); if (executor != null) { executor.shutdown(); while (!executor.isTerminated()) { try { executor.awaitTermination(3, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } } } if (exceptionRef.get() != null) { throw new RuntimeException(exceptionRef.get()); } // wait for any async mutations that transactions write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); } } }
@Override CompletableFuture<Boolean> getMainOp(CommitData cd) { return env.getSharedResources().getBatchWriter() .writeMutationsAsyncFuture(createMutations(cd)).thenApply(v -> true); }
@Override public void commit() { super.commit(); // wait for any async mutations that transaction write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); } };
public void commit() throws CommitException { tx.commit(); env.getSharedResources().getBatchWriter().waitForAsyncFlush(); }
void deleteWeakRow() { if (weakNotification != null) { env.getSharedResources().getBatchWriter() .writeMutation(weakNotification.newDelete(env, startTs)); } }
@Override public void commit() { super.commit(); // wait for any async mutations that transaction write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); } };
void deleteWeakRow() { if (weakNotification != null) { env.getSharedResources().getBatchWriter() .writeMutation(weakNotification.newDelete(env, startTs)); } }
public void finishCommit(CommitData cd, Stamp commitStamp) { tx.finishCommit(cd, commitStamp); env.getSharedResources().getBatchWriter().waitForAsyncFlush(); }
private int countNotifications() throws Exception { // deletes of notifications are queued async at end of transaction env.getSharedResources().getBatchWriter().waitForAsyncFlush(); Scanner scanner = aClient.createScanner(getCurTableName(), Authorizations.EMPTY); Notification.configureScanner(scanner); int count = 0; for (Iterator<Entry<Key, Value>> iterator = scanner.iterator(); iterator.hasNext();) { iterator.next(); count++; } return count; } }
env.getSharedResources().getBatchWriter().writeMutations(new ArrayList<>(mutations.values()));
env.getSharedResources().getBatchWriter().writeMutations(new ArrayList<>(mutations.values()));
env.getSharedResources().getBatchWriter().waitForAsyncFlush();
env.getSharedResources().getBatchWriter().waitForAsyncFlush();
env.getSharedResources().getBatchWriter() .writeMutationAsync(notification.newDelete(env)); return true;
env.getSharedResources().getBatchWriter().waitForAsyncFlush(); iter = scanner.iterator(); Assert.assertFalse(iter.hasNext());
env.getSharedResources().getBatchWriter() .writeMutationAsync(notification.newDelete(env)); return true;