[Cassandra] Use simple software configuration

Change-Id: Ia838a0ba8d72f9446439bc1992baf807d5917570
Partially-Implements: bp refactor-apps-scripts
This commit is contained in:
Dmytro Dovbii 2016-04-01 14:17:17 +03:00
parent 3b51222b09
commit e022463cf5
8 changed files with 17 additions and 119 deletions

View File

@ -48,7 +48,7 @@ Methods:
- $.regularNodes.pselect($.spawnInstance())
# Collect internal IPs of seed nodes
- $seedNodesAsString: join(',', $.seedNodes.select($.getInternalIp()))
- $seedNodesAsString: $.seedNodes.select($.getInternalIp()).join(',')
# Deploy Cassandra with default conf
- Parallel:

View File

@ -15,7 +15,7 @@ Namespaces:
std: io.murano
res: io.murano.resources
sys: io.murano.system
conf: io.murano.configuration
Name: CassandraNode
@ -29,7 +29,6 @@ Methods:
.init:
Body:
- $._environment: $.find(std:Environment).require()
- $.resources: new(sys:Resources)
updateConfiguration:
Arguments:
@ -41,14 +40,16 @@ Methods:
Body:
# Listen address is internal (so it gets resolved by node itself correctly)
- $listenAddress: $.instance.ipAddresses[0]
- $template: $.resources.yaml('UpdateCassandraYaml.template').bind(dict(
clusterName => $clusterName,
seedNodes => $seedNodes,
listenAddress => $listenAddress
))
- $replacements:
"%LISTEN_ADDRESS%": $listenAddress
"%CLUSTER_NAME%": $clusterName
"%SEED_NODES%": $seedNodes
- $file: sys:Resources.string('updateCassandraYaml.sh').replace($replacements)
- conf:Linux.runCommand($.instance.agent, $file)
- $msg: format('Updating Cassandra configuration at node "{0}"', $listenAddress)
- $._environment.reporter.report($this, $msg)
- $.instance.agent.call($template, $.resources)
configureSecurityGroups:
@ -97,8 +98,8 @@ Methods:
Then:
- $address: $.instance.ipAddresses[0]
- $._environment.reporter.report($this, 'Deploying Cassandra node "{0}"'.format($address))
- $template: $.resources.yaml('DeployCassandra.template')
- $.instance.agent.call($template, $.resources)
- $file: sys:Resources.string('deployCassandra.sh')
- conf:Linux.runCommand($.instance.agent, $file)
- $.setAttr(deployed, true)
getInternalIp:
@ -113,7 +114,5 @@ Methods:
Body:
- $msg: format('Restarting Cassandra node "{0}"', $.instance.name)
- $._environment.reporter.report($this, $msg)
- $template: $.resources.yaml('RestartCassandra.template').bind(dict(
delay => $delay
))
- $.instance.agent.call($template, $.resources)
- $command: format('sleep {0}; sudo service cassandra restart', $delay)
- conf:Linux.runCommand($.instance.agent, $command)

View File

@ -1,31 +0,0 @@
# Licensed 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.
FormatVersion: 2.0.0
Version: 1.0.0
Name: Deploy Cassandra
Parameters:
appName: $appName
Body: |
return deploy(args.appName).stdout
Scripts:
deploy:
Type: Application
Version: 1.0.0
EntryPoint: deployCassandra.sh
Files: []
Options:
captureStdout: false
captureStderr: true

View File

@ -1,32 +0,0 @@
# Licensed 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.
FormatVersion: 2.0.0
Version: 1.0.0
Name: Restart Cassandra
Parameters:
delay: $delay
Body: |
restart('{0}'.format(args.delay))
Scripts:
restart:
Type: Application
Version: 1.0.0
EntryPoint: restartCassandra.sh
Files: []
Options:
captureStdout: true
captureStderr: false
verifyExitcode: false

View File

@ -1,34 +0,0 @@
# Licensed 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.
FormatVersion: 2.0.0
Version: 1.0.0
Name: Update Cassandra Yaml
Parameters:
clusterName: $clusterName
seedNodes: $seedNodes
listenAddress: $listenAddress
Body: |
configure('{0} {1} {2}'.format(args.clusterName, args.seedNodes, args.listenAddress))
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: updateCassandraYaml.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -11,21 +11,17 @@
# License for the specific language governing permissions and limitations
# under the License.
CLUSTER_NAME="$1"
SEED_NODES="$2"
LISTEN_ADDRESS="$3"
## Configure Cassandra to use seed nodes
# Set cluster name
sed -e "s/cluster_name:.*/cluster_name: \'$CLUSTER_NAME\'/g" -i /etc/cassandra/cassandra.yaml
sed -e "s/cluster_name:.*/cluster_name: \'%CLUSTER_NAME%\'/g" -i /etc/cassandra/cassandra.yaml
# Seed provider class name
sed -e "s/- class_name:.*/- class_name: org.apache.cassandra.locator.SimpleSeedProvider/g" -i /etc/cassandra/cassandra.yaml
# Set seed nodes - nodes used to bootstrap other nodes
sed -e "s/seeds:.*/seeds: \"$SEED_NODES\"/g" -i /etc/cassandra/cassandra.yaml
# Set listen address and endpoint snitch class
sed -e "s/listen_address:.*/listen_address: $LISTEN_ADDRESS/g" -i /etc/cassandra/cassandra.yaml
sed -e "s/listen_address:.*/listen_address: %LISTEN_ADDRESS%/g" -i /etc/cassandra/cassandra.yaml
sed -e "s/endpoint_snitch:.*/endpoint_snitch: GossipingPropertyFileSnitch/g" -i /etc/cassandra/cassandra.yaml
# Set RPC address
sed -e "s/^rpc_address:.*/rpc_address: 0.0.0.0/g" -i /etc/cassandra/cassandra.yaml
sed -e "s/#\s*broadcast_rpc_address:.*/broadcast_rpc_address: $LISTEN_ADDRESS/g" -i /etc/cassandra/cassandra.yaml
sed -e "s/#\s*broadcast_rpc_address:.*/broadcast_rpc_address: %LISTEN_ADDRESS%/g" -i /etc/cassandra/cassandra.yaml