// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java
// public class Constants {
// 
//     public static final String ZK_PATH_PREFIX = "/ourea";
// 
//     public static final String PATH_SEPARATOR = "/";
// 
//     public static final String GROUP_KEY = "group";
// 
//     public static final String VERSION_KEY = "version";
// 
//     public static final String INTERFACE_KEY = "interface";
// 
//     public static final String INVOKER_KEY = "invoker";
// 
//     public static final String DEFAULT_INVOKER_PROVIDER = "provider";
// 
//     public static final String DEFAULT_INVOKER_CONSUMER = "consumer";
// 
//     public static final String DEFAULT_GROUP_NAME = "ourea";
// 
//     public static final String DEFAULT_VERSION_VALUE = "1.0.0";
// 
//     public static final int DEFAULT_WEIGHT_VALUE = 0;
// 
//     public static final int DEFAULT_TIMEOUT_VALUE = 1000;
// 
//     public static final int DEFAULT_THRIFT_PORT = 1000;
// }
// 
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java
// public interface ILoadBalanceStrategy {
// 
//     /**
//      * 从众多连接池子中选择其中一个池子.
//      * 
//      * @param invokeConns
//      * @return
//      */
//     public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation);
// }
// 
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java
// public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy {
// 
//     private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>();
// 
//     @Override
//     protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
// 
//         String key = invocation.getInterfaceName() + invocation.getMethodName();
//         Integer cur = current.get(key);
// 
//         if (cur == null || cur >= Integer.MAX_VALUE - 1) {
//             cur = 0;
//         }
//         current.putIfAbsent(key, cur + 1);
// 
//         try {
//             return invokeConns.get(cur % invokeConns.size());
//         }catch (IndexOutOfBoundsException e){
//             return invokeConns.get(0);
//         }
// 
//     }
// }


import com.taocoder.ourea.core.common.Constants;
import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy;
import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy;
/*
 * Copyright (c) 2015 taocoder.com. All Rights Reserved.
 */
package com.taocoder.ourea.core.config;


/**
 * thrift client 相关配置
 *
 * @author tao.ke Date: 16/4/28 Time: 上午10:54
 */
public class ThriftClientConfig {

    /**
     * 服务组,不同组之间不能服务交互
     */
    private String group = Constants.DEFAULT_GROUP_NAME;

    /**
     * 服务版本,不同版本之间不能交互
     */
    private String version = Constants.DEFAULT_VERSION_VALUE;

    /**
     * 超时时间
     */
    private int timeout = Constants.DEFAULT_TIMEOUT_VALUE;

    /**
     * 服务重试次数,默认重试一次
     */
    private int retryTimes = 1;

    /**
     * 服务client的负载策略
     */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java
// public class Constants {
// 
//     public static final String ZK_PATH_PREFIX = "/ourea";
// 
//     public static final String PATH_SEPARATOR = "/";
// 
//     public static final String GROUP_KEY = "group";
// 
//     public static final String VERSION_KEY = "version";
// 
//     public static final String INTERFACE_KEY = "interface";
// 
//     public static final String INVOKER_KEY = "invoker";
// 
//     public static final String DEFAULT_INVOKER_PROVIDER = "provider";
// 
//     public static final String DEFAULT_INVOKER_CONSUMER = "consumer";
// 
//     public static final String DEFAULT_GROUP_NAME = "ourea";
// 
//     public static final String DEFAULT_VERSION_VALUE = "1.0.0";
// 
//     public static final int DEFAULT_WEIGHT_VALUE = 0;
// 
//     public static final int DEFAULT_TIMEOUT_VALUE = 1000;
// 
//     public static final int DEFAULT_THRIFT_PORT = 1000;
// }
// 
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java
// public interface ILoadBalanceStrategy {
// 
//     /**
//      * 从众多连接池子中选择其中一个池子.
//      * 
//      * @param invokeConns
//      * @return
//      */
//     public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation);
// }
// 
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java
// public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy {
// 
//     private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>();
// 
//     @Override
//     protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
// 
//         String key = invocation.getInterfaceName() + invocation.getMethodName();
//         Integer cur = current.get(key);
// 
//         if (cur == null || cur >= Integer.MAX_VALUE - 1) {
//             cur = 0;
//         }
//         current.putIfAbsent(key, cur + 1);
// 
//         try {
//             return invokeConns.get(cur % invokeConns.size());
//         }catch (IndexOutOfBoundsException e){
//             return invokeConns.get(0);
//         }
// 
//     }
// }


// Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftClientConfig.java
import com.taocoder.ourea.core.common.Constants;
import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy;
import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy;

/*
 * Copyright (c) 2015 taocoder.com. All Rights Reserved.
 */
package com.taocoder.ourea.core.config;


/**
 * thrift client 相关配置
 *
 * @author tao.ke Date: 16/4/28 Time: 上午10:54
 */
public class ThriftClientConfig {

    /**
     * 服务组,不同组之间不能服务交互
     */
    private String group = Constants.DEFAULT_GROUP_NAME;

    /**
     * 服务版本,不同版本之间不能交互
     */
    private String version = Constants.DEFAULT_VERSION_VALUE;

    /**
     * 超时时间
     */
    private int timeout = Constants.DEFAULT_TIMEOUT_VALUE;

    /**
     * 服务重试次数,默认重试一次
     */
    private int retryTimes = 1;

    /**
     * 服务client的负载策略
     */
    private ILoadBalanceStrategy loadBalanceStrategy = new RoundRobinLoadBalanceStrategy();