Skip to content

Commit

Permalink
HDDS-3173. Provide better default JVM options
Browse files Browse the repository at this point in the history
Closes #710
  • Loading branch information
elek committed Apr 3, 2020
1 parent 63fde40 commit 1ebadbe
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hadoop-ozone/dist/src/shell/hdds/hadoop-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,21 @@ function hadoop_translate_cygwin_path
fi
}

## @description Adds default GC parameters
## @description Only for server components and only if no other -XX parameters
## @description are set
## @audience private
## @stability evolving
## @replaceable yes
function hadoop_add_default_gc_opts
{
if [[ "${HADOOP_SUBCMD_SUPPORTDAEMONIZATION}" == true ]]; then
if [[ ! "$HADOOP_OPTS" =~ "-XX" ]] ; then
hadoop_error "No '-XX:...' jvm parameters are used. Adding safer GC settings to the HADOOP_OPTS"
HADOOP_OPTS="${HADOOP_OPTS} -XX:ParallelGCThreads=8 -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled"
fi
fi
}
## @description Adds the HADOOP_CLIENT_OPTS variable to
## @description HADOOP_OPTS if HADOOP_SUBCMD_SUPPORTDAEMONIZATION is false
## @audience public
Expand Down
2 changes: 2 additions & 0 deletions hadoop-ozone/dist/src/shell/ozone/ozone
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ IFS=$OIFS

hadoop_add_client_opts

hadoop_add_default_gc_opts

if [[ ${HADOOP_WORKER_MODE} = true ]]; then
hadoop_common_worker_mode_execute "${HADOOP_HDFS_HOME}/bin/ozone" "${HADOOP_USER_PARAMS[@]}"
exit $?
Expand Down
44 changes: 44 additions & 0 deletions hadoop-ozone/dist/src/test/shell/gc_opts.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# 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.



#
# Can be executed with bats (https://github.com/bats-core/bats-core)
# bats gc_opts.bats (FROM THE CURRENT DIRECTORY)
#

source ../../shell/hdds/hadoop-functions.sh
@test "Setting Hadoop GC parameters: add GC params for server" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=true
export HADOOP_OPTS="Test"
hadoop_add_default_gc_opts
[[ "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}

@test "Setting Hadoop GC parameters: disabled for client" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=false
export HADOOP_OPTS="Test"
hadoop_add_default_gc_opts
[[ ! "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}

@test "Setting Hadoop GC parameters: disabled if GC params are customized" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=true
export HADOOP_OPTS="-XX:++UseG1GC -Xmx512"
hadoop_add_default_gc_opts
[[ ! "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}

0 comments on commit 1ebadbe

Please sign in to comment.