Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 219 lines (181 sloc) 6.075 kB
f61a439 @tamirko Tamir added MySQL
tamirko authored
1 /*******************************************************************************
01f3d2d @tamirko Added Copyright
tamirko authored
2 * Copyright (c) 2012 GigaSpaces Technologies Ltd. All rights reserved
f61a439 @tamirko Tamir added MySQL
tamirko authored
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 import groovy.sql.*
17 import com.mysql.jdbc.Driver
18
19 service {
20
21 name "mysql"
22
232a378 @tamirko Tamir update icon
tamirko authored
23 icon "mysql.png"
f61a439 @tamirko Tamir added MySQL
tamirko authored
24 type "DATABASE"
969b16f @tamirko Added MySQL master-slave (1st iteration-No Failover)
tamirko authored
25 elastic true
26 numInstances 1
27 minAllowedInstances 1
28 maxAllowedInstances 3
e6ac322 @tamirko CR-1
tamirko authored
29
158d4a8 @tamirko CR-2
tamirko authored
30 compute {
31 template "SMALL_LINUX"
32 }
33
f61a439 @tamirko Tamir added MySQL
tamirko authored
34 lifecycle{
35
36 install "mysql_install.groovy"
37
38 start "mysql_start.groovy"
39
40 startDetectionTimeoutSecs 900
41 startDetection "mysql_startDetection.groovy"
42
43 stopDetection {
44 !ServiceUtils.isPortOccupied(jdbcPort)
45 }
46
47 preStop ([
48 "Win.*":"killAllMysql.bat",
49 "Linux.*":"mysql_stop.groovy"
50 ])
51 shutdown ([
52 "Linux.*":"mysql_uninstall.groovy"
53 ])
54
55
56 locator {
57 //hack to avoid monitoring started processes by cloudify
58 //return [] as LinkedList
59
60 def myPids = ServiceUtils.ProcessUtils.getPidsWithQuery("State.Name.re=mysql.*\\.exe|mysqld")
61 println ":mysql-service.groovy: current PIDs: ${myPids}"
62 return myPids
3cced94 @yoramw Update mysql-service.groovy
yoramw authored
63 }
b490614 @tamirko Fixed indentatation
tamirko authored
64
65 details {
66 def currPublicIP
67
68 if ( context.isLocalCloud() ) {
69 currPublicIP = InetAddress.localHost.hostAddress
70 }
71 else {
72 currPublicIP =context.getPublicAddress()
73 }
74 return [
75 "MySQL IP":currPublicIP,
76 "MySQL Port":jdbcPort
77 ]
3cced94 @yoramw Update mysql-service.groovy
yoramw authored
78 }
f61a439 @tamirko Tamir added MySQL
tamirko authored
79 }
80
81 customCommands ([
4ff3327 @tamirko Added an option to enable s3 backup from any cloud
tamirko authored
82 /*
83 This custom command enables users to create a database snapshot (mysqldump)
84 and to upload the backup to an external storage (Amazon S3 for example).
85 Usage : invoke mysql mysqldump actionUser dumpPrefix dbName backupType bucketName
86 Example: invoke mysql mysqldump root myPrefix_ myDbName s3 myBucketName
87 */
f61a439 @tamirko Tamir added MySQL
tamirko authored
88
89 "mysqldump" : "mysql_dump.groovy" ,
90
91 /*
92 This custom command enables users to invoke an SQL statement
1443630 @tamirko Added an option to invoke the query command with or without a password
tamirko authored
93 Usage : invoke mysql query actionUser [puserPassword] dbName query
94 Examples:
95 1. invoke mysql query root myDbName "update users set city=\"NY\" where uid=15"
96 2. invoke mysql query root pmyRootPassword myDbName "update users set city=\"NY\" where uid=15"
97
f61a439 @tamirko Tamir added MySQL
tamirko authored
98 */
969b16f @tamirko Added MySQL master-slave (1st iteration-No Failover)
tamirko authored
99 "query" : "mysql_query.groovy" ,
100
101 /*
102 This custom command enables users to add a slave to the master.
103 It should be invoked only on a master instance (by a remote slave)
104 and only if masterSlaveMode is set to true on both the slave and master.
105 As a result, the following will be invoked :
106 mysql -u root -D dbName -e
107 "GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO slaveUser@'slaveHostIP' IDENTIFIED BY 'slavePassword';"
108
109 Usage : invoke mysqlmaster addSlave actionUser dbName slaveUser slavePassword slaveHostIP
110
111 */
112 "addSlave": "mysql_addSlave.groovy" ,
113
114 /*
115 This custom command enables users to show the master's status.
116 It should be invoked only on a master instance (either by the master or by a remote slave)
117 and only if masterSlaveMode is set to true.
118 As a result, the following will be invoked :
119 mysql -u root -D dbName -e "show master status;"
120 and the mysql-bin will be stored in context.attributes.thisApplication["masterBinLogFile"]
121 and the master's log's position will be stored in context.attributes.thisApplication["masterBinLogPos"]
122
123 Usage : invoke mysqlmaster showMasterStatus actionUser dbName
124
125 */
126 "showMasterStatus": "mysql_showMasterStatus.groovy" ,
127
128 /*
129 This custom command enables users to import a zipped file to a database
8e4874f @tamirko Fixed a missing service name
tamirko authored
130 Usage : invoke mysql import actionUser dbName zipFileURL
131 Example: invoke mysql import root myDbName http://www.mysite.com/myFile.zip
969b16f @tamirko Added MySQL master-slave (1st iteration-No Failover)
tamirko authored
132 */
133
134 "import" : "mysql_import.groovy"
f61a439 @tamirko Tamir added MySQL
tamirko authored
135 ])
136
137
138 userInterface {
139 metricGroups = ([
140 metricGroup {
141 name "server"
142
143 metrics([
144 "Server Uptime",
145 "Client Connections",
146 "Total Queries",
147 "Slow Queries",
148 "Opens",
149 "Current Open Tables",
150 "Queries Per Second"
151 ])
152 }
153 ])
154
155 widgetGroups = ([
156 widgetGroup {
157 name "Server Uptime"
158 widgets ([
159 barLineChart{
160 metric "Server Uptime"
161 axisYUnit Unit.REGULAR
162 },
163 ])
164
165 } ,
166 widgetGroup {
167 name "Client Connections"
168 widgets ([
169 barLineChart{
170 metric "Client Connections"
171 axisYUnit Unit.REGULAR
172 },
173 ])
174
175 } ,
176 widgetGroup {
177 name "Total Queries"
178 widgets ([
179 barLineChart{
180 metric "Total Queries"
181 axisYUnit Unit.REGULAR
182 },
183 ])
184
185 } ,
186 widgetGroup {
187 name "Opens"
188 widgets ([
189 barLineChart{
190 metric "Opens"
191 axisYUnit Unit.REGULAR
192 },
193 ])
194
195 } ,
196 widgetGroup {
197 name "Current Open Tables"
198 widgets ([
199 barLineChart{
200 metric "Current Open Tables"
201 axisYUnit Unit.REGULAR
202 },
203 ])
204
205 } ,
206 widgetGroup {
207 name "Queries Per Second"
208 widgets ([
209 barLineChart{
210 metric "Queries Per Second"
211 axisYUnit Unit.REGULAR
212 },
213 ])
214
215 } ,
216 ])
217 }
218 }
Something went wrong with that request. Please try again.