Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-yarn-master/ganglia_metrics into lp:~bigdata-dev/charms/trusty/apache-hadoop-yarn-master/trunk

Proposed by Andrew McLeod
Status: Merged
Merged at revision: 103
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-yarn-master/ganglia_metrics
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-yarn-master/trunk
Diff against target: 252 lines (+178/-1) (has conflicts)
8 files modified
DEV-README.md (+5/-0)
config.yaml (+4/-0)
hooks/callbacks.py (+31/-1)
hooks/common.py (+15/-0)
hooks/ganglia-relation-broken (+26/-0)
hooks/ganglia-relation-changed (+26/-0)
metadata.yaml (+2/-0)
templates/hadoop-metrics2.properties.j2 (+69/-0)
Text conflict in DEV-README.md
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-yarn-master/ganglia_metrics
Reviewer Review Type Date Requested Status
Juju Big Data Development Pending
Review via email: mp+268538@code.launchpad.net

Description of the change

Added capability to send ganglia metrics is relationship exists

To post a comment you must log in.
93. By Andrew McLeod

added ganglia_metrics config value, default false

94. By Andrew McLeod

changed restart-hdfs to restart-yarn

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'DEV-README.md'
--- DEV-README.md 2015-08-20 21:59:00 +0000
+++ DEV-README.md 2015-08-24 15:13:00 +0000
@@ -77,8 +77,13 @@
7777
78## Manual Deployment78## Manual Deployment
7979
80<<<<<<< TREE
80The easiest way to deploy an Apache Hadoop platform is to use one of81The easiest way to deploy an Apache Hadoop platform is to use one of
81the [apache bundles](https://jujucharms.com/u/bigdata-charmers/#bundles).82the [apache bundles](https://jujucharms.com/u/bigdata-charmers/#bundles).
83=======
84The easiest way to deploy the core Apache Hadoop platform is to use one of
85the [apache bundles](https://jujucharms.com/u/bigdata-charmers/#bundles).
86>>>>>>> MERGE-SOURCE
82However, to manually deploy the base Apache Hadoop platform without using one87However, to manually deploy the base Apache Hadoop platform without using one
83of the bundles, you can use the following:88of the bundles, you can use the following:
8489
8590
=== modified file 'config.yaml'
--- config.yaml 2015-04-03 16:49:17 +0000
+++ config.yaml 2015-08-24 15:13:00 +0000
@@ -4,3 +4,7 @@
4 default: ''4 default: ''
5 description: |5 description: |
6 URL from which to fetch resources (e.g., Hadoop binaries) instead of Launchpad.6 URL from which to fetch resources (e.g., Hadoop binaries) instead of Launchpad.
7 ganglia_metrics:
8 type: boolean
9 default: false
10 description: if relationship exists to ganglia:master, enable ganglia metrics
711
=== modified file 'hooks/callbacks.py'
--- hooks/callbacks.py 2015-08-10 22:59:54 +0000
+++ hooks/callbacks.py 2015-08-24 15:13:00 +0000
@@ -18,7 +18,10 @@
1818
19from charmhelpers.core import hookenv19from charmhelpers.core import hookenv
20from charmhelpers.core import unitdata20from charmhelpers.core import unitdata
21from jujubigdata.relations import NameNode, NodeManager21from jujubigdata.relations import NameNode, NodeManager, Ganglia
22from charmhelpers.core.templating import render
23from functools import partial
24from subprocess import check_call
2225
2326
24def update_blocked_status():27def update_blocked_status():
@@ -50,3 +53,30 @@
5053
51def clear_active_flag():54def clear_active_flag():
52 unitdata.kv().set('charm.active', False)55 unitdata.kv().set('charm.active', False)
56
57
58def conf_ganglia_metrics(purgeConf=False):
59 """
60 Send hadoop specific metrics to a ganglia server
61 """
62 config = hookenv.config()
63 ganglia_metrics = config['ganglia_metrics'] and not purgeConf
64 ganglia_metrics_changed = ganglia_metrics != unitdata.kv().get('ganglia_metrics', False)
65 unitdata.kv().set('ganglia_metrics', ganglia_metrics)
66 comment = '#' if not ganglia_metrics else ''
67 ganglia_host = 'UNSET_BY_JUJU' if not ganglia_metrics else Ganglia().host()
68 ganglia_sink_str = comment + '*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31'
69 hookenv.log("Configuring ganglia sink in /etc/hadoop/conf/hadoop-metrics2.properties", level=None)
70 render(
71 source='hadoop-metrics2.properties.j2',
72 target='/etc/hadoop/conf/hadoop-metrics2.properties',
73 context={
74 'ganglia_host': ganglia_host,
75 'ganglia_sink_str': ganglia_sink_str,
76 },
77 ),
78 if ganglia_metrics_changed:
79 check_call(['actions/restart-yarn'])
80
81
82purge_ganglia_metrics = partial(conf_ganglia_metrics, purgeConf=True)
5383
=== modified file 'hooks/common.py'
--- hooks/common.py 2015-08-10 22:59:54 +0000
+++ hooks/common.py 2015-08-24 15:13:00 +0000
@@ -116,6 +116,21 @@
116 callbacks.update_blocked_status,116 callbacks.update_blocked_status,
117 ],117 ],
118 },118 },
119 {
120 'name': 'ganglia',
121 'requires': [
122 hadoop.is_installed,
123 jujubigdata.relations.Ganglia,
124 ],
125 'callbacks': [
126 callbacks.conf_ganglia_metrics,
127 ],
128 'cleanup': [
129 callbacks.purge_ganglia_metrics,
130 ],
131
132 },
133
119 ])134 ])
120 manager.manage()135 manager.manage()
121136
122137
=== added file 'hooks/ganglia-relation-broken'
--- hooks/ganglia-relation-broken 1970-01-01 00:00:00 +0000
+++ hooks/ganglia-relation-broken 2015-08-24 15:13:00 +0000
@@ -0,0 +1,26 @@
1#!/usr/bin/env python
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
25import common
26common.manage()
027
=== added file 'hooks/ganglia-relation-changed'
--- hooks/ganglia-relation-changed 1970-01-01 00:00:00 +0000
+++ hooks/ganglia-relation-changed 2015-08-24 15:13:00 +0000
@@ -0,0 +1,26 @@
1#!/usr/bin/env python
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
25import common
26common.manage()
027
=== modified file 'metadata.yaml'
--- metadata.yaml 2015-04-23 20:48:28 +0000
+++ metadata.yaml 2015-08-24 15:13:00 +0000
@@ -10,6 +10,8 @@
10provides:10provides:
11 resourcemanager:11 resourcemanager:
12 interface: mapred12 interface: mapred
13 ganglia:
14 interface: monitor
13requires:15requires:
14 namenode:16 namenode:
15 interface: dfs17 interface: dfs
1618
=== added directory 'templates'
=== added file 'templates/hadoop-metrics2.properties.j2'
--- templates/hadoop-metrics2.properties.j2 1970-01-01 00:00:00 +0000
+++ templates/hadoop-metrics2.properties.j2 2015-08-24 15:13:00 +0000
@@ -0,0 +1,69 @@
1#
2# Licensed to the Apache Software Foundation (ASF) under one or more
3# contributor license agreements. See the NOTICE file distributed with
4# this work for additional information regarding copyright ownership.
5# The ASF licenses this file to You under the Apache License, Version 2.0
6# (the "License"); you may not use this file except in compliance with
7# the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18# syntax: [prefix].[source|sink].[instance].[options]
19# See javadoc of package-info.java for org.apache.hadoop.metrics2 for details
20
21*.sink.file.class=org.apache.hadoop.metrics2.sink.FileSink
22# default sampling period, in seconds
23*.period=10
24
25# Defining sink for Ganglia 3.1
26{{ ganglia_sink_str }}
27
28# Default polling period for GangliaSink
29*.sink.ganglia.period=10
30
31# default for supportsparse is false
32*.sink.ganglia.supportsparse=true
33
34# Directing output to ganglia servers
35
36*.sink.ganglia.slope=jvm.metrics.gcCount=zero,jvm.metrics.memHeapUsedM=both
37*.sink.ganglia.dmax=jvm.metrics.threadsBlocked=70,jvm.metrics.memHeapUsedM=40
38
39namenode.sink.ganglia.servers={{ ganglia_host }}:8649
40datanode.sink.ganglia.servers={{ ganglia_host }}:8649
41jobtracker.sink.ganglia.servers={{ ganglia_host }}:8649
42tasktracker.sink.ganglia.servers={{ ganglia_host }}:8649
43maptask.sink.ganglia.servers={{ ganglia_host }}:8649
44reducetask.sink.ganglia.servers={{ ganglia_host }}:8649
45resourcemanager.sink.ganglia.servers={{ ganglia_host }}:8649
46nodemanager.sink.ganglia.servers={{ ganglia_host }}:8649
47historyserver.sink.ganglia.servers={{ ganglia_host }}:8649
48journalnode.sink.ganglia.servers={{ ganglia_host }}:8649
49resourcemanager.sink.ganglia.tagsForPrefix.yarn=Queue
50
51# The namen de-metrics. ut will contain metrics from all context
52#namenode.sink.file.filename=namenode-metrics.out
53# Specifying a special sampling period for namenode:
54#namenode.sink.*.period=8
55
56#datanode.sink.file.filename=datanode-metrics.out
57
58# the following example split metrics of different
59# context to different sinks (in this case files)
60#jobtracker.sink.file_jvm.context=jvm
61#jobtracker.sink.file_jvm.filename=jobtracker-jvm-metrics.out
62#jobtracker.sink.file_mapred.context=mapred
63#jobtracker.sink.file_mapred.filename=jobtracker-mapred-metrics.out
64
65#tasktracker.sink.file.filename=tasktracker-metrics.out
66
67#maptask.sink.file.filename=maptask-metrics.out
68
69#reducetask.sink.file.filename=reducetask-metrics.out

Subscribers

People subscribed via source and target branches

to all changes: