// Path: java/src/main/java/monasca/persister/repository/RepoException.java
// public class RepoException extends Exception {
// 
//   public RepoException() {
// 
//     super();
//   }
// 
//   public RepoException(String message) {
// 
//     super(message);
//   }
// 
//   public RepoException(String message, Throwable cause) {
// 
//     super(message, cause);
//   }
// 
//   public RepoException(Throwable cause) {
// 
//     super(cause);
//   }
// 
//   protected RepoException(String message, Throwable cause, boolean enableSuppression,
//                           boolean writableStackTrace) {
// 
//     super(message, cause, enableSuppression, writableStackTrace);
//   }
// }


import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Timer;
import com.datastax.driver.core.BatchStatement;
import com.datastax.driver.core.BatchStatement.Type;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Statement;
import com.datastax.driver.core.exceptions.BootstrappingException;
import com.datastax.driver.core.exceptions.DriverException;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import com.datastax.driver.core.exceptions.OperationTimedOutException;
import com.datastax.driver.core.exceptions.OverloadedException;
import com.datastax.driver.core.exceptions.QueryConsistencyException;
import com.datastax.driver.core.exceptions.UnavailableException;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.dropwizard.setup.Environment;
import monasca.persister.repository.RepoException;

    } else {
      logger.warn("[{}]: Query failed, retrying {} of {}: {} ", id, retryCount, maxWriteRetries,
          e.getMessage());

      try {
        Thread.sleep(1000 * (1 << retryCount));
      } catch (InterruptedException ie) {
        logger.debug("[{}]: Interrupted: {}", id, ie);
      }
      _executeQuery(id, query, startTime, retryCount++);
    }
  }

  public int handleFlush_batch(String id) {
    Statement query;
    int flushedCount = 0;

    BatchStatement batch = new BatchStatement(Type.UNLOGGED);
    while ((query = queue.poll()) != null) {
      flushedCount++;
      batch.add(query);
    }

    executeQuery(id, batch, System.nanoTime());

    metricCompleted.inc(flushedCount);

    return flushedCount;
  }


// Path: java/src/main/java/monasca/persister/repository/RepoException.java
// public class RepoException extends Exception {
// 
//   public RepoException() {
// 
//     super();
//   }
// 
//   public RepoException(String message) {
// 
//     super(message);
//   }
// 
//   public RepoException(String message, Throwable cause) {
// 
//     super(message, cause);
//   }
// 
//   public RepoException(Throwable cause) {
// 
//     super(cause);
//   }
// 
//   protected RepoException(String message, Throwable cause, boolean enableSuppression,
//                           boolean writableStackTrace) {
// 
//     super(message, cause, enableSuppression, writableStackTrace);
//   }
// }


// Path: java/src/main/java/monasca/persister/repository/cassandra/CassandraRepo.java
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Timer;
import com.datastax.driver.core.BatchStatement;
import com.datastax.driver.core.BatchStatement.Type;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Statement;
import com.datastax.driver.core.exceptions.BootstrappingException;
import com.datastax.driver.core.exceptions.DriverException;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import com.datastax.driver.core.exceptions.OperationTimedOutException;
import com.datastax.driver.core.exceptions.OverloadedException;
import com.datastax.driver.core.exceptions.QueryConsistencyException;
import com.datastax.driver.core.exceptions.UnavailableException;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.dropwizard.setup.Environment;
import monasca.persister.repository.RepoException;

    } else {
      logger.warn("[{}]: Query failed, retrying {} of {}: {} ", id, retryCount, maxWriteRetries,
          e.getMessage());

      try {
        Thread.sleep(1000 * (1 << retryCount));
      } catch (InterruptedException ie) {
        logger.debug("[{}]: Interrupted: {}", id, ie);
      }
      _executeQuery(id, query, startTime, retryCount++);
    }
  }

  public int handleFlush_batch(String id) {
    Statement query;
    int flushedCount = 0;

    BatchStatement batch = new BatchStatement(Type.UNLOGGED);
    while ((query = queue.poll()) != null) {
      flushedCount++;
      batch.add(query);
    }

    executeQuery(id, batch, System.nanoTime());

    metricCompleted.inc(flushedCount);

    return flushedCount;
  }


  public int handleFlush(String id) throws RepoException {
