forked from apache/ambari
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AMBARI-6106. Customize the Hadoop metrics sink to write to MySQL stor…
…e. (swagle)
- Loading branch information
Showing
10 changed files
with
976 additions
and
275 deletions.
There are no files selected for viewing
460 changes: 460 additions & 0 deletions
460
contrib/ambari-scom/metrics-sink/db/Hadoop-Metrics-MySQL-CREATE.ddl
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...rib/ambari-scom/metrics-sink/src/main/java/org/apache/hadoop/metrics2/sink/MySqlSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
package org.apache.hadoop.metrics2.sink; | ||
|
||
import java.lang.Override; | ||
|
||
/** | ||
* This class stores published metrics to the MySql database. | ||
*/ | ||
public abstract class MySqlSink extends SqlSink { | ||
public MySqlSink(String NAMENODE_URL_KEY, String DFS_BLOCK_SIZE_KEY) { | ||
super(NAMENODE_URL_KEY, DFS_BLOCK_SIZE_KEY); | ||
} | ||
|
||
@Override | ||
protected String getInsertMetricsProcedureName() { | ||
return SqlSink.insertMetricProc; | ||
} | ||
|
||
@Override | ||
protected String getGetMetricsProcedureName() { | ||
return SqlSink.getMetricRecordProc; | ||
} | ||
|
||
@Override | ||
protected String getDatabaseDriverClassName() { | ||
return "com.mysql.jdbc.Driver"; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ari-scom/metrics-sink/src/main/java/org/apache/hadoop/metrics2/sink/MySqlSinkHadoop1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
package org.apache.hadoop.metrics2.sink; | ||
|
||
import org.apache.hadoop.metrics2.Metric; | ||
import org.apache.hadoop.metrics2.MetricsRecord; | ||
|
||
public class MySqlSinkHadoop1 extends MySqlSink { | ||
public MySqlSinkHadoop1() { | ||
super(SqlSink.HADOOP1_NAMENODE_URL_KEY, SqlSink.HADOOP1_DFS_BLOCK_SIZE_KEY); | ||
} | ||
|
||
@Override | ||
public void putMetrics(MetricsRecord record) { | ||
long metricRecordID = getMetricRecordID(record.context(), record.name(), | ||
getLocalNodeName(), getLocalNodeIPAddress(), getClusterNodeName(), getCurrentServiceName(), | ||
getTagString(record.tags()), record.timestamp()); | ||
if (metricRecordID < 0) | ||
return; | ||
|
||
for (Metric metric : record.metrics()) { | ||
insertMetricValue(metricRecordID, metric.name(), String.valueOf(metric | ||
.value())); | ||
if (metric.name().equals("BlockCapacity")) { | ||
insertMetricValue(metricRecordID, "BlockSize", Integer | ||
.toString(getBlockSize())); | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ari-scom/metrics-sink/src/main/java/org/apache/hadoop/metrics2/sink/MySqlSinkHadoop2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
package org.apache.hadoop.metrics2.sink; | ||
|
||
import org.apache.hadoop.metrics2.AbstractMetric; | ||
import org.apache.hadoop.metrics2.MetricsRecord; | ||
|
||
public class MySqlSinkHadoop2 extends MySqlSink { | ||
public MySqlSinkHadoop2() { | ||
super(SqlSink.HADOOP2_NAMENODE_URL_KEY, SqlSink.HADOOP2_DFS_BLOCK_SIZE_KEY); | ||
} | ||
|
||
@Override | ||
public void putMetrics(MetricsRecord record) { | ||
long metricRecordID = getMetricRecordID(record.context(), record.name(), | ||
getLocalNodeName(), getLocalNodeIPAddress(), getClusterNodeName(), getCurrentServiceName(), | ||
getTagString(record.tags()), record.timestamp()); | ||
if (metricRecordID < 0) | ||
return; | ||
|
||
for (AbstractMetric metric : record.metrics()) { | ||
insertMetricValue(metricRecordID, metric.name(), String.valueOf(metric.value())); | ||
if (metric.name().equals("BlockCapacity")) { | ||
insertMetricValue(metricRecordID, "BlockSize", Integer | ||
.toString(getBlockSize())); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.