-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from rhuss/35-b-properties
Adapted to latest jolokia-opts changes & added karaf images created by fish-pepper
- Loading branch information
Showing
57 changed files
with
1,587 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
README-RHEL.md | ||
.idea | ||
*.iml | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ config: | |
lib: | ||
version: | ||
maven: "3.3.3-1.el7" | ||
jolokia: "1.3.2.redhat-1" | ||
jolokia: "1.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
|
||
# Detected container limits | ||
# If found these are exposed as the following environment variables: | ||
# | ||
# - CONTAINER_MAX_MEMORY | ||
# - CONTAINER_CORE_LIMIT | ||
# | ||
# This script is meant to be sourced. | ||
|
||
ceiling() { | ||
awk -vnumber="$1" -vdiv="$2" ' | ||
function ceiling(x){ | ||
return x%1 ? int(x)+1 : x | ||
} | ||
BEGIN{ | ||
print ceiling(number/div) | ||
} | ||
' | ||
} | ||
|
||
# Based on the cgroup limits, figure out the max number of core we should utilize | ||
core_limit() { | ||
local cpu_period_file="/sys/fs/cgroup/cpu/cpu.cfs_period_us" | ||
local cpu_quota_file="/sys/fs/cgroup/cpu/cpu.cfs_quota_us" | ||
if [ -r "${cpu_period_file}" ]; then | ||
local cpu_period="$(cat ${cpu_period_file})" | ||
|
||
if [ -r "${cpu_quota_file}" ]; then | ||
local cpu_quota="$(cat ${cpu_quota_file})" | ||
# cfs_quota_us == -1 --> no restrictions | ||
if [ "x$cpu_quota" != "x-1" ]; then | ||
ceiling "$cpu_quota" "$cpu_period" | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
max_memory() { | ||
# High number which is the max limit unti which memory is supposed to be | ||
# unbounded. 512 TB for now. | ||
local max_mem_unbounded="562949953421312" | ||
local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes" | ||
if [ -r "${mem_file}" ]; then | ||
local max_mem="$(cat ${mem_file})" | ||
if [ ${max_mem} -lt ${max_mem_unbounded} ]; then | ||
echo "${max_mem}" | ||
fi | ||
fi | ||
} | ||
|
||
local limit="$(core_limit)" | ||
if [ x$limit != x ]; then | ||
export CONTAINER_CORE_LIMIT="$limit" | ||
fi | ||
|
||
local max_mem="$(max_memory)" | ||
if [ x$max_mem != x ]; then | ||
export CONTAINER_MAX_MEMORY="$max_mem" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# Check for debug options and echo them if enabled. Meant to be included by | ||
# a run script. | ||
|
||
debug_options() { | ||
if [ "x${JAVA_ENABLE_DEBUG}" != "x" -o "x${JAVA_DEBUG_ENABLE}" != "x" -o "x${JAVA_DEBUG}" != "x" ]; then | ||
local debug_port=${JAVA_DEBUG_PORT:-5005} | ||
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${debug_port}" | ||
fi | ||
} | ||
|
||
## Echo options, trimming trailing and multiple spaces | ||
echo "$(debug_options)" | awk '$1=$1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/sh | ||
# ================================================================= | ||
# Detect whether running in a container and set appropriate options | ||
# for limiting Java VM resources | ||
# | ||
# Usage: JAVA_OPTIONS="$(java-container-options.sh)" | ||
|
||
# Env Vars respected: | ||
|
||
# JAVA_OPTIONS: Checked for already set options | ||
# JAVA_MAX_MEM_RATIO: Ratio use to calculate a default maximum Memory, in percent. | ||
# E.g. the default value "50" implies that 50% of the Memory | ||
# given to the container is used as the maximum heap memory with | ||
# '-Xmx'. It is a heuristic and should be better backed up with real | ||
# experiments and measurements. | ||
# For a good overviews what tuning options are available --> | ||
# https://youtu.be/Vt4G-pHXfs4 | ||
# https://www.youtube.com/watch?v=w1rZOY5gbvk | ||
# https://vimeo.com/album/4133413/video/181900266 | ||
# Also note that heap is only a small portion of the memory used by a JVM. There are lot | ||
# of other memory areas (metadata, thread, code cache, ...) which addes to the overall | ||
# size. There is no easy solution for this, 50% seems to be are reasonable compromise. | ||
# However, when your container gets killed because of an OOM, then you should tune | ||
# the absolute values | ||
# | ||
|
||
# Check for memory options and calculate a sane default if not given | ||
max_memory() { | ||
# Check whether -Xmx is already given in JAVA_OPTIONS. Then we dont | ||
# do anything here | ||
if echo "${JAVA_OPTIONS}" | grep -q -- "-Xmx"; then | ||
return | ||
fi | ||
|
||
# Check if explicitely disabled | ||
if [ "x$JAVA_MAX_MEM_RATIO" = "x0" ]; then | ||
return | ||
fi | ||
|
||
# Check for the 'real memory size' and caluclate mx from a ratio | ||
# given (default is 50%) | ||
if [ "x$CONTAINER_MAX_MEMORY" != x ]; then | ||
local max_mem="${CONTAINER_MAX_MEMORY}" | ||
local ratio=${JAVA_MAX_MEM_RATIO:-50} | ||
local mx=$(echo "${max_mem} ${ratio} 1048576" | awk '{printf "%d\n" , ($1*$2)/(100*$3) + 0.5}') | ||
echo "-Xmx${mx}m" | ||
fi | ||
} | ||
|
||
# Switch on diagnostics except when switched off | ||
diagnostics() { | ||
if [ "x$JAVA_DIAGNOSTICS" != "x" ]; then | ||
echo "-XX:NativeMemoryTracking=summary -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UnlockDiagnosticVMOptions" | ||
fi | ||
} | ||
|
||
cpu_core_tunning() { | ||
local core_limit="${JAVA_CORE_LIMIT}" | ||
if [ "x$core_limit" = "x0" ]; then | ||
return | ||
fi | ||
|
||
if [ "x$CONTAINER_CORE_LIMIT" != x ]; then | ||
if [ "x$core_limit" = x ]; then | ||
core_limit="${CONTAINER_CORE_LIMIT}" | ||
fi | ||
echo "-XX:ParallelGCThreads=${core_limit} " \ | ||
"-XX:ConcGCThreads=${core_limit} " \ | ||
"-XX:ParallelGCThreads=${core_limit} " \ | ||
"-Djava.util.concurrent.ForkJoinPool.common.parallelism=${core_limit}" | ||
fi | ||
} | ||
|
||
## Echo options, trimming trailing and multiple spaces | ||
echo "$(max_memory) $(diagnostics) $(cpu_core_tunning)" | awk '$1=$1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.