Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
chetanmeh / deleteActions.scala
Created October 1, 2018 14:13
Delete actions concurrently
/*
* 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 / openwhisk-controller-deps.txt
Created April 27, 2018 08:24
Dependency tree for OpenWhisk Controller
------------------------------------------------------------
Project :core:controller
------------------------------------------------------------
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.scala-lang:scala-library:2.11.11 -> 2.11.12
+--- com.lightbend.akka.management:akka-management-cluster-bootstrap_2.11:0.11.0
| +--- org.scala-lang:scala-library:2.11.11 -> 2.11.12
| +--- com.lightbend.akka.management:akka-management_2.11:0.11.0
| | +--- org.scala-lang:scala-library:2.11.11 -> 2.11.12
@chetanmeh
chetanmeh / createOWRunConfigs.groovy
Last active February 15, 2018 19:25
Launch OpenWhisk controller in Intellij
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def owHome = System.getenv("OPENWHISK_HOME")
assert owHome : "Cannot determine OpenWhisk home via environment variable 'OPENWHISK_HOME'"
def containerNames = 'docker ps --format {{.Names}}'.execute().text.split("\n")
def transformEnvScript = "/bin/bash $owHome/common/scala/transformEnvironment.sh"
def text = '''<component name="ProjectRunConfigurationManager">
@chetanmeh
chetanmeh / analyzeOsgiMetadata.groovy
Created October 5, 2017 19:03
Script to analyze the OSGi metadata specifically Declarative Services and Metatype xml and generates a json report. Which can be diff for changes. See OAK-6741 for usage
import groovy.json.JsonOutput
import groovy.time.TimeCategory
import groovy.transform.Field
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import groovy.json.JsonSlurper
import org.json.JSONObject
@Grab(group='org.json', module='json', version='20140107')
import org.json.XML
@chetanmeh
chetanmeh / recoverMissingRev.groovy
Last active September 18, 2017 15:27
Last Rev Recovery
import com.google.common.base.Stopwatch
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.slf4j.Logger
import org.slf4j.LoggerFactory
NodeStore ns = getStore()
def agent = ns.getLastRevRecoveryAgent()
def lastRevUtil = agent.missingLastRevUtil
/*
* 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
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.plugins.segment.SegmentBlob
import org.apache.jackrabbit.oak.spi.state.NodeState
def countNodes(NodeState n, deep = false, String path = "/", Integer flush = 50000, AtomicInteger count = new AtomicInteger(0), AtomicInteger binaries = new AtomicInteger(0), root = true) {
if(root) {
println "Counting nodes in tree ${path}"
}
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.NodeBuilder as JNodeBuilder
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.apache.jackrabbit.util.ISO8601
import java.util.concurrent.TimeUnit
NodeStore store = getStore()
package hpe
import org.apache.jackrabbit.oak.api.Blob
import org.apache.jackrabbit.oak.api.PropertyState
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeBuilder
import org.apache.jackrabbit.oak.spi.state.NodeState
package felixconsole
import com.google.common.base.Charsets
import com.google.common.hash.Hashing
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.apache.commons.io.FileUtils
import org.apache.jackrabbit.core.data.DataIdentifier
import org.apache.jackrabbit.core.data.DataRecord
import org.apache.jackrabbit.core.data.FileDataStore