Skip to content

Commit

Permalink
OAK-2313 Better handling for external binaries in the segment explorer
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1642765 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
stillalex committed Dec 1, 2014
1 parent 63d69f5 commit 84fd938
Showing 1 changed file with 37 additions and 3 deletions.
Expand Up @@ -308,9 +308,9 @@ private String toString(PropertyState ps, int index, String tarFile) {
Blob b = ps.getValue(Type.BINARY, index);
String info = "<";
info += b.getClass().getSimpleName() + ";";
info += "ref:" + b.getReference() + ";";
info += "ref:" + safeGetReference(b) + ";";
info += "id:" + b.getContentIdentity() + ";";
info += FileUtils.byteCountToDisplaySize(b.length()) + ">";
info += safeGetLength(b) + ">";
for (SegmentId sid : SegmentBlob.getBulkSegmentIds(b)) {
info += newline + " Bulk Segment Id " + sid;
String f = getFile(sid);
Expand All @@ -335,6 +335,24 @@ private String toString(PropertyState ps, int index, String tarFile) {
}
}

private String safeGetReference(Blob b) {
try {
return b.getReference();
} catch (IllegalStateException e) {
// missing BlobStore probably
}
return "[BlobStore not available]";
}

private String safeGetLength(Blob b) {
try {
return FileUtils.byteCountToDisplaySize(b.length());
} catch (IllegalStateException e) {
// missing BlobStore probably
}
return "[BlobStore not available]";
}

private String getFile(RecordId id) {
return getFile(id.getSegmentId());
}
Expand Down Expand Up @@ -426,6 +444,13 @@ public void printDependenciesToSegment(String sid) {
StringBuilder sb = new StringBuilder();
sb.append("SegmentNodeState references to " + id);
sb.append(newline);
for (Entry<String, Set<UUID>> e : store.getTarReaderIndex().entrySet()) {
if (e.getValue().contains(id)) {
sb.append("Tar file: " + e.getKey());
sb.append(newline);
break;
}
}

List<String> paths = newArrayList();
filterNodeStates(newHashSet(id), paths, store.getHead(), "/");
Expand Down Expand Up @@ -729,7 +754,16 @@ private static Long[] exploreSize(SegmentNodeState ns,
}
for (PropertyState ps : ns.getProperties()) {
for (int j = 0; j < ps.count(); j++) {
s[0] = s[0] + ps.size(j);
if (ps.getType().tag() == Type.BINARY.tag()) {
Blob b = ps.getValue(Type.BINARY, j);
boolean skip = b instanceof SegmentBlob
&& ((SegmentBlob) b).isExternal();
if (!skip) {
s[0] = s[0] + b.length();
}
} else {
s[0] = s[0] + ps.size(j);
}
}
}
sizeCache.put(key, s);
Expand Down

0 comments on commit 84fd938

Please sign in to comment.