// Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
// 
// 	public static Channel connect() throws Exception {
// 		ConnectionFactory factory = new ConnectionFactory();
// 		factory.setHost("127.0.0.1");
// 		factory.setPort(32768);
// 		Connection conn = factory.newConnection();
// 		return conn.createChannel();
// 	}
// 	
// 	public static void close(Channel channel) throws Exception {
// 		channel.close();
// 		channel.getConnection().close();
// 	}
// 
// }


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package threshold;



//timer is usually timestamp, but in this demo it is the number of messages due to 
//the long times when things get worse
public class AMQPProducer {
	
	long low = 0;
	long current = 1000;
	long high = 0;
	long timerSec = 10;
	long startTimer = System.currentTimeMillis();
	long tradeCount = 0;
	long timeout = 10; //trigger timeout after 10 trades with no adjustment
	
	List<Long> durations = new ArrayList<Long>();
	List<Long> highDurations = new ArrayList<Long>();
	double mean = 0;
	
	Channel channel = null;
	
	public void execute(String mode) throws Exception {
// Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
// 
// 	public static Channel connect() throws Exception {
// 		ConnectionFactory factory = new ConnectionFactory();
// 		factory.setHost("127.0.0.1");
// 		factory.setPort(32768);
// 		Connection conn = factory.newConnection();
// 		return conn.createChannel();
// 	}
// 	
// 	public static void close(Channel channel) throws Exception {
// 		channel.close();
// 		channel.getConnection().close();
// 	}
// 
// }


// Path: threshold/java/threshold/AMQPProducer.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;

package threshold;



//timer is usually timestamp, but in this demo it is the number of messages due to 
//the long times when things get worse
public class AMQPProducer {
	
	long low = 0;
	long current = 1000;
	long high = 0;
	long timerSec = 10;
	long startTimer = System.currentTimeMillis();
	long tradeCount = 0;
	long timeout = 10; //trigger timeout after 10 trades with no adjustment
	
	List<Long> durations = new ArrayList<Long>();
	List<Long> highDurations = new ArrayList<Long>();
	double mean = 0;
	
	Channel channel = null;
	
	public void execute(String mode) throws Exception {
		channel = AMQPCommon.connect();