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/09/04 19:33:15 UTC
[GitHub] sijie closed pull request #1632: ISSUE #1623: ReadOnlyLedgerHandle:
don't schedule monitorPendingAddOps()
sijie closed pull request #1632: ISSUE #1623: ReadOnlyLedgerHandle: don't schedule monitorPendingAddOps()
URL: https://github.com/apache/bookkeeper/pull/1632
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
index bd81b73c01..6894351513 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
@@ -253,34 +253,39 @@ public Integer getSample() {
return pendingAddOps.size();
}
});
- initializeExplicitLacFlushPolicy();
-
- if (bk.getConf().getAddEntryQuorumTimeout() > 0) {
- SafeRunnable monitor = new SafeRunnable() {
- @Override
- public void safeRun() {
- monitorPendingAddOps();
- }
- };
- this.timeoutFuture = bk.scheduler.scheduleAtFixedRate(monitor,
- bk.getConf().getTimeoutMonitorIntervalSec(),
- bk.getConf().getTimeoutMonitorIntervalSec(),
- TimeUnit.SECONDS);
- }
+ initializeWriteHandleState();
}
BookKeeper getBk() {
return bk;
}
- protected void initializeExplicitLacFlushPolicy() {
- if (!getLedgerMetadata().isClosed()
- && !(this instanceof ReadOnlyLedgerHandle)
- && bk.getExplicitLacInterval() > 0) {
+ protected void initializeWriteHandleState() {
+ if (bk.getExplicitLacInterval() > 0) {
explicitLacFlushPolicy = new ExplicitLacFlushPolicy.ExplicitLacFlushPolicyImpl(this);
} else {
explicitLacFlushPolicy = ExplicitLacFlushPolicy.VOID_EXPLICITLAC_FLUSH_POLICY;
}
+
+ if (bk.getConf().getAddEntryQuorumTimeout() > 0) {
+ SafeRunnable monitor = new SafeRunnable() {
+ @Override
+ public void safeRun() {
+ monitorPendingAddOps();
+ }
+ };
+ this.timeoutFuture = bk.scheduler.scheduleAtFixedRate(monitor,
+ bk.getConf().getTimeoutMonitorIntervalSec(),
+ bk.getConf().getTimeoutMonitorIntervalSec(),
+ TimeUnit.SECONDS);
+ }
+ }
+
+ private void tearDownWriteHandleState() {
+ explicitLacFlushPolicy.stopExplicitLacFlush();
+ if (timeoutFuture != null) {
+ timeoutFuture.cancel(false);
+ }
}
/**
@@ -462,10 +467,6 @@ public void close()
CompletableFuture<Void> result = new CompletableFuture<>();
SyncCloseCallback callback = new SyncCloseCallback(result);
asyncClose(callback, null);
- explicitLacFlushPolicy.stopExplicitLacFlush();
- if (timeoutFuture != null) {
- timeoutFuture.cancel(false);
- }
return result;
}
@@ -641,7 +642,7 @@ public String toString() {
}
writeLedgerConfig(new CloseCb());
-
+ tearDownWriteHandleState();
}
@Override
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
index 3cc59a042b..d65c8ab838 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java
@@ -182,7 +182,8 @@ public String toString() {
}
@Override
- protected void initializeExplicitLacFlushPolicy() {
+ protected void initializeWriteHandleState() {
+ // Essentially a noop, we don't want to set up write handle state here for a ReadOnlyLedgerHandle
explicitLacFlushPolicy = ExplicitLacFlushPolicy.VOID_EXPLICITLAC_FLUSH_POLICY;
}
----------------------------------------------------------------
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