<commit_before>package eu.choreos.gmond;

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

import org.apache.commons.io.FileUtils;

import eu.choreos.gmond.reloader.GmondReloader;

public class GmondConf {
	private String gmondFile = "/etc/ganglia/gmond.conf";
	private List<String> fileLines;
	private int searchIndex;

	public List<String> getFileLines() {
		return fileLines;
	}

	public GmondConf() {
		searchIndex = 0;

	}

	public static void main(String... args) throws Exception {
		String fileName = "/etc/ganglia/gmond.conf";

		validateArgs(args);

		fileName = getConfigFile(args);

		GmondConf gmondConf = new GmondConf();

		gmondConf.load(fileName);

		for (int i = 0; i < args.length; i++) {

			if (args[i].equals("--add")) {
				gmondConf.addUdpSendChannel(args[i + 1], args[i + 2]);
				i += 2;
			}

			if (args[i].equals("--update-port")) {
				gmondConf.updateUdpSendChannelPort(args[i + 1],
						Integer.parseInt(args[i + 2]));
				i += 2;
			}

			if (args[i].equals("--update-channel")) {
				gmondConf.updateUdpSendChannel(args[i], args[i + 1],
						Integer.parseInt(args[i + 2]));
				i += 2;
			}

			if (args[i].equals("--update-host")) {
				gmondConf.updateUdpSendChannelHost(args[i + 1], args[i + 2]);
				i += 2;
			}

			if (args[i].equals("--remove")) {
				gmondConf.removeUdpSendChannel(args[i + 1]);
				i += 2;
			}

		}

		gmondConf.save();

		GmondReloader reloader = new GmondReloader();
		if (reloader.reload())
			System.out.println("gmond restarted.");
		else
			System.out.println("could not restart gmond");

	}

	private static String getConfigFile(String[] arguments) {
		String fileName = "/etc/ganglia/gmond.conf";

		for (int i = 0; i < arguments.length; i++) {

			if (arguments[i].equals("--config-file")) {
				fileName = arguments[i + 1];
			}
		}
		return fileName;
	}

	private static void validateArgs(String[] args) throws Exception {
		String string;

		for (int index = 0; index < args.length; index++) {
			string = args[index];<commit_msg>Added root user message!<commit_after>package eu.choreos.gmond;

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

import org.apache.commons.io.FileUtils;

import eu.choreos.gmond.reloader.GmondReloader;

public class GmondConf {
	private String gmondFile = "/etc/ganglia/gmond.conf";
	private List<String> fileLines;
	private int searchIndex;

	public List<String> getFileLines() {
		return fileLines;
	}

	public GmondConf() {
		searchIndex = 0;

	}

	public static void main(String... args) throws Exception {
		String fileName = "/etc/ganglia/gmond.conf";

		validateArgs(args);

		fileName = getConfigFile(args);

		GmondConf gmondConf = new GmondConf();

		gmondConf.load(fileName);

		for (int i = 0; i < args.length; i++) {

			if (args[i].equals("--add")) {
				gmondConf.addUdpSendChannel(args[i + 1], args[i + 2]);
				i += 2;
			}

			if (args[i].equals("--update-port")) {
				gmondConf.updateUdpSendChannelPort(args[i + 1],
						Integer.parseInt(args[i + 2]));
				i += 2;
			}

			if (args[i].equals("--update-channel")) {
				gmondConf.updateUdpSendChannel(args[i], args[i + 1],
						Integer.parseInt(args[i + 2]));
				i += 2;
			}

			if (args[i].equals("--update-host")) {
				gmondConf.updateUdpSendChannelHost(args[i + 1], args[i + 2]);
				i += 2;
			}

			if (args[i].equals("--remove")) {
				gmondConf.removeUdpSendChannel(args[i + 1]);
				i += 2;
			}

		}

		gmondConf.save();

		GmondReloader reloader = new GmondReloader();
		if (reloader.reload())
			System.out.println("gmond restarted.");
		else
			System.out.println("could not restart gmond. Are you root? Do you have the necessary privileges?");

	}

	private static String getConfigFile(String[] arguments) {
		String fileName = "/etc/ganglia/gmond.conf";

		for (int i = 0; i < arguments.length; i++) {

			if (arguments[i].equals("--config-file")) {
				fileName = arguments[i + 1];
			}
		}
		return fileName;
	}

	private static void validateArgs(String[] args) throws Exception {
		String string;

		for (int index = 0; index < args.length; index++) {
			string = args[index];
{'fraction_non_alphanumeric': 0.1594064145524174, 'fraction_numerical': 0.009095260890378171, 'mean_word_length': 3.46474358974359, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '2491917', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1462, 'n_words': 319}