// Path: src/main/java/com/baidu/unbiz/multiengine/transport/dto/Signal.java
// public class Signal<T> {
// 
//     protected long seqId;
//     protected T message;
//     protected SignalType type = SignalType.TASK_COMMOND;
// 
//     public Signal() {
//     }
// 
//     public Signal(T message) {
//         this.message = message;
//     }
// 
//     public T getMessage() {
//         return message;
//     }
// 
//     public void setMessage(T message) {
//         this.message = message;
//     }
// 
//     public long getSeqId() {
//         return seqId;
//     }
// 
//     public void setSeqId(long seqId) {
//         this.seqId = seqId;
//     }
// 
//     public String toString() {
//         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
//     }
// 
//     public SignalType getType() {
//         return type;
//     }
// 
//     public void setType(SignalType type) {
//         this.type = type;
//     }
// }


import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.springframework.util.Assert;
import com.baidu.unbiz.multiengine.transport.dto.Signal;
import com.baidu.unbiz.multitask.log.AopLogFactory;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
package com.baidu.unbiz.multiengine.transport.client;




/**
 * Created by wangchongjie on 16/4/11.
 */
public class TaskClientContext {
    private static final Logger LOG = AopLogFactory.getLogger(TaskClientContext.class);

    public static ConcurrentHashMap<String, Channel> sessionChannelMap = new ConcurrentHashMap<String, Channel>();
    public static ConcurrentHashMap<String, TaskClient> sessionClientMap = new ConcurrentHashMap<String, TaskClient>();
    public static final AttributeKey<String> SESSION_ATTRIBUTE = AttributeKey.newInstance("SESSION_ATTRIBUTE");

    private static ConcurrentHashMap<String, ConcurrentHashMap<Long, SendFuture>> sessionResultMap =
            new ConcurrentHashMap<String, ConcurrentHashMap<Long, SendFuture>>();
    private static Long DEFAULT_RESULT_CAPACITY = 1000L;

    public static void placeSessionResult(String sessionKey, Long seqId, SendFuture futrue) {
        ConcurrentHashMap<Long, SendFuture> resultMap = sessionResultMap.get(sessionKey);
        if (resultMap == null) {
            resultMap = new ConcurrentHashMap<Long, SendFuture>();
            sessionResultMap.putIfAbsent(sessionKey, resultMap);
            resultMap = sessionResultMap.get(sessionKey);
        }
        resultMap.put(seqId, futrue);
    }

// Path: src/main/java/com/baidu/unbiz/multiengine/transport/dto/Signal.java
// public class Signal<T> {
// 
//     protected long seqId;
//     protected T message;
//     protected SignalType type = SignalType.TASK_COMMOND;
// 
//     public Signal() {
//     }
// 
//     public Signal(T message) {
//         this.message = message;
//     }
// 
//     public T getMessage() {
//         return message;
//     }
// 
//     public void setMessage(T message) {
//         this.message = message;
//     }
// 
//     public long getSeqId() {
//         return seqId;
//     }
// 
//     public void setSeqId(long seqId) {
//         this.seqId = seqId;
//     }
// 
//     public String toString() {
//         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
//     }
// 
//     public SignalType getType() {
//         return type;
//     }
// 
//     public void setType(SignalType type) {
//         this.type = type;
//     }
// }


// Path: src/main/java/com/baidu/unbiz/multiengine/transport/client/TaskClientContext.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.springframework.util.Assert;
import com.baidu.unbiz.multiengine.transport.dto.Signal;
import com.baidu.unbiz.multitask.log.AopLogFactory;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

package com.baidu.unbiz.multiengine.transport.client;




/**
 * Created by wangchongjie on 16/4/11.
 */
public class TaskClientContext {
    private static final Logger LOG = AopLogFactory.getLogger(TaskClientContext.class);

    public static ConcurrentHashMap<String, Channel> sessionChannelMap = new ConcurrentHashMap<String, Channel>();
    public static ConcurrentHashMap<String, TaskClient> sessionClientMap = new ConcurrentHashMap<String, TaskClient>();
    public static final AttributeKey<String> SESSION_ATTRIBUTE = AttributeKey.newInstance("SESSION_ATTRIBUTE");

    private static ConcurrentHashMap<String, ConcurrentHashMap<Long, SendFuture>> sessionResultMap =
            new ConcurrentHashMap<String, ConcurrentHashMap<Long, SendFuture>>();
    private static Long DEFAULT_RESULT_CAPACITY = 1000L;

    public static void placeSessionResult(String sessionKey, Long seqId, SendFuture futrue) {
        ConcurrentHashMap<Long, SendFuture> resultMap = sessionResultMap.get(sessionKey);
        if (resultMap == null) {
            resultMap = new ConcurrentHashMap<Long, SendFuture>();
            sessionResultMap.putIfAbsent(sessionKey, resultMap);
            resultMap = sessionResultMap.get(sessionKey);
        }
        resultMap.put(seqId, futrue);
    }

    public static void fillSessionResult(String sessionKey, Signal signal) {