// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/Worker.java
// public interface Worker<T> {
// 
//     /**
//      * Accepts message of type {@code <T>} and processes it.
//      *
//      * @param message Message which will be processed.
//      * @param commitSuccess Callback to be invoked when processing is successful.
//      * @param commitFailure Callback to be invoked in case of a failure.
//      */
//     void accept(T message, Runnable commitSuccess, Runnable commitFailure);
// }
// 
// Path: berserker-cassandra/src/main/java/io/smartcat/berserker/cassandra/configuration/PreparedStatement.java
// public class PreparedStatement {
// 
//     private String id;
//     private String query;
// 
//     /**
//      * Constructs empty prepared statement.
//      */
//     public PreparedStatement() {
//     }
// 
//     /**
//      * Constructs prepared statement with specified <code>id</code> and <code>query</code>.
//      *
//      * @param id Statement id.
//      * @param query Statement query.
//      */
//     public PreparedStatement(String id, String query) {
//         this.id = id;
//         this.query = query;
//     }
// 
//     /**
//      * Returns statement's id.
//      *
//      * @return Statement's id.
//      */
//     public String getId() {
//         return id;
//     }
// 
//     /**
//      * Sets statement's id.
//      *
//      * @param id Id to set.
//      */
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     /**
//      * Returns statement's query.
//      *
//      * @return Statement's query.
//      */
//     public String getQuery() {
//         return query;
//     }
// 
//     /**
//      * Sets statement's query.
//      *
//      * @param query Query to set.
//      */
//     public void setQuery(String query) {
//         this.query = query;
//     }
// }


import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.datastax.driver.core.*;
import com.datastax.driver.core.Cluster.Builder;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import io.smartcat.berserker.api.Worker;
import io.smartcat.berserker.cassandra.configuration.PreparedStatement;
package io.smartcat.berserker.cassandra.worker;




/**
 * Worker that executes CQL statements on provided Cassandra connection points. It uses DataStax's java driver
 * internally.
 */
public class CassandraWorker implements Worker<Map<String, Object>> {

    private static final String QUERY = "query";
    private static final String VALUES = "values";
    private static final String PREPARED_STATEMENT_ID = "preparedStatementId";
    private static final String CONSISTENCY_LEVEL = "consistencyLevel";

    private final Cluster cluster;
    private final Session session;
    private final boolean async;
// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/Worker.java
// public interface Worker<T> {
// 
//     /**
//      * Accepts message of type {@code <T>} and processes it.
//      *
//      * @param message Message which will be processed.
//      * @param commitSuccess Callback to be invoked when processing is successful.
//      * @param commitFailure Callback to be invoked in case of a failure.
//      */
//     void accept(T message, Runnable commitSuccess, Runnable commitFailure);
// }
// 
// Path: berserker-cassandra/src/main/java/io/smartcat/berserker/cassandra/configuration/PreparedStatement.java
// public class PreparedStatement {
// 
//     private String id;
//     private String query;
// 
//     /**
//      * Constructs empty prepared statement.
//      */
//     public PreparedStatement() {
//     }
// 
//     /**
//      * Constructs prepared statement with specified <code>id</code> and <code>query</code>.
//      *
//      * @param id Statement id.
//      * @param query Statement query.
//      */
//     public PreparedStatement(String id, String query) {
//         this.id = id;
//         this.query = query;
//     }
// 
//     /**
//      * Returns statement's id.
//      *
//      * @return Statement's id.
//      */
//     public String getId() {
//         return id;
//     }
// 
//     /**
//      * Sets statement's id.
//      *
//      * @param id Id to set.
//      */
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     /**
//      * Returns statement's query.
//      *
//      * @return Statement's query.
//      */
//     public String getQuery() {
//         return query;
//     }
// 
//     /**
//      * Sets statement's query.
//      *
//      * @param query Query to set.
//      */
//     public void setQuery(String query) {
//         this.query = query;
//     }
// }


// Path: berserker-cassandra/src/main/java/io/smartcat/berserker/cassandra/worker/CassandraWorker.java
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.datastax.driver.core.*;
import com.datastax.driver.core.Cluster.Builder;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import io.smartcat.berserker.api.Worker;
import io.smartcat.berserker.cassandra.configuration.PreparedStatement;

package io.smartcat.berserker.cassandra.worker;




/**
 * Worker that executes CQL statements on provided Cassandra connection points. It uses DataStax's java driver
 * internally.
 */
public class CassandraWorker implements Worker<Map<String, Object>> {

    private static final String QUERY = "query";
    private static final String VALUES = "values";
    private static final String PREPARED_STATEMENT_ID = "preparedStatementId";
    private static final String CONSISTENCY_LEVEL = "consistencyLevel";

    private final Cluster cluster;
    private final Session session;
    private final boolean async;
    private final Map<String, com.datastax.driver.core.PreparedStatement> preparedStatements;