// Path: micro-genie-aws/src/main/java/io/microgenie/aws/config/KinesisConfig.java
// public class KinesisConfig {
// 	
// 	private String topic;
// 	private int shards;
// 	
// 	public KinesisConfig(){}
// 	
// 	
// 	@JsonProperty("topic")
// 	public String getTopic() {
// 		return topic;
// 	}
// 	@JsonProperty("topic")
// 	public void setTopic(String topic) {
// 		this.topic = topic;
// 	}
// 	public KinesisConfig withTopic(final String topic){
// 		this.topic = topic;
// 		return this;
// 	}
// 	
// 	
// 	@JsonProperty("shards")
// 	public int getShards() {
// 		return shards;
// 	}
// 	@JsonProperty("shards")
// 	public void setShards(int shards) {
// 		this.shards = shards;
// 	}
// 	public KinesisConfig withShards(final int shards){
// 		this.shards = shards;
// 		return this;
// 	}
// }


import io.microgenie.aws.config.KinesisConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.kinesis.AmazonKinesisClient;
import com.amazonaws.services.kinesis.model.CreateStreamRequest;
import com.amazonaws.services.kinesis.model.DeleteStreamRequest;
import com.amazonaws.services.kinesis.model.DescribeStreamRequest;
import com.amazonaws.services.kinesis.model.DescribeStreamResult;
import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
	
	
	
	


	/***
	 * Initialize kinesis streams
	 * @param kinesis
	 */
	public void initialize(final List<KinesisConfig> kinesis) throws ExecutionException, TimeoutException {
		try{
			this.executeTasks(kinesis);	
		}catch(final InterruptedException ie){
			throw new RuntimeException(ie.getMessage(),ie);
		}
	}
	
	
	/***
	 * Execute tasks concurrently
	 * 
	 * @param configs
	 * @throws InterruptedException
	 * @throws ExecutionException
	 * @throws TimeoutException
	 */
	private void executeTasks(final List<KinesisConfig> configs) throws InterruptedException, ExecutionException, TimeoutException{
		
		final List<ListenableFuture<?>> futures = new ArrayList<ListenableFuture<?>>();
// Path: micro-genie-aws/src/main/java/io/microgenie/aws/config/KinesisConfig.java
// public class KinesisConfig {
// 	
// 	private String topic;
// 	private int shards;
// 	
// 	public KinesisConfig(){}
// 	
// 	
// 	@JsonProperty("topic")
// 	public String getTopic() {
// 		return topic;
// 	}
// 	@JsonProperty("topic")
// 	public void setTopic(String topic) {
// 		this.topic = topic;
// 	}
// 	public KinesisConfig withTopic(final String topic){
// 		this.topic = topic;
// 		return this;
// 	}
// 	
// 	
// 	@JsonProperty("shards")
// 	public int getShards() {
// 		return shards;
// 	}
// 	@JsonProperty("shards")
// 	public void setShards(int shards) {
// 		this.shards = shards;
// 	}
// 	public KinesisConfig withShards(final int shards){
// 		this.shards = shards;
// 		return this;
// 	}
// }


// Path: micro-genie-aws/src/main/java/io/microgenie/aws/admin/KinesisAdmin.java
import io.microgenie.aws.config.KinesisConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.kinesis.AmazonKinesisClient;
import com.amazonaws.services.kinesis.model.CreateStreamRequest;
import com.amazonaws.services.kinesis.model.DeleteStreamRequest;
import com.amazonaws.services.kinesis.model.DescribeStreamRequest;
import com.amazonaws.services.kinesis.model.DescribeStreamResult;
import com.amazonaws.services.kinesis.model.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;

	
	
	
	


	/***
	 * Initialize kinesis streams
	 * @param kinesis
	 */
	public void initialize(final List<KinesisConfig> kinesis) throws ExecutionException, TimeoutException {
		try{
			this.executeTasks(kinesis);	
		}catch(final InterruptedException ie){
			throw new RuntimeException(ie.getMessage(),ie);
		}
	}
	
	
	/***
	 * Execute tasks concurrently
	 * 
	 * @param configs
	 * @throws InterruptedException
	 * @throws ExecutionException
	 * @throws TimeoutException
	 */
	private void executeTasks(final List<KinesisConfig> configs) throws InterruptedException, ExecutionException, TimeoutException{
		
		final List<ListenableFuture<?>> futures = new ArrayList<ListenableFuture<?>>();
		for(KinesisConfig config : configs){