Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
chetanmeh / listIndexFiles.groovy
Last active March 12, 2022 15:40
Lucene index files details
import groovy.json.JsonOutput
import org.apache.jackrabbit.oak.api.Blob
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeState
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.slf4j.LoggerFactory
//Directory path under which dump data would be written
def dumpDirPath = 'crx-quickstart/logs'
@chetanmeh
chetanmeh / oakRepoStats.groovy
Last active March 12, 2022 15:41
Groovy script to get various stats related to Oak repository
import com.codahale.metrics.ConsoleReporter
import com.codahale.metrics.MetricRegistry
import com.google.common.base.Predicate
import com.google.common.base.Stopwatch
import com.google.common.collect.AbstractIterator
import com.google.common.collect.FluentIterable
import com.google.common.collect.Iterators
import com.google.common.collect.PeekingIterator
import com.google.common.collect.Sets
import com.google.common.collect.TreeTraverser
@chetanmeh
chetanmeh / consoleIndexStats.groovy
Created June 23, 2016 09:41
Script to analyze the content of property indexes. Number of entries, number of indexes etc on a fine grained basis
import com.google.common.base.Function
import com.google.common.base.Stopwatch
import com.google.common.collect.FluentIterable
import com.google.common.collect.TreeTraverser
import groovy.json.JsonOutput
import groovy.text.SimpleTemplateEngine
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeState
import static com.google.common.collect.Iterables.transform
@chetanmeh
chetanmeh / nodeStats.groovy
Created June 16, 2016 15:38
Script to get node details and property details from an Oak based setup
package felixconsole
import com.google.common.base.Stopwatch
import com.google.common.collect.FluentIterable
import com.google.common.collect.TreeTraverser
import org.apache.jackrabbit.JcrConstants
import org.apache.jackrabbit.oak.api.PropertyState
import org.apache.jackrabbit.oak.api.Tree
@chetanmeh
chetanmeh / README.md
Last active January 21, 2021 21:13
Oak DataStore Consistency Check

This script traverses a repository and look for orphaned binary reference i.e. binary references which are present in repository but not present in DataStore.

This script can be used with both Felix Script Console and Oak Console. In of Felix console just add a call like below while in Oak Console you can invoke in command line

Felix Script Console

Add following call at the end of script

new BlobChecker(script:this, reportPath:'crx-quickstart/logs').checkBlobs('/')
@chetanmeh
chetanmeh / Tokenizer.java
Created February 24, 2016 05:10
Lucene Token breakdown via Analyzer
private void dumpTokenized(String text, Analyzer analyzer) throws IOException {
List<String> tokens = tokenize(text, analyzer);
System.out.printf("Text to tokenize [%s] via %s %n", text, analyzer.getClass().getSimpleName());
for (String t : tokens){
System.out.printf("[%s] ", t);
}
System.out.println();
}
@chetanmeh
chetanmeh / JcrWithFileDataStoreTest.java
Created January 27, 2016 11:37
Constructs a Oak repository with FileDataStore configured for testing
import java.io.IOException;
import java.util.Properties;
import javax.jcr.Repository;
import org.apache.jackrabbit.api.JackrabbitRepository;
import org.apache.jackrabbit.core.data.FileDataStore;
import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
@chetanmeh
chetanmeh / dumpContent.groovy
Last active January 12, 2016 10:58
Dump Document nodes and index files
package felixconsole
import org.apache.jackrabbit.oak.commons.IOUtils as OakIOUtils
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
import org.apache.jackrabbit.oak.api.Blob
import org.apache.jackrabbit.oak.commons.PathUtils
import org.slf4j.LoggerFactory
/**
@chetanmeh
chetanmeh / dumpBinaryStats.groovy
Created June 3, 2015 09:02
Script to generate csv file containing the binary related metadata required for https://issues.apache.org/jira/browse/OAK-2953
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@chetanmeh
chetanmeh / listener.groovy
Created April 12, 2015 15:02
Oak Listener Details
import com.google.common.collect.ImmutableList
import com.google.common.collect.Iterables
import com.google.common.collect.Lists
import groovy.text.SimpleTemplateEngine
import org.apache.jackrabbit.oak.spi.commit.BackgroundObserver
import org.apache.jackrabbit.oak.spi.commit.Observer
def observers = osgi.getServices(Observer.class, null)
println "Number of observers : ${observers.size()}"