<commit_before>package com.fenixinfotech.jmx.playpen;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

/**
 * Class to monitor mbean status.
 */
public class MbeanMonitor
{
    private static final Logger logger = LoggerFactory.getLogger(MbeanMonitor.class);

    public void connect(String host, String port) throws IOException
    {
        logger.info("connect with host {} and port", host, port);

        if (port != null)
        {
            // retrieve the RMI connector server stub jmxrmi
            JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" + port + "/jmxrmi");
            JMXConnector jmxConnector = JMXConnectorFactory.connect(url);
            logger.debug("created RMI connector client to url {}", url);

            MBeanServerConnection mBeanServerConnection = jmxConnector.getMBeanServerConnection();
            logger.debug("opened mbean server connection");

            // print out info about domains
            String domains[] = mBeanServerConnection.getDomains();
            Arrays.sort(domains);
            for (String domain : domains)
            {
                logger.debug("found mbean domain {}", domain);
            }

            logger.debug("default domain name is {}", mBeanServerConnection.getDefaultDomain());
            logger.debug("mbean count is {}", mBeanServerConnection.getMBeanCount());

            Set<ObjectName> objectNames = new TreeSet<ObjectName>(mBeanServerConnection.queryNames(null, null));
            for (ObjectName objectName : objectNames)
            {
                logger.debug("found objectName {}", objectName);
            }

            // close connection
            jmxConnector.close();
        }
    }

    public static void main(String[] args) throws IOException
    {
        logger.info("Started main with args {}", args);
        if (args.length > 1)
        {
            new MbeanMonitor().connect(args[0], args[1]);
        }
    }
}
<commit_msg>Added code to pass credentials.<commit_after>package com.fenixinfotech.jmx.playpen;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.IOException;
import java.util.*;

/**
 * Class to monitor mbean status.
 */
public class MbeanMonitor
{
    private static final Logger logger = LoggerFactory.getLogger(MbeanMonitor.class);

    public void connect(String host, String port) throws IOException
    {
        connect(host, port, null, null);
    }

    public void connect(String host, String port, String username, String password) throws IOException
    {
        logger.info("connect with host {} port {} username {} password {}", host, port, username, password);

        if (port != null)
        {
            // retrieve the RMI connector server stub jmxrmi
            JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" + port + "/jmxrmi");
            Map<String, String[]> env = new HashMap<String, String[]>();
            if (username != null && password != null)
            {
                env.put(JMXConnector.CREDENTIALS, new String[]{username, password});
            }
            JMXConnector jmxConnector = JMXConnectorFactory.connect(url, env);
            logger.debug("created RMI connector client to url {} with env ", url, env);

            MBeanServerConnection mBeanServerConnection = jmxConnector.getMBeanServerConnection();
            logger.debug("opened mbean server connection");

            // print out info about domains
            String domains[] = mBeanServerConnection.getDomains();
            Arrays.sort(domains);
            for (String domain : domains)
            {
                logger.debug("found mbean domain {}", domain);
            }

            logger.debug("default domain name is {}", mBeanServerConnection.getDefaultDomain());
            logger.debug("mbean count is {}", mBeanServerConnection.getMBeanCount());

            Set<ObjectName> objectNames = new TreeSet<ObjectName>(mBeanServerConnection.queryNames(null, null));
            for (ObjectName objectName : objectNames)
            {
                logger.debug("found objectName {}", objectName);
            }

            // close connection
            jmxConnector.close();
        }
    }

    public static void main(String[] args) throws IOException
    {
        logger.info("Started main with args {}", args);
        if (args.length > 1)
        {
            new MbeanMonitor().connect(args[0], args[1]);
        }
    }
}

{'fraction_non_alphanumeric': 0.10712160285657607, 'fraction_numerical': 0.0019837333862328904, 'mean_word_length': 2.5784244144783535, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5331367', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1314, 'n_words': 328}