You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2017/04/20 17:35:25 UTC

[3/7] bookkeeper git commit: Fix

Fix


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

Branch: refs/heads/sijie/bookkeeper_fallocate
Commit: 6077ef8b97648aa5521d352609abb236b151b8ad
Parents: 014512c
Author: Sijie Guo <si...@apache.org>
Authored: Thu Nov 17 17:42:36 2016 -0800
Committer: Sijie Guo <si...@apache.org>
Committed: Thu Nov 17 17:42:36 2016 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/bookkeeper/bookie/Journal.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/6077ef8b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index e8adfff..942a93f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -334,12 +334,14 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
 
             try {
                 if (shouldForceWrite) {
+                    long startTime = MathUtils.nowInNano();
                     if (enableGroupForceWrites) {
                         this.logFile.forceWrite(false);
                     } else {
                         this.logFile.syncRangeOrForceWrite(this.startFlushPosition,
                             this.endFlushPosition - this.startFlushPosition);
                     }
+                    journalSyncStats.registerSuccessfulEvent(MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS);
                 }
                 lastLogMark.setCurLogMark(this.logId, this.endFlushPosition);
 
@@ -539,6 +541,7 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
     private final StatsLogger statsLogger;
     private final OpStatsLogger journalAddEntryStats;
     private final OpStatsLogger journalMemAddEntryStats;
+    private final OpStatsLogger journalSyncStats;
     private final OpStatsLogger journalCreationStats;
     private final OpStatsLogger journalFlushStats;
     private final OpStatsLogger journalMemAddFlushStats;
@@ -594,6 +597,7 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
         this.statsLogger = statsLogger;
         journalAddEntryStats = statsLogger.getOpStatsLogger(JOURNAL_ADD_ENTRY);
         journalMemAddEntryStats = statsLogger.getOpStatsLogger(JOURNAL_MEM_ADD_ENTRY);
+        journalSyncStats = statsLogger.getOpStatsLogger(JOURNAL_SYNC);
         journalCreationStats = statsLogger.getOpStatsLogger(JOURNAL_CREATION_LATENCY);
         journalFlushStats = statsLogger.getOpStatsLogger(JOURNAL_FLUSH_LATENCY);
         journalMemAddFlushStats = statsLogger.getOpStatsLogger(JOURNAL_FLUSH_IN_MEM_ADD);
@@ -857,7 +861,7 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
 
                     bc = logFile.getBufferedChannel();
 
-                    lastFlushPosition = 0;
+                    lastFlushPosition = bc.position();
                 }
 
                 if (qe == null) {
@@ -928,7 +932,7 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
                                 logFile.startSyncRange(prevFlushPosition, lastFlushPosition);
                             }
                             journalFlushStats.registerSuccessfulEvent(
-                                    journalFlushWatcher.stop().elapsedTime(TimeUnit.MICROSECONDS), TimeUnit.MICROSECONDS);
+                                    journalFlushWatcher.stop().elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
 
                             // Trace the lifetime of entries through persistence
                             if (LOG.isDebugEnabled()) {