// Path: src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueFactory.java
// public class MessageQueueFactory {
// 	private static final Logger logger = Logger.getLogger(MessageQueueFactory.class
// 			.getName());
// 
// 	public enum QueueTypes {
// 		AMQ, SQS, NAN;
// 		public static QueueTypes toQueue(String str) {
// 			try {
// 				return valueOf(str);
// 			} catch (Exception ex) {
// 				return NAN;
// 			}
// 		}
// 	}
// 
// 	public MessageQueueInterface getQueue(String type) {
// 		
// 		switch (QueueTypes.toQueue(type))
// 		{
// 		    case AMQ:
// 		    	return new ActiveMQ();
// 		    case SQS:
// 		    	return new AmazonSQS();
// 		    default:
// 		    	Util.cease(logger, "Invalid Message Queue. Quitting.");
// 		        return null;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueInterface.java
// public interface MessageQueueInterface {
// 	public void connect(String hostname, String queue_name);
// 	public void disconnect();
// 	public void deliver(String payload);
// 	public void consume(HTTPAsyncLogMessageListener ml);
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/ConfigurationSingleton.java
// public enum ConfigurationSingleton {
// 	instance;
// 	private static final Logger logger = Logger
// 			.getLogger(ConfigurationSingleton.class.getName());
// 
// 	private Properties props = new Properties();
// 
// 	private ConfigurationSingleton() {
// 	}
// 
// 	public void readConfigFile(String config_path) {
// 		try {
// 			InputStream input = new FileInputStream(config_path);
// 			props.load(input);
// 			input.close();
// 		} catch (IOException e) {
// 			cease(logger, e.getMessage());
// 		}
// 	}
// 
// 	public String getConfigItem(String val) {
// 		try {
// 			if (props.isEmpty()) {
// 				throw new Exception("Propery file object is empty. "
// 						+ "This likely indicates that the config singleton "
// 						+ "was not properly initialized via readConfigFile.");
// 			}
// 			if (props.getProperty(val) == null) {
// 				throw new Exception("The property " + val
// 						+ " is missing from the configurtion file.");
// 			}
// 			return props.getProperty(val);
// 		} catch (Exception e) {
// 			cease(logger, e.getMessage());
// 			return null;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Timer.java
// public class Timer {
// 
// 	private long start;
// 	private long stop;
// 	private long elapsed;
// 
// 	public void start() {
// 		start = System.currentTimeMillis();
// 	}
// 
// 	public void stop() {
// 		stop = System.currentTimeMillis();
// 	}
// 
// 	public long getElapsed() {
// 		elapsed = stop - start;
// 		return elapsed;
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public class Util {
// 	public static void cease(Logger logger, String message) {
// 		logger.error(message);
// 		System.exit(1);
// 	}
// }


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.messagequeue.MessageQueueFactory;
import com.dogeops.cantilever.messagequeue.MessageQueueInterface;
import com.dogeops.cantilever.utils.ConfigurationSingleton;
import com.dogeops.cantilever.utils.Timer;
import com.dogeops.cantilever.utils.Util;
package com.dogeops.cantilever.beam;




public class LoopControl {
	private static final Logger logger = Logger.getLogger(LoopControl.class
			.getName());

	public void execute() {
		String inputDateFormat = ConfigurationSingleton.instance
				.getConfigItem("replay.dateformat");
		SimpleDateFormat dateFormat = new SimpleDateFormat(inputDateFormat);

		try {
			String inputStartTime = ConfigurationSingleton.instance
					.getConfigItem("replay.starttime");
			Date tmpStart = dateFormat.parse(inputStartTime);
			Calendar startTime = new GregorianCalendar(
					TimeZone.getTimeZone("GMT"));
			startTime.setTime(tmpStart);

			String inputEndTime = ConfigurationSingleton.instance
					.getConfigItem("replay.endtime");
			Date tmpEnd = dateFormat.parse(inputEndTime);
			Calendar endTime = new GregorianCalendar(
					TimeZone.getTimeZone("GMT"));
			endTime.setTime(tmpEnd);

			// How long to run the scheduler.
			long run_time = (endTime.getTimeInMillis() - startTime
					.getTimeInMillis());

			logger.debug("Staring at: " + startTime.getTime()
					+ " and Ending at: " + endTime.getTime() + ", running for "
					+ run_time + " ms");
			
			MessageQueueFactory mqf = new MessageQueueFactory();
			
// Path: src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueFactory.java
// public class MessageQueueFactory {
// 	private static final Logger logger = Logger.getLogger(MessageQueueFactory.class
// 			.getName());
// 
// 	public enum QueueTypes {
// 		AMQ, SQS, NAN;
// 		public static QueueTypes toQueue(String str) {
// 			try {
// 				return valueOf(str);
// 			} catch (Exception ex) {
// 				return NAN;
// 			}
// 		}
// 	}
// 
// 	public MessageQueueInterface getQueue(String type) {
// 		
// 		switch (QueueTypes.toQueue(type))
// 		{
// 		    case AMQ:
// 		    	return new ActiveMQ();
// 		    case SQS:
// 		    	return new AmazonSQS();
// 		    default:
// 		    	Util.cease(logger, "Invalid Message Queue. Quitting.");
// 		        return null;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueInterface.java
// public interface MessageQueueInterface {
// 	public void connect(String hostname, String queue_name);
// 	public void disconnect();
// 	public void deliver(String payload);
// 	public void consume(HTTPAsyncLogMessageListener ml);
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/ConfigurationSingleton.java
// public enum ConfigurationSingleton {
// 	instance;
// 	private static final Logger logger = Logger
// 			.getLogger(ConfigurationSingleton.class.getName());
// 
// 	private Properties props = new Properties();
// 
// 	private ConfigurationSingleton() {
// 	}
// 
// 	public void readConfigFile(String config_path) {
// 		try {
// 			InputStream input = new FileInputStream(config_path);
// 			props.load(input);
// 			input.close();
// 		} catch (IOException e) {
// 			cease(logger, e.getMessage());
// 		}
// 	}
// 
// 	public String getConfigItem(String val) {
// 		try {
// 			if (props.isEmpty()) {
// 				throw new Exception("Propery file object is empty. "
// 						+ "This likely indicates that the config singleton "
// 						+ "was not properly initialized via readConfigFile.");
// 			}
// 			if (props.getProperty(val) == null) {
// 				throw new Exception("The property " + val
// 						+ " is missing from the configurtion file.");
// 			}
// 			return props.getProperty(val);
// 		} catch (Exception e) {
// 			cease(logger, e.getMessage());
// 			return null;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Timer.java
// public class Timer {
// 
// 	private long start;
// 	private long stop;
// 	private long elapsed;
// 
// 	public void start() {
// 		start = System.currentTimeMillis();
// 	}
// 
// 	public void stop() {
// 		stop = System.currentTimeMillis();
// 	}
// 
// 	public long getElapsed() {
// 		elapsed = stop - start;
// 		return elapsed;
// 	}
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public class Util {
// 	public static void cease(Logger logger, String message) {
// 		logger.error(message);
// 		System.exit(1);
// 	}
// }


// Path: src/main/java/com/dogeops/cantilever/beam/LoopControl.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.messagequeue.MessageQueueFactory;
import com.dogeops.cantilever.messagequeue.MessageQueueInterface;
import com.dogeops.cantilever.utils.ConfigurationSingleton;
import com.dogeops.cantilever.utils.Timer;
import com.dogeops.cantilever.utils.Util;

package com.dogeops.cantilever.beam;




public class LoopControl {
	private static final Logger logger = Logger.getLogger(LoopControl.class
			.getName());

	public void execute() {
		String inputDateFormat = ConfigurationSingleton.instance
				.getConfigItem("replay.dateformat");
		SimpleDateFormat dateFormat = new SimpleDateFormat(inputDateFormat);

		try {
			String inputStartTime = ConfigurationSingleton.instance
					.getConfigItem("replay.starttime");
			Date tmpStart = dateFormat.parse(inputStartTime);
			Calendar startTime = new GregorianCalendar(
					TimeZone.getTimeZone("GMT"));
			startTime.setTime(tmpStart);

			String inputEndTime = ConfigurationSingleton.instance
					.getConfigItem("replay.endtime");
			Date tmpEnd = dateFormat.parse(inputEndTime);
			Calendar endTime = new GregorianCalendar(
					TimeZone.getTimeZone("GMT"));
			endTime.setTime(tmpEnd);

			// How long to run the scheduler.
			long run_time = (endTime.getTimeInMillis() - startTime
					.getTimeInMillis());

			logger.debug("Staring at: " + startTime.getTime()
					+ " and Ending at: " + endTime.getTime() + ", running for "
					+ run_time + " ms");
			
			MessageQueueFactory mqf = new MessageQueueFactory();
			
			MessageQueueInterface mqi = mqf.getQueue(ConfigurationSingleton.instance