-
Notifications
You must be signed in to change notification settings - Fork 2
/
cassandra-catalog.bom
198 lines (171 loc) · 7.19 KB
/
cassandra-catalog.bom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
brooklyn.catalog:
version: 0.1.4-SNAPSHOT
publish:
description: |
Entities for running the Cassandra project in Apache Brooklyn.
license_code: Apache-2.0
icon_url: https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Cassandra_logo.svg/200px-Cassandra_logo.svg.png
items:
- id: cassandra-cluster-template
description: |
A cluster of Cassandra nodes
name: "Cassandra cluster"
iconUrl: classpath:///cassandra-logo.png
itemType: template
item:
services:
- type: cassandra-cluster-application
name: "Cassandra cluster"
- id: cassandra-cluster-application
itemType: entity
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
brooklyn.parameters:
- name: cassandra.archive.url
description: |
The URL for the Cassandra binary distribution archive
type: string
default: http://archive.apache.org/dist/cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz
constraints:
- required
- name: cassandra.cluster.name
description: |
The name of the Cassandra cluster (optional)
type: string
- name: cassandra.cluster.nodes
description: |
The number of nodes in the cluster
type: integer
default: 2
constraints:
- required
brooklyn.config:
cassandra.archive.url: http://archive.apache.org/dist/cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz
cassandra.cluster.nodes: 2
brooklyn.children:
- type: cassandra-cluster
name: "Cassandra cluster"
id: cassandra-cluster
- id: cassandra-node
description: A Cassandra node
itemType: entity
item:
type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
name: Cassandra node
brooklyn.config:
cql.port: 9042
gossip.port: 7000
jmx.port: 7199
provisioning.properties:
minRam: 4g
shell.env:
C_URL: $brooklyn:config("cassandra.archive.url")
C_CLUSTER_NAME: $brooklyn:config("cassandra.cluster.name")
IS_FIRST_NODE: $brooklyn:config("is.first.node")
FIRST_NODE_ADDRESS: $brooklyn:config("cassandra.first.node.address")
CLUSTER_INDEX: $brooklyn:config("cluster.index")
HOST_ADDRESS: $brooklyn:attributeWhenReady("host.subnet.address")
pre.install.command: |
which apt-get || (
sudo yum install -y patch git
sudo yum groupinstall -y "Development tools"
sudo yum install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
sudo ln -s ~/.pyenv/bin/pyenv /usr/local/bin/pyenv
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
echo 'eval "$(pyenv init -)" ; eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)" ; eval "$(pyenv virtualenv-init -)"' >> ~/.bash_rc
pyenv install 2.7.8
pyenv local 2.7.8
)
install.command: |
which yum && (
sudo yum -y install wget java-1.8.0-openjdk
)
which apt-get && (
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt-get update -y
sudo apt-get install -y --allow-unauthenticated wget openjdk-8-jdk
)
wget "$C_URL"
tar zxf *z
mv *cassandra*[^z] cassandra
launch.command: |
# configure Cassandra
config_file=$INSTALL_DIR/cassandra/conf/cassandra.yaml
seeds=${FIRST_NODE_ADDRESS:-$HOST_ADDRESS}
sed -i -e "s|- seeds: \"127.0.0.1\"|- seeds: \"${seeds}\"|" $config_file
sed -i -e "s|listen_address: localhost|listen_address: $HOST_ADDRESS|" $config_file
sed -i -e "s|rpc_address: localhost|rpc_address: $HOST_ADDRESS|" $config_file
[[ -n "$C_CLUSTER_NAME" ]] && sed -i -e "s|cluster_name: 'Test Cluster'|cluster_name: '${C_CLUSTER_NAME//\'/\'\'}'|" $config_file
# workaround for https://github.com/ibmcb/cbtool/issues/59
if [[ $CLUSTER_INDEX > 1 ]]
then
echo sleeping $((120*($CLUSTER_INDEX-1))) seconds
sleep $((120*($CLUSTER_INDEX-1)))
fi
$INSTALL_DIR/cassandra/bin/cassandra
echo $(pgrep -of cassandra) > ${PID_FILE:-pid.txt}
stop.command: |
$INSTALL_DIR/cassandra/bin/nodetool stopdaemon
checkRunning.command: |
$INSTALL_DIR/cassandra/bin/nodetool status
brooklyn.enrichers:
# publish the JMX URL as a sensor; the GUI will pick this up (main.uri)
- type: org.apache.brooklyn.enricher.stock.Transformer
brooklyn.config:
uniqueTag: url-generator
enricher.sourceSensor: host.subnet.hostname
# use the definition from Attributes class, as it has a RendererHint so GUI makes it a link
enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri")
enricher.targetValue:
$brooklyn:formatString:
- "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi"
- $brooklyn:attributeWhenReady("host.subnet.hostname")
- 7199
- type: org.apache.brooklyn.policy.ha.ServiceFailureDetector
brooklyn.config:
# wait 15s after service fails before propagating failure
serviceFailedStabilizationDelay: 15s
brooklyn.policies:
- type: org.apache.brooklyn.policy.ha.ServiceRestarter
- id: cassandra-cluster
description: A cluster of Cassandra nodes
name: Cassandra Cluster
item:
type: org.apache.brooklyn.entity.group.DynamicCluster
brooklyn.config:
initialSize: $brooklyn:config("cassandra.cluster.nodes")
start.timeout: 40m
firstMemberSpec:
$brooklyn:entitySpec:
id: first-node
type: cassandra-node
name: Cassandra node (first)
brooklyn.config:
is.first.node: true
cluster.index: $brooklyn:config("cluster.member.id")
cassandra.first.node.address: $brooklyn:component("first-node").attributeWhenReady("host.subnet.address")
memberSpec:
$brooklyn:entitySpec:
type: cassandra-node
name: Cassandra node
id: cassandra-node
brooklyn.config:
is.first.node: false
cluster.index: $brooklyn:config("cluster.member.id")
cassandra.first.node.address: $brooklyn:component("first-node").attributeWhenReady("host.subnet.address")
launch.latch: $brooklyn:component("first-node").attributeWhenReady("service.isUp")
brooklyn.enrichers:
- type: org.apache.brooklyn.enricher.stock.Aggregator
brooklyn.config:
uniqueTag: node-address-aggregator
enricher.aggregator.excludeBlank: true
enricher.aggregating.fromMembers: true
enricher.sourceSensor: $brooklyn:sensor("host.address")
enricher.targetSensor: $brooklyn:sensor("node.host.address.list")
brooklyn.policies:
- type: org.apache.brooklyn.policy.ha.ServiceReplacer
brooklyn.config:
failureSensorToMonitor: $brooklyn:sensor("ha.entityFailed")