// Path: cocaine-core/src/main/java/cocaine/message/ErrorMessage.java
// public final class ErrorMessage extends Message {
// 
//     public static final class Code {
// 
//         // No handler for requested event
//         public static final int ENOHANDLER = 200;
//         // Invocation failed
//         public static final int EINVFAILED = 212;
//         // Service is disconnected
//         public static final int ESRVDISCON = 220;
// 
//         private Code() { }
//     }
// 
//     private final int code;
//     private final String message;
// 
//     public ErrorMessage(long session, int code, String message) {
//         super(MessageType.ERROR, session);
//         this.code = code;
//         this.message = Preconditions.checkNotNull(message, "Error message can not be null");
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return "ErrorMessage/" + getSession() + ": " + code + " - " + message;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
//         if (!super.equals(o)) {
//             return false;
//         }
// 
//         ErrorMessage that = (ErrorMessage) o;
//         return code == that.code && message.equals(that.message);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = super.hashCode();
//         result = 31 * result + code;
//         result = 31 * result + message.hashCode();
//         return result;
//     }
// 
// }


import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import cocaine.message.ErrorMessage;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;
import rx.subjects.Subject;
        public long getId() {
            return id;
        }

        public Observable<byte[]> getInput() {
            return input;
        }

        public Observer<byte[]> getOutput() {
            return output;
        }
    }

    private static final class Writer implements Observer<byte[]> {

        private final long session;
        private final Worker worker;

        public Writer(long session, Worker worker) {
            this.session = session;
            this.worker = worker;
        }

        @Override
        public void onCompleted() {
            this.worker.sendChoke(session);
        }

        @Override
        public void onError(Throwable error) {
// Path: cocaine-core/src/main/java/cocaine/message/ErrorMessage.java
// public final class ErrorMessage extends Message {
// 
//     public static final class Code {
// 
//         // No handler for requested event
//         public static final int ENOHANDLER = 200;
//         // Invocation failed
//         public static final int EINVFAILED = 212;
//         // Service is disconnected
//         public static final int ESRVDISCON = 220;
// 
//         private Code() { }
//     }
// 
//     private final int code;
//     private final String message;
// 
//     public ErrorMessage(long session, int code, String message) {
//         super(MessageType.ERROR, session);
//         this.code = code;
//         this.message = Preconditions.checkNotNull(message, "Error message can not be null");
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return "ErrorMessage/" + getSession() + ": " + code + " - " + message;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
//         if (!super.equals(o)) {
//             return false;
//         }
// 
//         ErrorMessage that = (ErrorMessage) o;
//         return code == that.code && message.equals(that.message);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = super.hashCode();
//         result = 31 * result + code;
//         result = 31 * result + message.hashCode();
//         return result;
//     }
// 
// }


// Path: cocaine-worker/src/main/java/cocaine/WorkerSessions.java
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import cocaine.message.ErrorMessage;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;
import rx.subjects.Subject;

        public long getId() {
            return id;
        }

        public Observable<byte[]> getInput() {
            return input;
        }

        public Observer<byte[]> getOutput() {
            return output;
        }
    }

    private static final class Writer implements Observer<byte[]> {

        private final long session;
        private final Worker worker;

        public Writer(long session, Worker worker) {
            this.session = session;
            this.worker = worker;
        }

        @Override
        public void onCompleted() {
            this.worker.sendChoke(session);
        }

        @Override
        public void onError(Throwable error) {
            this.worker.sendError(session, ErrorMessage.Code.EINVFAILED, error.getMessage());