You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Arek Kita (JIRA)" <ji...@apache.org> on 2017/08/24 14:04:00 UTC
[jira] [Created] (OAK-6586) An oak-run command to check missing
inline/external binaries
Arek Kita created OAK-6586:
------------------------------
Summary: An oak-run command to check missing inline/external binaries
Key: OAK-6586
URL: https://issues.apache.org/jira/browse/OAK-6586
Project: Jackrabbit Oak
Issue Type: Improvement
Components: run
Reporter: Arek Kita
Assignee: Andrei Dulceanu
Fix For: 1.8
It would be good if we could create OOTB check in oak-run that could scan Oak repositories looking for any binaries that might be missing mostly due to 2 reasons:
* missing inlined binaries where BlobStore/DataStore is not defined (external reference exist but no DS is known, result of misconfiguration)
* missing binaries in BlobStore/DataStore (references exist but no binary is present)
I see that this is is often the case and it causes problems during migration (upgrades, sidegrades) of stores. The knowledge which JCR paths are affected would be a great help for Oak users.
The following groovy script does this but I thought about something built-in.
{code}
// usage:
// java -jar oak-run-1.4.6.jar console --fds-path crx-quickstart/repository/datastore crx-quickstart/repository/segmentstore ":load find-missing-blobs.groovy"
import org.apache.jackrabbit.oak.api.PropertyState
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.commons.PathUtils
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeState
org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME).setLevel(ch.qos.logback.classic.Level.OFF)
class MissingBlobFinder {
static checkProperties(state, String path) {
for (PropertyState p : state.properties) {
try {
if (p.type == Type.BINARY) {
InputStream is = p.getValue(Type.BINARY).newStream
is.read()
is.close()
} else if (p.type == Type.BINARIES && p.count() > 0) {
InputStream is = p.getValue(Type.BINARIES).iterator().next().newStream
is.read()
is.close()
}
} catch (Exception e) {
System.out.println(PathUtils.concat(path, p.name))
}
}
}
static traverse(NodeState state, String path) {
checkProperties(state, path)
for (ChildNodeEntry c : state.childNodeEntries) {
traverse(c.nodeState, PathUtils.concat(path, c.name))
}
}
static runFixer(session) {
System.out.println("---")
System.out.println("List of missing blobs:")
System.out.println()
traverse(session.store.root, "/")
System.out.println("---")
null
}
}
MissingBlobFinder.runFixer(session)
{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)