Templatizes JVM configuration for Midolman
Change-Id: I798d051fc050d9f5492859c4292d4ae9e6373418
This commit is contained in:
parent
57c5a81201
commit
9a170d618d
4
Gemfile
4
Gemfile
@ -21,11 +21,11 @@ end
|
||||
|
||||
group :system_tests do
|
||||
|
||||
gem 'beaker', '2.45.0'
|
||||
gem 'beaker'
|
||||
if beaker_version = ENV['BEAKER_VERSION']
|
||||
## TODO - Remove hardcoded version as soon as BKR-885 is fixed
|
||||
## https://tickets.puppetlabs.com/browse/BKR-885
|
||||
#gem 'beaker', *location_for(beaker_version)
|
||||
# gem 'beaker', *location_for(beaker_version)
|
||||
end
|
||||
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
|
||||
gem 'beaker-rspec', *location_for(beaker_rspec_version)
|
||||
|
@ -15,7 +15,13 @@ mod 'puppet-neutron',
|
||||
mod 'puppetlabs/inifile'
|
||||
mod 'puppetlabs/apt'
|
||||
mod 'puppetlabs/java'
|
||||
mod 'puppetlabs/tomcat'
|
||||
mod 'puppetlabs/stdlib'
|
||||
mod 'puppetlabs/apache'
|
||||
mod 'puppetlabs/firewall'
|
||||
mod 'deric/zookeeper'
|
||||
mod 'locp/cassandra'
|
||||
mod 'puppetlabs/concat'
|
||||
|
||||
mod 'midonet_openstack',
|
||||
:git => 'https://github.com/midonet/puppet-midonet_openstack',
|
||||
:ref => 'master'
|
||||
|
@ -10,6 +10,9 @@
|
||||
# [*service_name*]
|
||||
# Name of the MN agent service. Default: undef
|
||||
#
|
||||
# [*service_ensure*]
|
||||
# Whether the service should be running or not. Default: undef
|
||||
#
|
||||
# [*agent_config_path*]
|
||||
# Full path to the MN agent config. Default: undef
|
||||
#
|
||||
@ -80,6 +83,7 @@ class midonet::agent (
|
||||
$agent_config_path = undef,
|
||||
$package_ensure = undef,
|
||||
$manage_java = undef,
|
||||
$max_heap_size = undef,
|
||||
$zookeeper_hosts,
|
||||
$controller_host,
|
||||
$metadata_port,
|
||||
@ -104,6 +108,7 @@ class midonet::agent (
|
||||
controller_host => $controller_host,
|
||||
metadata_port => $metadata_port,
|
||||
shared_secret => $shared_secret,
|
||||
max_heap_size => $max_heap_size,
|
||||
require => Class['midonet::agent::install'],
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
class midonet::agent::run (
|
||||
$service_name = 'midolman',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$agent_config_path = '/etc/midolman/midolman.conf',
|
||||
$jvm_config_path = '/etc/midolman/midolman-env.sh',
|
||||
$max_heap_size = '2048M',
|
||||
$zookeeper_hosts,
|
||||
$controller_host,
|
||||
$metadata_port,
|
||||
@ -62,6 +65,14 @@ class midonet::agent::run (
|
||||
before => File['/tmp/mn-agent_config.sh'],
|
||||
}
|
||||
|
||||
file { 'jvm_config':
|
||||
ensure => present,
|
||||
path => $jvm_config_path,
|
||||
content => template('midonet/agent/midolman-env.sh.erb'),
|
||||
require => Package['midolman'],
|
||||
notify => Service['midolman'],
|
||||
}
|
||||
|
||||
service { 'midolman':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
|
@ -42,17 +42,22 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::midonet_cli(
|
||||
class midonet::cli(
|
||||
$api_endpoint='http://127.0.0.1:8181/midonet-api',
|
||||
$username='admin',
|
||||
$password='admin',
|
||||
$tenant_name='admin',
|
||||
) {
|
||||
|
||||
package {'python-midonetclient':
|
||||
ensure => present,
|
||||
if $::osfamily == 'RedHat' {
|
||||
package { 'epel-release':
|
||||
ensure => installed,
|
||||
before => Package['python-midonetclient']
|
||||
}
|
||||
}
|
||||
|
||||
package { 'python-midonetclient': ensure => present, }
|
||||
|
||||
midonet_client_conf {
|
||||
'cli/api_url': value => $api_endpoint;
|
||||
'cli/username': value => $username;
|
@ -75,14 +75,17 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::cluster (
|
||||
$package_name = undef,
|
||||
$service_name = undef,
|
||||
$service_ensure = undef,
|
||||
$service_enable = undef,
|
||||
$cluster_config_path = undef,
|
||||
$cluster_host = undef,
|
||||
$cluster_port = undef,
|
||||
$keystone_port = undef,
|
||||
$package_name = undef,
|
||||
$service_name = undef,
|
||||
$service_ensure = undef,
|
||||
$service_enable = undef,
|
||||
$cluster_config_path = undef,
|
||||
$cluster_jvm_config_path = undef,
|
||||
$cluster_host = undef,
|
||||
$cluster_port = undef,
|
||||
$keystone_port = undef,
|
||||
$max_heap_size = undef,
|
||||
$heap_newsize = undef,
|
||||
$zookeeper_hosts,
|
||||
$cassandra_servers,
|
||||
$cassandra_rep_factor,
|
||||
@ -95,17 +98,20 @@ class midonet::cluster (
|
||||
} ->
|
||||
|
||||
class { 'midonet::cluster::run':
|
||||
service_name => $service_name,
|
||||
service_ensure => $service_ensure,
|
||||
service_enable => $service_enable,
|
||||
cluster_config_path => $cluster_config_path,
|
||||
cluster_host => $cluster_host,
|
||||
cluster_port => $cluster_port,
|
||||
zookeeper_hosts => $zookeeper_hosts,
|
||||
cassandra_servers => $cassandra_servers,
|
||||
cassandra_rep_factor => $cassandra_rep_factor,
|
||||
keystone_admin_token => $keystone_admin_token,
|
||||
keystone_host => $keystone_host,
|
||||
keystone_port => $keystone_port
|
||||
service_name => $service_name,
|
||||
service_ensure => $service_ensure,
|
||||
service_enable => $service_enable,
|
||||
cluster_config_path => $cluster_config_path,
|
||||
cluster_jvm_config_path => $cluster_config_path,
|
||||
cluster_host => $cluster_host,
|
||||
cluster_port => $cluster_port,
|
||||
max_heap_size => $max_heap_size,
|
||||
heap_newsize => $heap_newsize,
|
||||
zookeeper_hosts => $zookeeper_hosts,
|
||||
cassandra_servers => $cassandra_servers,
|
||||
cassandra_rep_factor => $cassandra_rep_factor,
|
||||
keystone_admin_token => $keystone_admin_token,
|
||||
keystone_host => $keystone_host,
|
||||
keystone_port => $keystone_port
|
||||
}
|
||||
}
|
||||
|
@ -23,18 +23,21 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::cluster::run (
|
||||
$service_name = 'midonet-cluster',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$cluster_config_path = '/etc/midonet/midonet.conf',
|
||||
$cluster_host = '0.0.0.0',
|
||||
$cluster_port = '8181',
|
||||
$service_name = 'midonet-cluster',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$cluster_config_path = '/etc/midonet/midonet.conf',
|
||||
$cluster_jvm_config_path = '/etc/midonet-cluster/midonet-cluster-env.sh',
|
||||
$cluster_host = '0.0.0.0',
|
||||
$cluster_port = '8181',
|
||||
$max_heap_size = '2048M',
|
||||
$heap_newsize = '1024M',
|
||||
$zookeeper_hosts,
|
||||
$cassandra_servers,
|
||||
$cassandra_rep_factor,
|
||||
$keystone_admin_token,
|
||||
$keystone_host,
|
||||
$keystone_port = '35357'
|
||||
$keystone_port = '35537'
|
||||
) {
|
||||
|
||||
file { '/tmp/mn-cluster_config.sh':
|
||||
@ -53,6 +56,14 @@ class midonet::cluster::run (
|
||||
before => File['/tmp/mn-cluster_config.sh'],
|
||||
}
|
||||
|
||||
file { 'cluster_jvm_config':
|
||||
ensure => present,
|
||||
path => $cluster_jvm_config_path,
|
||||
content => template('midonet/cluster/midonet-cluster-env.sh.erb'),
|
||||
require => Package['midonet-cluster'],
|
||||
notify => Service['midonet-cluster'],
|
||||
}
|
||||
|
||||
service { 'midonet-cluster':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
|
@ -5,12 +5,16 @@ describe 'midonet::agent class' do
|
||||
# Using puppet_apply as a helper
|
||||
it 'should install the midonet agent without any errors' do
|
||||
pp = <<-EOS
|
||||
class { 'midonet_openstack::role::nsdb':
|
||||
}
|
||||
class { 'midonet::agent':
|
||||
zookeeper_hosts => [ { 'ip' => '127.0.0.1', 'port' => '2181' } ],
|
||||
controller_host => '127.0.0.1',
|
||||
metadata_port => '8181',
|
||||
shared_secret => 'SHARED_SECRET',
|
||||
manage_java => true,
|
||||
metadata_port => '8181',
|
||||
shared_secret => 'SHARED_SECRET',
|
||||
manage_java => false,
|
||||
require => Class['midonet_openstack::role::nsdb'],
|
||||
max_heap_size => "256M"
|
||||
}
|
||||
EOS
|
||||
|
||||
@ -27,11 +31,6 @@ describe 'midonet::agent class' do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
|
||||
# JMX
|
||||
describe port(7200) do
|
||||
it { should be_listening }
|
||||
end
|
||||
end
|
||||
|
||||
context
|
||||
|
@ -1,11 +1,11 @@
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'midonet class' do
|
||||
describe 'midonet::cli class' do
|
||||
context 'without mem' do
|
||||
# Using puppet_apply as a helper
|
||||
it 'should work without any errors' do
|
||||
pp = <<-EOS
|
||||
class {'::midonet::midonet_cli':
|
||||
class {'midonet::cli':
|
||||
api_endpoint => 'http://127.0.0.1:8181/midonet-api',
|
||||
username => 'admin',
|
||||
password => 'admin',
|
||||
@ -27,7 +27,6 @@ describe 'midonet class' do
|
||||
its (:content) { should match /username=admin/ }
|
||||
its (:content) { should match /password=admin/ }
|
||||
its (:content) { should match /project_id=admin/ }
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -10,7 +10,8 @@ describe 'midonet::cluster class' do
|
||||
cassandra_servers => ['127.0.0.1'],
|
||||
cassandra_rep_factor => 1,
|
||||
keystone_admin_token => 'testmido',
|
||||
keystone_host => '127.0.0.1'
|
||||
keystone_host => '127.0.0.1',
|
||||
max_heap_size => '256M',
|
||||
}
|
||||
EOS
|
||||
|
||||
|
@ -9,3 +9,14 @@ HOSTS:
|
||||
CONFIG:
|
||||
type: foss
|
||||
log_level: debug
|
||||
# HOSTS:
|
||||
# centos-server-70-x64:
|
||||
# roles:
|
||||
# - master
|
||||
# platform: el-7-x86_64
|
||||
# box: puppetlabs/centos-7.0-64-nocm
|
||||
# box_url: https://vagrantcloud.com/puppetlabs/centos-7.0-64-nocm
|
||||
# hypervisor: vagrant
|
||||
# CONFIG:
|
||||
# log_level: debug
|
||||
# type: foss
|
||||
|
@ -18,6 +18,7 @@ describe 'midonet::agent::run' do
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_file('agent_config').with_ensure('present') }
|
||||
it { is_expected.to contain_file('jvm_config').with_ensure('present') }
|
||||
it { is_expected.to contain_service('midolman').with_ensure('running') }
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'midonet::midonet_cli' do
|
||||
describe 'midonet::cli' do
|
||||
|
||||
let :pre_condition do
|
||||
"include ::midonet::repository"
|
||||
@ -116,5 +116,6 @@ describe 'midonet::midonet_cli' do
|
||||
end
|
||||
|
||||
it_configures 'set up midonet cli'
|
||||
it { is_expected.to contain_package('epel-release').with_ensure('installed') }
|
||||
end
|
||||
end
|
||||
|
115
templates/agent/midolman-env.sh.erb
Normal file
115
templates/agent/midolman-env.sh.erb
Normal file
@ -0,0 +1,115 @@
|
||||
# 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
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
MIDO_HOME=/usr/share/midolman
|
||||
MIDO_CFG=/etc/midolman
|
||||
MIDO_LOG_DIR=/var/log/midolman/
|
||||
MIDO_DEBUG_PORT=8001
|
||||
JMX_PORT="7200"
|
||||
MIDO_CFG_FILE=midolman.conf
|
||||
QUAGGA_DIR=/var/run/quagga
|
||||
# setting this option will make the agent not run under the watchdog
|
||||
#WATCHDOG_DISABLE=
|
||||
WATCHDOG_TIMEOUT=10
|
||||
|
||||
# Amount of memory to allocate for the JVM heap.
|
||||
MAX_HEAP_SIZE="<%= @max_heap_size %>"
|
||||
|
||||
# Here we create the arguments that will get passed to the jvm when
|
||||
# starting midolman.
|
||||
|
||||
# enable assertions. disabling this in production will give a modest
|
||||
# performance benefit (around 5%).
|
||||
# JVM_OPTS="$JVM_OPTS -ea"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+AggressiveOpts"
|
||||
|
||||
# enable thread priorities, primarily so we can give periodic tasks
|
||||
# a lower priority to avoid interfering with client workload
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
|
||||
# allows lowering thread priority without being root. see
|
||||
# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html
|
||||
JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"
|
||||
|
||||
# min and max heap sizes should be set to the same value to avoid
|
||||
# stop-the-world GC pauses during resize, and so that we can lock the
|
||||
# heap in memory on startup to prevent any of it from being swapped
|
||||
# out.
|
||||
JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
|
||||
JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
|
||||
JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=/var/log/midolman/"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"
|
||||
JVM_OPTS="$JVM_OPTS -XX:OnOutOfMemoryError=\"kill;-3;%p\""
|
||||
|
||||
# Do not use biased locking
|
||||
JVM_OPTS="$JVM_OPTS -XX:-UseBiasedLocking"
|
||||
|
||||
# GC tuning options
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseG1GC"
|
||||
JVM_OPTS="$JVM_OPTS -XX:MaxGCPauseMillis=500"
|
||||
JVM_OPTS="$JVM_OPTS -XX:InitiatingHeapOccupancyPercent=70"
|
||||
JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
|
||||
JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=8"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+ResizeTLAB"
|
||||
JVM_OPTS="$JVM_OPTS -XX:TLABSize=2m"
|
||||
JVM_OPTS="$JVM_OPTS -XX:PretenureSizeThreshold=2m"
|
||||
|
||||
# GC logging options
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCTimeStamps"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintClassHistogram"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
|
||||
JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
|
||||
JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"
|
||||
JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/midolman/gc-`date +%Y%m%d_%H%M%S`.log"
|
||||
|
||||
# uncomment to have Midolman JVM listen for remote debuggers/profilers on port 1414
|
||||
# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
|
||||
|
||||
# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
|
||||
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
|
||||
# comment out this entry to enable IPv6 support).
|
||||
# JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
|
||||
|
||||
# uncomment to disable JMX
|
||||
# JMXDISABLE=true
|
||||
|
||||
# jmx: metrics and administration interface
|
||||
#
|
||||
# add this if you're having trouble connecting:
|
||||
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
|
||||
#
|
||||
# see
|
||||
# http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
|
||||
# for more on configuring JMX through firewalls, etc. (Short version:
|
||||
# get it working with no firewall first.)
|
||||
if [ "x$JMXDISABLE" = "x" ] ; then
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
|
||||
HOSTNAME=`hostname`
|
||||
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=$HOSTNAME"
|
||||
fi
|
||||
|
||||
if [ "$MIDOLMAN_HPROF" = "1" ] ; then
|
||||
DATE=$(date +'%H%M%S')
|
||||
HPROF_FILENAME=${HPROF_FILENAME:-/tmp/midolman-$DATE.hprof}
|
||||
JVM_OPTS="$JVM_OPTS -agentlib:hprof=cpu=samples,depth=100,interval=1,lineno=y,thread=y,file=$HPROF_FILENAME"
|
||||
fi
|
164
templates/cluster/midonet-cluster-env.sh.erb
Normal file
164
templates/cluster/midonet-cluster-env.sh.erb
Normal file
@ -0,0 +1,164 @@
|
||||
# Copyright 2015 Midokura SARL
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# The first existing directory is used for JAVA_HOME if needed.
|
||||
JVM_SEARCH_DIRS="/usr/lib/jvm/java-1.8.0-openjdk-amd64 /usr/lib/jvm/java-8-openjdk-amd64 \
|
||||
/usr/lib/jvm/java-8-oracle /usr/lib/jvm/zulu-8-amd64 \
|
||||
/usr/lib/jvm/jre-1.8.0-openjdk \
|
||||
/usr/lib/jvm/jre-8-oracle-x64 /usr/lib/jvm/jdk-8-oracle-x64"
|
||||
|
||||
check_for_java8() {
|
||||
[ "x" = "x$1" ] && return 1
|
||||
[ -x "$1" ] || return 1
|
||||
$1 -version 2>&1 | grep -q 'version "1.8'
|
||||
}
|
||||
|
||||
if [ -n "`which java`" ]; then
|
||||
java=`which java`
|
||||
# Dereference symlink(s)
|
||||
while true; do
|
||||
if [ -h "$java" ]; then
|
||||
java=`readlink -f "$java"`
|
||||
continue
|
||||
fi
|
||||
break
|
||||
done
|
||||
CUR_JAVA_DIR=$(dirname $java | sed 's!\(/jre\)*/bin!!')
|
||||
JVM_SEARCH_DIRS="$CUR_JAVA_DIR $JVM_SEARCH_DIRS"
|
||||
fi
|
||||
if [ ! -z "$JAVA_HOME" ]; then
|
||||
JVM_SEARCH_DIRS="$JAVA_HOME $JVM_SEARCH_DIRS"
|
||||
fi
|
||||
|
||||
oldopts=$-
|
||||
set +e
|
||||
JAVA_HOME=
|
||||
for jdir in $JVM_SEARCH_DIRS; do
|
||||
check_for_java8 "$jdir/bin/java"
|
||||
if [ $? -eq 0 ]; then
|
||||
JAVA_HOME="$jdir"
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo $oldopts | grep 'e' 2>&1 >/dev/null && set -e
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "No suitable JVM found (at least v1.8 required)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
|
||||
# Override these to set the amount of memory to allocate to the JVM at
|
||||
# start-up. For production use you almost certainly want to adjust
|
||||
# this for your environment. MAX_HEAP_SIZE is the total amount of
|
||||
# memory dedicated to the Java heap; HEAP_NEWSIZE refers to the size
|
||||
# of the young generation. You should either set both MAX_HEAP_SIZE and
|
||||
# HEAP_NEWSIZE or none.
|
||||
MAX_HEAP_SIZE="<%= @max_heap_size %>"
|
||||
HEAP_NEWSIZE="<%= @heap_newsize %>"
|
||||
|
||||
if [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" ]; then
|
||||
echo "please set MAX_HEAP_SIZE and HEAP_NEWSIZE, or none (see midonet-cluster-env.sh)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Specifies the default port over which JMX will be exposed
|
||||
JMX_PORT="7201"
|
||||
|
||||
# Here we create the arguments that will get passed to the JVM
|
||||
|
||||
# enable assertions. disabling this in production will give a modest
|
||||
# performance benefit (around 5%).
|
||||
# JVM_OPTS="$JVM_OPTS -ea"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+AggressiveOpts"
|
||||
|
||||
# enable thread priorities, primarily so we can give periodic tasks
|
||||
# a lower priority to avoid interfering with client workload
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
|
||||
# allows lowering thread priority without being root. see
|
||||
# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html
|
||||
JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"
|
||||
|
||||
# min and max heap sizes should be set to the same value to avoid
|
||||
# stop-the-world GC pauses during resize, and so that we can lock the
|
||||
# heap in memory on startup to prevent any of it from being swapped
|
||||
# out.
|
||||
JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
|
||||
JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
|
||||
JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}"
|
||||
JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=/var/log/midonet-cluster/"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"
|
||||
JVM_OPTS="$JVM_OPTS -XX:OnOutOfMemoryError=\"kill;-3;%p\""
|
||||
|
||||
# GC tuning options
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseG1GC"
|
||||
JVM_OPTS="$JVM_OPTS -XX:MaxGCPauseMillis=500"
|
||||
JVM_OPTS="$JVM_OPTS -XX:InitiatingHeapOccupancyPercent=70"
|
||||
JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
|
||||
JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=8"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+ResizeTLAB"
|
||||
JVM_OPTS="$JVM_OPTS -XX:TLABSize=2m"
|
||||
JVM_OPTS="$JVM_OPTS -XX:PretenureSizeThreshold=2m"
|
||||
|
||||
# GC logging options
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCTimeStamps"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintClassHistogram"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
|
||||
JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
|
||||
JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
|
||||
JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"
|
||||
JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/midonet-cluster/gc-`date +%Y%m%d_%H%M%S`.log"
|
||||
|
||||
# uncomment to have the JVM listen for remote debuggers/profilers on port 1414
|
||||
# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
|
||||
|
||||
# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
|
||||
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
|
||||
# comment out this entry to enable IPv6 support).
|
||||
# JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
|
||||
|
||||
# uncomment to disable JMX
|
||||
# JMXDISABLE=true
|
||||
|
||||
# jmx: metrics and administration interface
|
||||
#
|
||||
# add this if you're having trouble connecting:
|
||||
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
|
||||
#
|
||||
# see
|
||||
# http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
|
||||
# for more on configuring JMX through firewalls, etc. (Short version:
|
||||
# get it working with no firewall first.)
|
||||
if [ "x$JMXDISABLE" = "x" ] ; then
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
|
||||
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
|
||||
HOSTNAME=`hostname`
|
||||
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=$HOSTNAME"
|
||||
fi
|
||||
|
||||
if [ "$MIDOLMAN_HPROF" = "1" ] ; then
|
||||
DATE=$(date +'%H%M%S')
|
||||
HPROF_FILENAME=${HPROF_FILENAME:-/tmp/midonet-cluster-$DATE.hprof}
|
||||
JVM_OPTS="$JVM_OPTS -agentlib:hprof=cpu=samples,depth=100,interval=1,lineno=y,thread=y,file=$HPROF_FILENAME"
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user