Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;
import org.apache.hadoop.hbase.util.GsonUtil;
import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;

import org.apache.hbase.thirdparty.com.google.gson.Gson;
Expand Down Expand Up @@ -271,7 +270,23 @@ public void disableStatusJournal() {

@Override
public String prettyPrintJournal() {
return StringUtils.join("\n\t", getStatusJournal());
if (!journalEnabled) {
return "";
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < journal.size(); i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will journal be null ever?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liuml07 That's a good point. It would thrown an NPE and thereafter abort the master if we print the journal without enabling it. Pushed the change to have a safety check before printing the journal entries

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. Thanks

StatusJournalEntry je = journal.get(i);
sb.append(je.toString());
if (i != 0) {
StatusJournalEntry jep = journal.get(i-1);
long delta = je.getTimeStamp() - jep.getTimeStamp();
if (delta != 0) {
sb.append(" (+" + delta + " ms)");
}
}
sb.append("\n");
}
return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ public boolean compact(CompactionContext compaction, HStore store,
} finally {
if (requestNeedsCancellation) store.cancelRequestedCompaction(compaction);
if (status != null) {
LOG.debug("Compaction status journal for {}:\n\t{}", this.getRegionInfo().getEncodedName(),
LOG.debug("Compaction status journal for {}:\n{}", this.getRegionInfo().getEncodedName(),
status.prettyPrintJournal());
status.cleanup();
}
Expand Down Expand Up @@ -2506,7 +2506,7 @@ public FlushResultImpl flushcache(List<byte[]> families,
}
} finally {
lock.readLock().unlock();
LOG.debug("Flush status journal for {}:\n\t{}", this.getRegionInfo().getEncodedName(),
LOG.debug("Flush status journal for {}:\n{}", this.getRegionInfo().getEncodedName(),
status.prettyPrintJournal());
status.cleanup();
}
Expand Down