<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _hdfs_namenode_metrics(self, beans, metrics, tags):
 """ Get HDFS namenode metrics from JMX """

        bean = next(iter(beans))
        bean_name = bean.get('name')

        if bean_name != bean_name:
            raise Exception("Unexpected bean name {}".format(bean_name))

        for metric, (metric_name, metric_type) in iteritems(metrics):
            metric_value = bean.get(metric)

            if metric_value is not None:
                self._set_metric(metric_name, metric_type, metric_value, tags)

        if 'CapacityUsed' in bean and 'CapacityTotal' in bean:
            self._set_metric(
                'hdfs.namenode.capacity_in_use',
                self.GAUGE,
                float(bean['CapacityUsed']) / float(bean['CapacityTotal']),
                tags,
            )