<commit_before>package eu.choreos.monitoring.platform.daemon;

import it.cnr.isti.labse.glimpse.event.GlimpseBaseEventImpl;
import it.cnr.isti.labse.glimpse.utils.Manager;

import java.util.Properties;

public class ThresholdEvalDaemonLauncher {

	private static String host;
	private static int port;
	private static String javaNamingProviderUrl = null;

	private static void parseArgs(String[] args) {
		host = "localhost";
		port = 8649;

		switch (args.length) {
		case 0:
			break;
		case 3:
			javaNamingProviderUrl = args[2];
		case 2:
			port = Integer.parseInt(args[1]);
		case 1:
			host = args[0];

			break;
		default:
			System.out
					.println("USAGE: ThresholdEvalDaemon [hostLocation] [port] [java naming provider URL]");
			System.out
					.println("Default values: hostLocation = 'http://localhost/'");
			System.out.println("                port = 8649");
			host = args[0];

			System.out
					.println("Note: to set a port, the hostLocation must also be present");
			break;
		}
	}

	private static Properties getProperties() {
		if (javaNamingProviderUrl == null)
			javaNamingProviderUrl = "tcp://dsbchoreos.petalslink.org:61616";
		Properties probeSettingsProperties = Manager
				.createProbeSettingsPropertiesObject(
						"org.apache.activemq.jndi.ActiveMQInitialContextFactory",
						javaNamingProviderUrl, "system", "manager",
						"GangliaFactory", "jms.probeTopic", true, "probeName",
						"probeTopic");
		return probeSettingsProperties;

	}

	private static GlimpseBaseEventImpl<String> getBaseEvent() {

		return new GlimpseBaseEventImpl<String>("thresholdAlarm",
				"connector1", "connInstance1", "connExecution1", 1, 2,
				System.currentTimeMillis(), "NS1", false);

	}

	
	public static void main(String[] args) throws InterruptedException {
		parseArgs(args);
		
		ThresholdEvalDaemon daemon = new ThresholdEvalDaemon(getProperties(),
				host, port);
		
		daemon.addThreshold(new Threshold("load_one", Threshold.MAX, 1));
		daemon.continuouslyEvaluateThresholdsAndSendMessages(getBaseEvent());
	}

}<commit_msg>Integrated YamlParser into ThresholdEvalDaemonLauncher<commit_after>package eu.choreos.monitoring.platform.daemon;

import it.cnr.isti.labse.glimpse.event.GlimpseBaseEventImpl;
import it.cnr.isti.labse.glimpse.utils.Manager;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import eu.choreos.monitoring.platform.utils.YamlParser;

public class ThresholdEvalDaemonLauncher {

	private static String host;
	private static int port;
	private static String javaNamingProviderUrl = null;
	private static String thresholdListFileName = null;

	private static void parseArgs(String[] args) {
		host = "localhost";
		port = 8649;
		javaNamingProviderUrl=null;
		thresholdListFileName = "";

		switch (args.length) {
		case 1:
			thresholdListFileName = args[0];
			break;

		case 4:
			javaNamingProviderUrl = args[3];
		
		case 3:
			port = Integer.parseInt(args[2]);
		
		case 2:
			host = args[1];
			break;

		default:
			System.out
					.println("USAGE: ThresholdEvalDaemon THRESHOLD_LIST_FILE [HOST_LOCATION] [PORT] [JAVA_NAMING_PROVIDER_URL]");
			System.out
					.println("Default values: hostLocation = 'http://localhost/'");
			System.out.println("                port = 8649");
			System.out
					.println("Note: to set a port, the hostLocation must also be present");
			System.exit(1);
		}
	}

	private static Properties getProperties() {
		if (javaNamingProviderUrl == null)
			javaNamingProviderUrl = "tcp://dsbchoreos.petalslink.org:61616";
		Properties probeSettingsProperties = Manager
				.createProbeSettingsPropertiesObject(
						"org.apache.activemq.jndi.ActiveMQInitialContextFactory",
						javaNamingProviderUrl, "system", "manager",
						"GangliaFactory", "jms.probeTopic", true, "probeName",
						"probeTopic");
		return probeSettingsProperties;

	}

	private static GlimpseBaseEventImpl<String> getBaseEvent() {

		return new GlimpseBaseEventImpl<String>("thresholdAlarm",
				"connector1", "connInstance1", "connExecution1", 1, 2,
				System.currentTimeMillis(), "NS1", false);

	}

	
	public static void main(String[] args) throws InterruptedException, IOException {
		parseArgs(args);
		
		ThresholdEvalDaemon daemon = new ThresholdEvalDaemon(getProperties(),
				host, port);
		
		List<Threshold> thresholdList = YamlParser.getThresholdsFromFile(thresholdListFileName);
		daemon.addMultipleThreshold(thresholdList);
		daemon.continuouslyEvaluateThresholdsAndSendMessages(getBaseEvent());
	}

}
{'fraction_non_alphanumeric': 0.1108662111527441, 'fraction_numerical': 0.012342957901697156, 'mean_word_length': 4.547677261613692, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3322357', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1400, 'n_words': 301}