78 lines
2.7 KiB
YAML
78 lines
2.7 KiB
YAML
# 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.
|
|
|
|
Namespaces:
|
|
=: com.example.apache
|
|
std: io.murano
|
|
res: io.murano.resources
|
|
sys: io.murano.system
|
|
|
|
|
|
Name: CassandraCluster
|
|
|
|
Extends: std:Application
|
|
|
|
Properties:
|
|
name:
|
|
Contract: $.string().notNull()
|
|
|
|
seedNodes:
|
|
Contract: [$.class(CassandraNode).notNull()]
|
|
|
|
regularNodes:
|
|
Contract: [$.class(CassandraNode).notNull()]
|
|
|
|
Methods:
|
|
.init:
|
|
Body:
|
|
- $._environment: $.find(std:Environment).require()
|
|
|
|
deploy:
|
|
Body:
|
|
- If: not $.getAttr(deployed, false)
|
|
Then:
|
|
- $._environment.reporter.report($this, 'Creating VMs for Cassandra cluster')
|
|
|
|
# Spawn VMs in parallel
|
|
- Parallel:
|
|
- $.seedNodes.pselect($.spawnInstance())
|
|
- $.regularNodes.pselect($.spawnInstance())
|
|
|
|
# Collect internal IPs of seed nodes
|
|
- $seedNodesAsString: $.seedNodes.select($.getInternalIp()).join(',')
|
|
|
|
# Deploy Cassandra with default conf
|
|
- Parallel:
|
|
- $.seedNodes.pselect($.deployInstance())
|
|
- $.regularNodes.pselect($.deployInstance())
|
|
|
|
- $msg: format('Deployed {0} seed nodes and {1} usual nodes', len($.seedNodes), len($.regularNodes))
|
|
- $._environment.reporter.report($this, $msg)
|
|
|
|
# Update configuration (identical on all nodes)
|
|
- Parallel:
|
|
- $.seedNodes.pselect($.updateConfiguration($this.name, $seedNodesAsString))
|
|
- $.regularNodes.pselect($.updateConfiguration($this.name, $seedNodesAsString))
|
|
|
|
# Restart nodes for changes to take an effect
|
|
- $msg: format('Restarting all nodes in the cluster')
|
|
- $._environment.reporter.report($this, $msg)
|
|
- $.seedNodes.pselect($.restartCassandra(delay => 1))
|
|
|
|
# No parallel there because usual nodes have to be started one by one
|
|
# Uses delay of restart for usual nodes to give seed nodes time on slow envs
|
|
- $.regularNodes.select($.restartCassandra(delay => 120))
|
|
|
|
- $._environment.reporter.report($this, 'Cassandra cluster is deployed')
|
|
- $._environment.reporter.report($this, 'Log in to any instance and use "nodetool status" to check')
|
|
- $.setAttr(deployed, true)
|