#!/usr/bin/env bash
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * 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.
# */

#
# Set hbase-specific environment variables here.
#
# Created by Chef -- changes will be overwritten
#

# a fence, because bin/hadoop sources this like four times
this_file="`readlink -f $BASH_SOURCE`"
if [ "$HBASE_ENV_SOURCED" == "" ] || [ "$HBASE_ENV_SOURCED" != "$this_file" ] ; then

# The java implementation to use.  Java 1.6 required.
# export JAVA_HOME=/usr/java/jdk1.6.0/

# Extra Java CLASSPATH elements.  Optional.
# export HBASE_CLASSPATH=

# The maximum amount of heap to use, in MB. Default is 1000.
# export HBASE_HEAPSIZE=1000

# Extra Java runtime options.
# Below are what we set by default.  May only work with SUN JVM.
# For more on why as well as other possible settings,
# see http://wiki.apache.org/hadoop/PerformanceTuning
export HBASE_OPTS="$HBASE_OPTS -ea -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true"

# JVM options
export             HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -Xms<%= @hbase[:master      ][:java_heap_size_max] %> -Xmx<%= @hbase[:master      ][:java_heap_size_max] %> -XX:NewSize=<%= @hbase[:master      ][:java_heap_size_new] %> -XX:MaxNewSize=<%= @hbase[:master      ][:java_heap_size_new] %>"
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -Xms<%= @hbase[:regionserver][:java_heap_size_max] %> -Xmx<%= @hbase[:regionserver][:java_heap_size_max] %> -XX:NewSize=<%= @hbase[:regionserver][:java_heap_size_new] %> -XX:MaxNewSize=<%= @hbase[:regionserver][:java_heap_size_new] %>"

# GC options
export             HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS  <%= @hbase[:master      ][:gc_tuning_opts] %> <%= @hbase[:master      ][:gc_log_opts] %> -Xloggc:/var/log/hbase/hbase-master-gc.log"
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS  <%= @hbase[:regionserver][:gc_tuning_opts] %> <%= @hbase[:regionserver][:gc_log_opts] %> -Xloggc:/var/log/hbase/hbase-regionserver-gc.log"

# Enable JMX exporting. See jmxremote.password and jmxremote.access in
# $JRE_HOME/lib/management to configure remote password access.  More details
# at: http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
#
# You should set the java.rmi.server.hostname to the *public* hostname if you
# want remote access; you'll need to use security groups to open up the high end
# of all ports (not just this one).
#
export HBASE_JMX_BASE="-Djava.rmi.server.hostname=<%= @hbase[:jmx_dash_addr] %> -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

# JMX port
export             HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=<%= @hbase[:master      ][:jmx_dash_port] %>"
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=<%= @hbase[:regionserver][:jmx_dash_port] %>"
export             HBASE_THRIFT_OPTS="$HBASE_THRIFT_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=<%= @hbase[:zookeeper   ][:jmx_dash_port] %>"
export       HBASE_ZOOKEEPER_OPTS="$HBASE_ZOOKEEPER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=<%= @hbase[:thrift      ][:jmx_dash_port] %>"
export                 HBASE_REST_OPTS="$HBASE_REST_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=<%= @hbase[:stargate    ][:jmx_dash_port] %>"

# File naming hosts on which HRegionServers will run.  $HBASE_HOME/conf/regionservers by default.
# export HBASE_REGIONSERVERS=${HBASE_HOME}/conf/regionservers

# Extra ssh options.  Empty by default.
# export HBASE_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HBASE_CONF_DIR -o StrictHostKeyChecking=no"

# The scheduling priority for daemon processes.  See 'man nice'.
# export HBASE_NICENESS=10

# Seconds to sleep between slave commands.  Unset by default.  This
# can be useful in large clusters, where, e.g., slave rsyncs can
# otherwise arrive faster than the master can service them.
# export HBASE_SLAVE_SLEEP=0.1

export HBASE_NODENAME="<%= node.name.gsub(/[^\w\-]+/, '') %>"

# end of double-run fence
export HBASE_ENV_SOURCED="$this_file"
fi
