// Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
// 
//     private boolean requireMaster = false;
// 
//     /**
//      * @return the requireMaster
//      */
//     public boolean isRequireMaster() {
//         return requireMaster;
//     }
// 
//     /**
//      * @param requireMaster the requireMaster to set
//      */
//     public void setRequireMaster(boolean requireMaster) {
//         this.requireMaster = requireMaster;
//     }
//     
// }
// 
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
// 
//     private final TcpConnection connection;
//     protected F request;
// 
//     public RequestOperation(TcpConnection connection, F request) {
//         this.connection = connection;
//         this.request = request;
//     }
// 
//     //private final Semaphore processing = new Semaphore(0);
// 
//     public TcpPackage getRequestPackage() {
//         return request.getTcpPackage(connection.getSettings());
//     }
// 
//     public UUID getCorrelationId() {
//         return request.getCorrelationId();
//     }
// 
//     public void doneProcessing() {
//         //processing.release();
//     }
// 
//     public void send() {
//         sendAsync();
//         /*try {
//             processing.acquire();
//         } catch (InterruptedException ex) {
//             log.warn("Processing was interrpupted", ex);
//         }*/
//     }
// 
//     public void sendAsync() {
//         connection.send(this);
//     }
// 
//     /**
//      * @return the connection
//      */
//     public TcpConnection getConnection() {
//         return connection;
//     }
// 
//     /**
//      * @return the request
//      */
//     public F getRequest() {
//         return request;
//     }
// 
// }


import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;




public class TcpConnection implements AutoCloseable {

    private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
    
    public static final int HEADER_SIZE = 4;

// Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
// 
//     private boolean requireMaster = false;
// 
//     /**
//      * @return the requireMaster
//      */
//     public boolean isRequireMaster() {
//         return requireMaster;
//     }
// 
//     /**
//      * @param requireMaster the requireMaster to set
//      */
//     public void setRequireMaster(boolean requireMaster) {
//         this.requireMaster = requireMaster;
//     }
//     
// }
// 
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
// 
//     private final TcpConnection connection;
//     protected F request;
// 
//     public RequestOperation(TcpConnection connection, F request) {
//         this.connection = connection;
//         this.request = request;
//     }
// 
//     //private final Semaphore processing = new Semaphore(0);
// 
//     public TcpPackage getRequestPackage() {
//         return request.getTcpPackage(connection.getSettings());
//     }
// 
//     public UUID getCorrelationId() {
//         return request.getCorrelationId();
//     }
// 
//     public void doneProcessing() {
//         //processing.release();
//     }
// 
//     public void send() {
//         sendAsync();
//         /*try {
//             processing.acquire();
//         } catch (InterruptedException ex) {
//             log.warn("Processing was interrpupted", ex);
//         }*/
//     }
// 
//     public void sendAsync() {
//         connection.send(this);
//     }
// 
//     /**
//      * @return the connection
//      */
//     public TcpConnection getConnection() {
//         return connection;
//     }
// 
//     /**
//      * @return the request
//      */
//     public F getRequest() {
//         return request;
//     }
// 
// }


// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package lt.emasina.esj.tcp;




public class TcpConnection implements AutoCloseable {

    private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
    
    public static final int HEADER_SIZE = 4;

    private final Settings settings;