Skip to content

Commit

Permalink
Merge pull request #365 from chrismoos/fix_node_attr_syntax
Browse files Browse the repository at this point in the history
Switch to standardized node attribute syntax. Fixes #350
  • Loading branch information
michaelklishin authored Dec 25, 2017
2 parents e3b51e9 + 9cfc2ac commit a97d12c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion templates/default/cqlsh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# This file is managed by Chef.
# Do NOT modify this file directly.
#
exec <%= node.cassandra.bin_dir %>/cqlsh "$@"
exec <%= node['cassandra']['bin_dir'] %>/cqlsh "$@"
20 changes: 10 additions & 10 deletions templates/default/debian.cassandra.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ DESC="Cassandra"
NAME=cassandra
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
export CASSANDRA_HOME=<%= node.cassandra.installation_dir %>
export CASSANDRA_CONF=<%= node.cassandra.conf_dir %>
USER=<%= node.cassandra.user %>
GROUP=<%= node.cassandra.group %>
export CASSANDRA_HOME=<%= node['cassandra']['installation_dir'] %>
export CASSANDRA_CONF=<%= node['cassandra']['conf_dir'] %>
USER=<%= node['cassandra']['user'] %>
GROUP=<%= node['cassandra']['group'] %>
WAIT_FOR_START=10
FD_LIMIT=<%= node.cassandra.limits.nofile %>
FD_LIMIT=<%= node['cassandra']['limits']['nofile'] %>
NODETOOL=$CASSANDRA_HOME/bin/nodetool

[ -e $CASSANDRA_HOME/lib/apache-cassandra-<%= node.cassandra.version %>.jar ] || exit 0
[ -e $CASSANDRA_HOME/lib/apache-cassandra-<%= node['cassandra']['version'] %>.jar ] || exit 0
[ -e $CASSANDRA_CONF/cassandra.yaml ] || exit 0
[ -e $CASSANDRA_CONF/cassandra-env.sh ] || exit 0
[ -e $CASSANDRA_HOME/bin/cassandra ] || exit 0
Expand Down Expand Up @@ -76,7 +76,7 @@ do_start()
--chuid $USER:$GROUP \
--exec /bin/bash \
--pidfile $PIDFILE \
-- -c "$CASSANDRA_HOME/bin/cassandra -p $PIDFILE > <%= node.cassandra.log_dir %>/boot.log 2>&1"
-- -c "$CASSANDRA_HOME/bin/cassandra -p $PIDFILE > <%= node['cassandra']['log_dir'] %>/boot.log 2>&1"

is_running && return 0

Expand All @@ -99,23 +99,23 @@ do_stop()

# Disable Thrift, Mark node down for client
echo "executing nodetool disablethrift .."
$NODETOOL -h <%=node.ipaddress%> disablethrift
$NODETOOL -h <%=node['ipaddress']%> disablethrift
[ $? -eq 0 ] || {
echo "failed to execute disablethrift .."
}
sleep 2

# Disabling Gossip, Mark node down for cluster
echo "executing nodetool disablegossip .."
$NODETOOL -h <%=node.ipaddress%> disablegossip
$NODETOOL -h <%=node['ipaddress']%> disablegossip
[ $? -eq 0 ] || {
echo "failed to execute disablegossip .."
}
sleep 2

# Drain node for existing connections, Always safe even takes long time
echo "executing nodetool drain .."
$NODETOOL -h <%=node.ipaddress%> drain
$NODETOOL -h <%=node['ipaddress']%> drain
[ $? -eq 0 ] || {
echo "failed to execute drain .."
}
Expand Down
2 changes: 1 addition & 1 deletion templates/default/jvm.options.erb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
#-Xms4G
#-Xmx4G
<% if node['cassandra']['jvm'] && node['cassandra']['jvm']['xms'] -%>
# (set via node.cassandra.jvm.xms)
# (set via node['cassandra']['jvm']['xms'])
-Xms<%= node['cassandra']['jvm']['xms'] %>
<% end -%>
<% if node['cassandra']['jvm'] && node['cassandra']['jvm']['xmx'] -%>
Expand Down
6 changes: 3 additions & 3 deletions templates/default/log4j-server.properties.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# (%l is slower.)

# output messages into a rolling log file as well as stdout
log4j.rootLogger=<%= node.cassandra.rootlogger %>
log4j.rootLogger=<%= node['cassandra']['rootlogger'] %>

# stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
Expand All @@ -36,7 +36,7 @@ log4j.appender.R.maxBackupIndex=50
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
# Edit the next line to point to your logs directory
log4j.appender.R.File=<%= node.cassandra.log_dir %>/system.log
log4j.appender.R.File=<%= node['cassandra']['log_dir'] %>/system.log

# Application logging options
#log4j.logger.org.apache.cassandra=DEBUG
Expand All @@ -46,7 +46,7 @@ log4j.appender.R.File=<%= node.cassandra.log_dir %>/system.log
# Adding this to avoid thrift logging disconnect errors.
log4j.logger.org.apache.thrift.server.TNonblockingServer=ERROR

<% node.cassandra.log4j.each do |key, value| %>
<% node['cassandra']['log4j'].each do |key, value| %>
<%= key %>=<%= value %>
<% end %>

3 changes: 0 additions & 3 deletions templates/default/logback.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,4 @@

<logger name="org.apache.cassandra" level="INFO"/>
<logger name="com.thinkaurelius.thrift" level="ERROR"/>
<% node['cassandra']['logback']['override_loggers'].each do |logger, level| %>
<logger name="<%= logger %>" level="<%= level %>"/>
<% end %>
</configuration>
28 changes: 14 additions & 14 deletions templates/default/rhel.cassandra.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
# Do NOT modify this file directly.
#
# chkconfig: 345 20 80
# description: <%=node.cassandra.service_name%> daemon
# processname: <%=node.cassandra.service_name%>
# description: <%=node['cassandra']['service_name']%> daemon
# processname: <%=node['cassandra']['service_name']%>

export CASSANDRA_HOME=<%=node.cassandra.installation_dir%>
export CASSANDRA_CONF=<%=node.cassandra.conf_dir%>
export CASSANDRA_HOME=<%=node['cassandra']['installation_dir']%>
export CASSANDRA_CONF=<%=node['cassandra']['conf_dir']%>
NODETOOL=$CASSANDRA_HOME/bin/nodetool

SERVICE_USER=<%=node.cassandra.user%>
SERVICE_GROUP=<%=node.cassandra.group%>
SERVICE_USER=<%=node['cassandra']['user']%>
SERVICE_GROUP=<%=node['cassandra']['group']%>

PROGRAM=<%=node.cassandra.service_name%>
SERVICE_PID_FILE=<%=node.cassandra.pid_dir%>/$PROGRAM.pid
PROGRAM=<%=node['cassandra']['service_name']%>
SERVICE_PID_FILE=<%=node['cassandra']['pid_dir']%>/$PROGRAM.pid

SERVICE_EXEC=$CASSANDRA_HOME/bin/cassandra

SERVICE_LOG_FILE=<%=node.cassandra.log_dir%>/boot.log
SERVICE_LOG_FILE=<%=node['cassandra']['log_dir']%>/boot.log
SERVICE_LOCK=/var/lock/subsys/$PROGRAM

WAIT_FOR_START=10
Expand All @@ -34,8 +34,8 @@ WAIT_FOR_START=10
exit 1
}

[ -e $CASSANDRA_HOME/lib/apache-cassandra-<%=node.cassandra.version%>.jar ] || {
echo "$PROGRAM missing $CASSANDRA_HOME/lib/apache-cassandra-<%=node.cassandra.version%>.jar [failed]"
[ -e $CASSANDRA_HOME/lib/apache-cassandra-<%=node['cassandra']['version']%>.jar ] || {
echo "$PROGRAM missing $CASSANDRA_HOME/lib/apache-cassandra-<%=node['cassandra']['version']%>.jar [failed]"
exit 1
}

Expand Down Expand Up @@ -106,21 +106,21 @@ service_stop() {
service_stop_pre_check

echo "executing nodetool disablethrift .."
$NODETOOL -h <%=node.ipaddress%> disablethrift
$NODETOOL -h <%=node['ipaddress']%> disablethrift
[ $? -eq 0 ] || {
echo "failed to execute disablethrift .."
}
sleep 3

echo "executing nodetool disablegossip .."
$NODETOOL -h <%=node.ipaddress%> disablegossip
$NODETOOL -h <%=node['ipaddress']%> disablegossip
[ $? -eq 0 ] || {
echo "failed to execute disablegossip .."
}
sleep 3

echo "executing nodetool drain .."
$NODETOOL -h <%=node.ipaddress%> drain
$NODETOOL -h <%=node['ipaddress']%> drain
[ $? -eq 0 ] || {
echo "failed to execute drain .."
}
Expand Down

0 comments on commit a97d12c

Please sign in to comment.