Flushes to HBase any buffered client-side write operation. @return A Deferred, whose callback chain will be invoked when everything that was buffered at the time of the call has been flushed.
()
| 387 | * everything that was buffered at the time of the call has been flushed. |
| 388 | */ |
| 389 | Deferred<Object> flush() { |
| 390 | // Copy the batch to a local variable and null it out. |
| 391 | final MultiAction batched_rpcs; |
| 392 | final ArrayList<Deferred<Object>> pending; |
| 393 | synchronized (this) { |
| 394 | batched_rpcs = this.batched_rpcs; |
| 395 | this.batched_rpcs = null; |
| 396 | pending = getPendingRpcs(); |
| 397 | } |
| 398 | |
| 399 | if (pending != null && !pending.isEmpty()) { |
| 400 | @SuppressWarnings("unchecked") |
| 401 | final Deferred<Object> wait = (Deferred) Deferred.group(pending); |
| 402 | // We can return here because if we found pending RPCs it's guaranteed |
| 403 | // that batched_rpcs was null. |
| 404 | return wait; |
| 405 | } |
| 406 | |
| 407 | if (batched_rpcs == null || batched_rpcs.size() == 0) { |
| 408 | return Deferred.fromResult(null); |
| 409 | } |
| 410 | final Deferred<Object> d = batched_rpcs.getDeferred(); |
| 411 | sendRpc(batched_rpcs); |
| 412 | return d; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Introduces a sync point for all outstanding RPCs. |
no test coverage detected