You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/05/29 05:49:51 UTC

[GitHub] jvrao commented on a change in pull request #1436: BP-14 force() API - client side implementation

jvrao commented on a change in pull request #1436: BP-14 force() API - client side implementation
URL: https://github.com/apache/bookkeeper/pull/1436#discussion_r191309413
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ForceLedgerOp.java
 ##########
 @@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bookkeeper.client;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.concurrent.CompletableFuture;
+import org.apache.bookkeeper.common.concurrent.FutureUtils;
+import org.apache.bookkeeper.net.BookieSocketAddress;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ForceLedgerCallback;
+import org.apache.bookkeeper.util.SafeRunnable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This represents a request to sync the ledger on every bookie.
+ */
+class ForceLedgerOp extends SafeRunnable implements ForceLedgerCallback {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ForceLedgerOp.class);
+    final CompletableFuture<Void> cb;
+    BitSet receivedResponseSet;
+
+    DistributionSchedule.AckSet ackSet;
+    boolean completed = false;
+    int lastSeenError = BKException.Code.WriteException;
+    ArrayList<BookieSocketAddress> currentEnsemble;
+
+    long currentNonDurableLastAddConfirmed = LedgerHandle.INVALID_ENTRY_ID;
+
+    final LedgerHandle lh;
+
+    ForceLedgerOp(LedgerHandle lh, CompletableFuture<Void> cb) {
+        this.lh = lh;
+        this.cb = cb;
+    }
+
+    void sendForceLedgerRequest(int bookieIndex) {
+        lh.bk.getBookieClient().forceLedger(currentEnsemble.get(bookieIndex), lh.ledgerId, this, bookieIndex);
+    }
+
+    @Override
+    public void safeRun() {
+        initiate();
+    }
+
+    void initiate() {
+
+        // capture currentNonDurableLastAddConfirmed
+        // remember that we are inside OrderedExecutor, this induces a strict ordering
+        // on the sequence of events
+        this.currentNonDurableLastAddConfirmed = lh.pendingAddsSequenceHead;
+        LOG.debug("start force() on ledger {} capturing {} ", lh.ledgerId, currentNonDurableLastAddConfirmed);
 
 Review comment:
   instead of capturing {} ; just say clientNonDurableLac {} 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services