Skip to content

Instantly share code, notes, and snippets.

@olivergondza
olivergondza / effective-pom
Last active June 30, 2017 13:23
foreman release
[INFO] Scanning for projects...
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:2.0 is missing, no dependency information available
[WARNING] Failed to build parent project for org.jenkins-ci.plugins.nodesharing:foreman-node-sharing:hpi:1.2.8-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Node sharing parent
[INFO] Foreman Host Configurator
[INFO] Foreman Node Sharing Plugin
Downloading: http://repo.jenkins-ci.org/public/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml
Mar 30, 2017 11:00:07 AM hudson.ExpressionFactory2$JexlExpression evaluate
WARNING: Caught exception evaluating: it.writeLogTo(offset,output) in /hudson/job/job-name/14/consoleFull. Reason: java.io.IOException
java.io.IOException
at org.apache.commons.jelly.XMLOutput$1.write(XMLOutput.java:230)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2002)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1886)
at hudson.model.Run.writeLogTo(Run.java:1387)
@olivergondza
olivergondza / profiler.jfc
Last active March 16, 2017 21:14
Java Flight Recorder profiler
<!-- Run as `-DargLine="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=samplethreads=true -XX:StartFlightRecording=dumponexit=true,filename="(pwd)"/out.jfr,settings=$HOME/profiler.jfc"` -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration version="1.0" name="profiler" description="These settings were used to start the recording &apos;flight_recording_180121comintellijideaMain1101.jfr&apos;." provider="Oracle">
<producer uri="http://www.oracle.com/hotspot/jvm/" label="Oracle JDK">
<event path="java/statistics/thread_allocation">
<setting name="enabled">true</setting>
<setting name="period">everyChunk</setting>
</event>
@olivergondza
olivergondza / gist:5b8b2fd0fd62c49b7849
Created August 13, 2015 08:47
openjdk "1.7.0_85" deadlock
Found one Java-level deadlock:
=============================
"Loading job Upstream":
waiting to lock monitor 0x00007f63c8013608 (object 0x0000000785f05408, a java.lang.Class),
which is held by "Loading job System"
"Loading job System":
waiting to lock monitor 0x00007f63c80168e8 (object 0x00000007854c22a8, a java.lang.Class),
which is held by "Loading job Upstream"
Java stack information for the threads listed above:
lr = D.load.threaddump(D.args[0]).threads
rr = D.load.threaddump(D.args[1]).threads
lhs = lr.toSet().collectEntries { [it.nid, it] };
rhs = rr.toSet().collectEntries { [it.nid, it] };
/*
println "New:"
rhs.each { nid, thread ->
if (lhs[nid] == null) {
println thread.header;
@olivergondza
olivergondza / gist:ba0d967c5f5616f6baf5
Created June 7, 2015 16:28
Detect non-static classes in java code
for f in `find $1 -iname *.java`; do
out=`grep "class\ " $f | grep -v -e "[[:space:]]*\*" -e "[[:space:]]//" | sed '1d' | grep -v -e static`
if [ $? == 0 ]; then
echo $f
echo $out | grep --color=auto class
fi
done
@olivergondza
olivergondza / gist:7ff7350ccc1d97aa3fee
Created April 30, 2015 10:29
True zip can not be interrupted while in Stream.cat
"A thread" prio=10 tid=47477949280256 nid=14753
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x5f77a1e28> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
at de.schlichtherle.truezip.io.Streams.cat(Streams.java:210)
at de.schlichtherle.truezip.io.Streams.copy(Streams.java:71)
at de.schlichtherle.truezip.file.TFile.cp(TFile.java:2744)
at de.schlichtherle.truezip.file.TFile.cp(TFile.java:2817)

DRAFT: Threaddump analysis with Dumpling

Final version

Dumpling CLI is fully scriptable, console based tool for threaddump analysis. It is GitHub hosted project available under the terms of MIT license. It values maximal flexibility, reliability and convenience. How can it help you?

Installation

Dumpling CLI is distributed in a form of a self contained jar file hosted on OSS Sonatype maven repository. Preferred way to install it is using dumpling.sh script:

@olivergondza
olivergondza / query.groovy
Last active August 29, 2015 14:15
Dumpling query to group threads by locks involved - not sure it is of any use
waitingTo = [:]
waitingOn = [:]
acquired = [:]
D.runtime.threads.each {
it.acquiredLocks.each { al ->
if (acquired[al]) {
acquired[al] << it;
} else {
acquired[al] = [it];
@olivergondza
olivergondza / jps-monitor.sh
Last active August 29, 2015 14:12
jps-monitor
#!/bin/sh
# Make periodic snapshots of running java processes.
#
# ./jps-monitor.sh jmap -heap
# ./jps-monitor.sh jmap -heap %s # PID of monitored process will be used for %s
target="jps-monitor/"
rm -rf $target
mkdir -p $target