<commit_before>package org.safehaus.kiskis.mgmt.cli.commands;

import org.apache.felix.gogo.commands.Argument;
import org.apache.felix.gogo.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.safehaus.kiskis.mgmt.api.hadoop.Config;
import org.safehaus.kiskis.mgmt.api.hadoop.Hadoop;
import org.safehaus.kiskis.mgmt.shared.protocol.Agent;

import java.util.List;


/**
 * Displays the last log entries
 */
@Command(scope = "hadoop", name = "describe-clusters", description = "Shows the details of Hadoop cluster")
public class DescribeClusterCommand extends OsgiCommandSupport {

    private Hadoop hadoopManager;

    public Hadoop getHadoopManager() {
        return hadoopManager;
    }

    public void setHadoopManager(Hadoop hadoopManager) {
        this.hadoopManager = hadoopManager;
    }

    @Argument(index = 0, name = "clusterName", required = true, multiValued = false, description = "The name of the Hadoop cluster")
    String clusterName;

    protected Object doExecute() {
        Config config = hadoopManager.getCluster(clusterName);
        if (config != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("Cluster name: ").append(config.getClusterName()).append("\n");
            sb.append("Domain name: ").append(config.getDomainName()).append("\n");
            sb.append("All nodes:").append("\n");
            for (Agent agent : config.getAllNodes()) {
                sb.append(agent.getHostname()).append("\n");
            }
            sb.append("Slave nodes:").append("\n");
            for (Agent agent : config.getAllSlaveNodes()) {
                sb.append(agent.getHostname()).append("\n");
            }
            sb.append("Data nodes:").append("\n");
            for (Agent agent : config.getDataNodes()) {
                sb.append(agent.getHostname()).append("\n");
            }
            sb.append("Task trackers:").append("\n");
            for (Agent agent : config.getTaskTrackers()) {
                sb.append(agent.getHostname()).append("\n");
            }
            sb.append("Job tracker:").append(config.getJobTracker()).append("\n");
            System.out.println(sb.toString());
        } else System.out.println("No clusters found...");

        return null;
    }
}
<commit_msg>Refactored Hadoop CLI command.<commit_after>package org.safehaus.kiskis.mgmt.cli.commands;

import org.apache.felix.gogo.commands.Argument;
import org.apache.felix.gogo.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.safehaus.kiskis.mgmt.api.hadoop.Config;
import org.safehaus.kiskis.mgmt.api.hadoop.Hadoop;
import org.safehaus.kiskis.mgmt.shared.protocol.Agent;

import java.util.List;


/**
 * Displays the last log entries
 */
@Command(scope = "hadoop", name = "describe-clusters", description = "Shows the details of Hadoop cluster")
public class DescribeClusterCommand extends OsgiCommandSupport {

    private Hadoop hadoopManager;

    public Hadoop getHadoopManager() {
        return hadoopManager;
    }

    public void setHadoopManager(Hadoop hadoopManager) {
        this.hadoopManager = hadoopManager;
    }

    @Argument(index = 0, name = "clusterName", required = true, multiValued = false, description = "The name of the Hadoop cluster")
    String clusterName;

    protected Object doExecute() {
        Config config = hadoopManager.getCluster(clusterName);
        if (config != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("Cluster name: ").append(config.getClusterName()).append("\n");
            sb.append("Domain name: ").append(config.getDomainName()).append("\n");
            sb.append("All nodes:").append("\n");
            for (Agent agent : config.getAllNodes()) {
                sb.append("Hostname: ").append(agent.getHostname()).append("\n");
            }
            sb.append("Slave nodes:").append("\n");
            for (Agent agent : config.getAllSlaveNodes()) {
                sb.append("Hostname: ").append(agent.getHostname()).append("\n");
            }
            sb.append("Data nodes:").append("\n");
            for (Agent agent : config.getDataNodes()) {
                sb.append("Hostname: ").append(agent.getHostname()).append("\n");
            }
            sb.append("Task trackers:").append("\n");
            for (Agent agent : config.getTaskTrackers()) {
                sb.append("Hostname: ").append(agent.getHostname()).append("\n");
            }
            Agent jt = config.getJobTracker();
            sb.append("Job tracker hostname:").append(jt.getHostname()).append("\n");
            sb.append("Job tracker IPs:").append(jt.getListIP()).append("\n");
            sb.append("Job tracker MAC address:").append(jt.getMacAddress()).append("\n");
            sb.append("Job tracker parent hostname:").append(jt.getParentHostName()).append("\n");
            sb.append("Job tracker UUID:").append(jt.getUuid()).append("\n");
            System.out.println(sb.toString());
        } else System.out.println("No clusters found...");

        return null;
    }
}

{'fraction_non_alphanumeric': 0.15168100078186084, 'fraction_numerical': 0.00039093041438623924, 'mean_word_length': 2.7542186353631695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4447811', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1432, 'n_words': 273}