@ Override public OperationFuture < Boolean > flush ( final int delay ) { final AtomicReference < Boolean > flushResult = new AtomicReference < Boolean > ( null ) ; final ConcurrentLinkedQueue < Operation > ops = new ConcurrentLinkedQueue < Operation > ( ) ; CountDownLatch blatch = broadcastOp ( new BroadcastOpFactory ( ) { @ Override public Operation newOp ( final MemcachedNode n , final CountDownLatch latch ) { Operation op = opFact . flush ( delay , new OperationCallback ( ) { @ Override public void receivedStatus ( OperationStatus s ) { flushResult . set ( s . isSuccess ( ) ) ; } @ Override public void complete ( ) { latch . countDown ( ) ; } } ) ; ops . add ( op ) ; return op ; } } ) ; return new OperationFuture < Boolean > ( null , blatch , flushResult , operationTimeout , executorService ) { @ Override public void set ( Boolean o , OperationStatus s ) { super . set ( o , s ) ; notifyListeners ( ) ; } @ Override public boolean cancel ( boolean ign ) { boolean rv = false ; for ( Operation op : ops ) { op . cancel ( ) ; rv |= op . getState ( ) == OperationState . WRITE_QUEUED ; } notifyListeners ( ) ; return rv ; } @ Override public Boolean get ( long duration , TimeUnit units ) throws InterruptedException , TimeoutException , ExecutionException { status = new OperationStatus ( true , "OK" , StatusCode . SUCCESS ) ; return super . get ( duration , units ) ; } @ Override public boolean isCancelled ( ) { boolean rv = false ; for ( Operation op : ops ) { rv |= op . isCancelled ( ) ; } return rv ; } @ Override public boolean isDone ( ) { boolean rv = true ; for ( Operation op : ops ) { rv &= op . getState ( ) == OperationState . COMPLETE ; } return rv || isCancelled ( ) ; } } ; }
Flush all caches from all servers with a delay of application .