Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
chetanmeh / LuceneJcr.java
Created March 5, 2015 18:14
Oak Lucene Index Example
/*
* 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 / aa-oak-script-console-scripts.md
Last active August 6, 2017 08:09
Oak related scripts to be executed via Felix Script Console
@chetanmeh
chetanmeh / README.md
Last active January 16, 2017 09:56
Utility JS function for Mongo when used with Jackrabbit Oak

Following js file can be load at start of mongo shell and then the functions can be accessed

$ wget https://gist.githubusercontent.com/chetanmeh/836ca8fffc4c410daed2/raw/oak-mongo.js
$ mongo localhost/oak --shell oak-mongo.js
MongoDB shell version: 2.6.3
connecting to: localhost/oak
type "help" for help
> oak.countChildren('/oak:index/')
356787

> oak.getChildStats('/oak:index')

@chetanmeh
chetanmeh / fixAsync.groovy
Last active January 23, 2016 12:56
Gist to demonstrate executing script via oak-run
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.NodeStore
def removeAsync(def session) {
NodeStore ns = session.store
def nb = ns.root.builder()
def asyncBuilder = nb.getChildNode(':async')
println "Would be removing property ${asyncBuilder.getProperty('async')}"
@chetanmeh
chetanmeh / currentTopThreads.groovy
Last active August 29, 2015 14:03
Script to determine top threads of current Java process
import java.lang.management.ManagementFactory
displayThreadDumpAlso = false
topJavaThreads = "top -b -n 1 -H | grep java"
jstack = "jstack"
maxThreads = 5
pid = myPid()
def dump = threadDump(pid)
def currentCpu = myCpuUsage(pid)
@chetanmeh
chetanmeh / exportedPackageInfo.groovy
Last active August 29, 2015 13:59
Extracts the exported package info from a running OSGi system for list of given bundle name
import groovy.text.SimpleTemplateEngine
import org.osgi.framework.Bundle
import org.osgi.framework.wiring.BundleRevision
import org.osgi.framework.wiring.BundleWire
import org.osgi.framework.wiring.BundleWiring
import org.osgi.service.packageadmin.ExportedPackage
import org.osgi.service.packageadmin.PackageAdmin
PackageAdmin pkgAdmin = osgi.getService(org.osgi.service.packageadmin.PackageAdmin.class)
@chetanmeh
chetanmeh / extractSCRDetails.groovy
Created March 6, 2014 12:12
Script to determine OSGi SCR related details like component pid , classnames etc
import org.apache.sling.commons.osgi.ManifestHeader
def oakBundles = bundleContext.getBundles().findAll {b ->
def name = b.symbolicName
return name.startsWith('org.apache.jackrabbit.oak')
}
oakBundles.each{b ->
def scs = b.headers.get('Service-Component')
if(!scs) return
@chetanmeh
chetanmeh / uninstallOsgiBundles.groovy
Last active August 29, 2015 13:56
Groovy script to remove bundle via JMX
/*
* 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 / classLoaderLeakAnalyzer.js
Last active January 21, 2020 12:52
Following scripts looks for Classloading Leak suspects for OSGi env. This script needs to be executed from the OQL editor of JHat
var debugEnabled = false
var infoEnabled = true
var traceEnabled = false
//Maximum number of live paths to determine when a leak object is found
var maxPathsToFound = 1
//No of object instances after which a progress message
//is logged