Monthly Archives: August 2015

Decommission and recommission in Ambari API

It’s pretty easy to find how to decommission something in Ambari API.

For example, let’s decommission a datanode :

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Decommission DataNodes dn1,dn2",
"command":"DECOMMISSION",
"parameters":{
"slave_type":"DATANODE",
"excluded_hosts":"dn1.example.com,dn2.example.com"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"MY_CLUSTER"
}
},
"Requests/resource_filters":[
{
"service_name":"HDFS",
"component_name":"NAMENODE"
}
]
}' http://gw.example.com:8080/api/v1/clusters/MY_CLUSTER/requests

 

I then tried to recommission these datanodes using the “RECOMMISSION” command, and it failed.

The thing here is to change excluded_hosts (which is the list of hosts to be decommissioned), for included_hosts.

 

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Recommission DataNodes dn1,dn2",
"command":"DECOMMISSION",
"parameters":{
"slave_type":"DATANODE",
"included_hosts":"dn1.example.com,dn2.example.com"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"MY_CLUSTER"
}
},
"Requests/resource_filters":[
{
"service_name":"HDFS",
"component_name":"NAMENODE"
}
]
}' http://gw.example.com:8080/api/v1/clusters/MY_CLUSTER/requests

get Hadoop metric with jmx

JMX is widely used in Java world to stream metrics and KPIs.

In Hadoop, the most used JMX is on the NameNode :

http://NAMENODE_FQDN:50070/jmx

This provides an overview of all the things accessible through JMX :

JMX Hadoop metrics JMX Overview

You can have a list of all metrics provided by JMX :

http://sandbox.hortonworks.com:50070/jmx?qry=Hadoop:*

JMX Hadoop metrics

And you can finally (which is very useful if you’re looking at something very specific) get a specific metric when specifying the bean name and the attribute :

http://NAMENODE_FQDN:50070/jmx?get=MXBeanName::AttributeName

For example, if we want to get the CapacityUsed found here :

JMX find metric

Then we’ll call JMX with MXBeanName = Hadoop:service=NameNode,name=FSNamesystemState and AttributeName set to CapacityUsed

So we call http://sandbox.hortonworks.com:50070/jmx?get=Hadoop:service=NameNode,name=FSNamesystemState::CapacityUsed

JMX CapacityUsed