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 "Amit Jain (JIRA)" <ji...@apache.org> on 2017/08/25 08:12:01 UTC

[jira] [Assigned] (OAK-6586) An oak-run command to check external binary references

     [ https://issues.apache.org/jira/browse/OAK-6586?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amit Jain reassigned OAK-6586:
------------------------------

    Assignee: Amit Jain  (was: Andrei Dulceanu)

> An oak-run command to check external binary references
> ------------------------------------------------------
>
>                 Key: OAK-6586
>                 URL: https://issues.apache.org/jira/browse/OAK-6586
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: run
>            Reporter: Arek Kita
>            Assignee: Amit Jain
>             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:
> * binaries that are not inlined _when_ BlobStore/DataStore is not defined (the assumption is we have *+only+* inlined binaries and we would like to verify such hypothesis, external reference exists but shouldn't and no DS is known, i.e. a result of misconfiguration)
> * missing binaries in defined BlobStore/DataStore (external references exist but no binary is present at DataStore)
> _This might also be also very helpful debugging repository in the future with CompositeBlobStore layouts._
> 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)