bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-837: UpdateLedgerOp - Replace AbstractFuture with SettableFuture (rakeshr via sijie)
Date Thu, 12 Mar 2015 07:37:32 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master e89ee080f -> 0c7dfc077


BOOKKEEPER-837: UpdateLedgerOp - Replace AbstractFuture with SettableFuture (rakeshr via sijie)


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/0c7dfc07
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/0c7dfc07
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/0c7dfc07

Branch: refs/heads/master
Commit: 0c7dfc077b413d4019b68133cb7461832eae3541
Parents: e89ee08
Author: Sijie Guo <sijie@apache.org>
Authored: Thu Mar 12 00:37:20 2015 -0700
Committer: Sijie Guo <sijie@apache.org>
Committed: Thu Mar 12 00:37:20 2015 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../bookkeeper/client/UpdateLedgerOp.java       | 24 ++++++++++++--------
 2 files changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/0c7dfc07/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c07b06e..b84943c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -55,6 +55,8 @@ Trunk (unreleased changes)
  
       BOOKKEEPER-830: Documentation has no structure (ivank via fpj)
 
+      BOOKKEEPER-837: UpdateLedgerOp - Replace AbstractFuture with SettableFuture (rakeshr
via sijie)
+
       bookkeeper-client:
 
         BOOKKEEPER-810: Allow to configure TCP connect timeout (Charles Xie via sijie)

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/0c7dfc07/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
index 9d9f331..49b9f03 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
@@ -38,10 +38,11 @@ import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.AbstractFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.RateLimiter;
+import com.google.common.util.concurrent.SettableFuture;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
 /**
@@ -112,7 +113,7 @@ public class UpdateLedgerOp {
 
                         FutureCallback<Void> updateLedgerCb = new UpdateLedgerCb(lId,
stop, issuedLedgerCnt,
                                 updatedLedgerCnt, outstandings, syncObj, progressable);
-                        Futures.addCallback(readCb, updateLedgerCb);
+                        Futures.addCallback(readCb.getFutureListener(), updateLedgerCb);
 
                         issuedLedgerCnt.incrementAndGet();
                         if (limit != Integer.MIN_VALUE && issuedLedgerCnt.get() >=
limit || !ledgerItr.hasNext()) {
@@ -190,13 +191,12 @@ public class UpdateLedgerOp {
         }
     }
 
-    private final static class ReadLedgerMetadataCb extends AbstractFuture<Void> implements
-            GenericCallback<LedgerMetadata> {
+    private final static class ReadLedgerMetadataCb implements GenericCallback<LedgerMetadata>
{
         final BookKeeper bkc;
         final Long ledgerId;
         final BookieSocketAddress curBookieAddr;
         final BookieSocketAddress toBookieAddr;
-
+        SettableFuture<Void> future = SettableFuture.create();
         public ReadLedgerMetadataCb(BookKeeper bkc, Long ledgerId, BookieSocketAddress curBookieAddr,
                 BookieSocketAddress toBookieAddr) {
             this.bkc = bkc;
@@ -205,15 +205,19 @@ public class UpdateLedgerOp {
             this.toBookieAddr = toBookieAddr;
         }
 
+        ListenableFuture<Void> getFutureListener() {
+            return future;
+        }
+
         @Override
         public void operationComplete(int rc, LedgerMetadata metadata) {
             if (BKException.Code.NoSuchLedgerExistsException == rc) {
-                set(null);
+                future.set(null);
                 return; // this is OK
             } else if (BKException.Code.OK != rc) {
                 // open ledger failed.
                 LOG.error("Get ledger metadata {} failed. Error code {}", ledgerId, rc);
-                setException(BKException.create(rc));
+                future.setException(BKException.create(rc));
                 return;
             }
             boolean updateEnsemble = false;
@@ -225,7 +229,7 @@ public class UpdateLedgerOp {
                 }
             }
             if (!updateEnsemble) {
-                set(null);
+                future.set(null);
                 return; // ledger doesn't contains the given curBookieId
             }
             final GenericCallback<Void> writeCb = new GenericCallback<Void>()
{
@@ -234,10 +238,10 @@ public class UpdateLedgerOp {
                     if (rc != BKException.Code.OK) {
                         // metadata update failed
                         LOG.error("Ledger {} metadata update failed. Error code {}", ledgerId,
rc);
-                        setException(BKException.create(rc));
+                        future.setException(BKException.create(rc));
                         return;
                     }
-                    set(null);
+                    future.set(null);
                 }
             };
             bkc.getLedgerManager().writeLedgerMetadata(ledgerId, metadata, writeCb);


Mime
View raw message