<commit_before>/*
 * -----------------------------------------------------------------------\
 * PerfCake
 *  
 * Copyright (C) 2010 - 2016 the original author or authors.
 *  
 * Licensed 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.perfcake.debug;

import org.perfcake.PerfCakeConst;
import org.perfcake.PerfCakeException;
import org.perfcake.message.correlator.Correlator;
import org.perfcake.message.generator.MessageGenerator;
import org.perfcake.message.receiver.Receiver;
import org.perfcake.message.sequence.Sequence;
import org.perfcake.reporting.destinations.Destination;
import org.perfcake.reporting.reporters.Reporter;
import org.perfcake.util.Utils;
import org.perfcake.validation.MessageValidator;

import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.BasicInformational;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.Informational;
import com.netflix.servo.monitor.MonitorConfig;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * JMX based debug agent providing information about the running performance test.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class PerfCakeDebug {

   /**
    * The logger.
    */
   private static final Logger log = LogManager.getLogger(PerfCakeDebug.class);

   /**
    * Singleton instance of the debug agent.
    */
   private static PerfCakeDebug INSTANCE;

   /**
    * Name of the debug agent. Determines the property key in JMX. Defaults to perfcake-1. Important when multiple instances were running.
    */
   private static String AGENT_NAME = Utils.getProperty(PerfCakeConst.DEBUG_AGENT_NAME_PROPERTY, PerfCakeConst.DEBUG_AGENT_DEFAULT_NAME);

   /**
    * Class name of the generator used.
    */
   private Informational messageGeneratorClass;

   /**
    * Class name of the sender used.
    */
   private Informational messageSenderClass;

   /**
    * Class name of the receiver used.
    */
   private Informational receiverClass;

   /**
    * Class name of the correlator used.
    */
   private Informational correlatorClass;

   /**
    * Class names of the sequences used.
    */
   private Map<String, Informational> sequenceClasses = new ConcurrentHashMap<>();

   /**
    * Class names of the validators used.
    */
   private Map<String, Informational> validatorClasses = new ConcurrentHashMap<>();

   /**
    * How many sender tasks were created so far.
    */
   private Counter generatedSenderTasks = newCounter("GeneratedSenderTasks");

   /**
    * Number of sent messages.
    */
   private Counter sentMessages = newCounter("SentMessages");

   /**
    * Number of received messages
    */
   private Counter correlatedMessages = newCounter("CorrelatedMessages");

   /**
    * Number of sequence snapshots taken
    */
   private Counter sequenceSnapshots = newCounter("SequenceSnapshots");

   /**
    * Internal reference of parent reportes of individual destinations for later reporting.
    */
   private Map<Destination, String> parentReporters = new ConcurrentHashMap<>();
<commit_msg>fixed javadoc<commit_after>/*
 * -----------------------------------------------------------------------\
 * PerfCake
 *  
 * Copyright (C) 2010 - 2016 the original author or authors.
 *  
 * Licensed 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.perfcake.debug;

import org.perfcake.PerfCakeConst;
import org.perfcake.PerfCakeException;
import org.perfcake.message.correlator.Correlator;
import org.perfcake.message.generator.MessageGenerator;
import org.perfcake.message.receiver.Receiver;
import org.perfcake.message.sequence.Sequence;
import org.perfcake.reporting.destinations.Destination;
import org.perfcake.reporting.reporters.Reporter;
import org.perfcake.util.Utils;
import org.perfcake.validation.MessageValidator;

import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.BasicInformational;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.Informational;
import com.netflix.servo.monitor.MonitorConfig;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * JMX based debug agent providing information about the running performance test.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class PerfCakeDebug {

   /**
    * The logger.
    */
   private static final Logger log = LogManager.getLogger(PerfCakeDebug.class);

   /**
    * Singleton instance of the debug agent.
    */
   private static PerfCakeDebug INSTANCE;

   /**
    * Name of the debug agent. Determines the property key in JMX. Defaults to perfcake-1. Important when multiple instances were running.
    */
   private static String AGENT_NAME = Utils.getProperty(PerfCakeConst.DEBUG_AGENT_NAME_PROPERTY, PerfCakeConst.DEBUG_AGENT_DEFAULT_NAME);

   /**
    * Class name of the generator used.
    */
   private Informational messageGeneratorClass;

   /**
    * Class name of the sender used.
    */
   private Informational messageSenderClass;

   /**
    * Class name of the receiver used.
    */
   private Informational receiverClass;

   /**
    * Class name of the correlator used.
    */
   private Informational correlatorClass;

   /**
    * Class names of the sequences used.
    */
   private Map<String, Informational> sequenceClasses = new ConcurrentHashMap<>();

   /**
    * Class names of the validators used.
    */
   private Map<String, Informational> validatorClasses = new ConcurrentHashMap<>();

   /**
    * How many sender tasks were created so far.
    */
   private Counter generatedSenderTasks = newCounter("GeneratedSenderTasks");

   /**
    * Number of sent messages.
    */
   private Counter sentMessages = newCounter("SentMessages");

   /**
    * Number of received messages.
    */
   private Counter correlatedMessages = newCounter("CorrelatedMessages");

   /**
    * Number of sequence snapshots taken.
    */
   private Counter sequenceSnapshots = newCounter("SequenceSnapshots");

   /**
    * Internal reference of parent reportes of individual destinations for later reporting.
    */
   private Map<Destination, String> parentReporters = new ConcurrentHashMap<>();

{'fraction_non_alphanumeric': 0.12613496932515336, 'fraction_numerical': 0.0036809815950920245, 'mean_word_length': 3.2720125786163523, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6887372', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2200, 'n_words': 645}