All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.dts.client.config.ClientConfigImpl Maven / Gradle / Ivy

package com.alibaba.dts.client.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

import com.alibaba.dts.client.SchedulerxClient;
import com.alibaba.dts.client.executor.job.context.ClientContextImpl;
import com.alibaba.dts.client.executor.job.processor.FailureJobProcessor;
import com.alibaba.dts.client.executor.job.processor.StopJobProcessor;
import com.alibaba.dts.common.constants.Constants;
import com.alibaba.dts.common.domain.Machine;
import com.alibaba.dts.common.domain.store.EnvGroup;
import com.alibaba.dts.common.exception.InitException;
import com.alibaba.dts.common.logger.SchedulerXLoggerFactory;
import com.alibaba.dts.common.logger.innerlog.Logger;
import com.alibaba.dts.common.service.HttpService;
import com.alibaba.dts.common.util.DiamondHelper;
import com.alibaba.dts.common.util.IniUtil;
import com.alibaba.dts.common.util.RemotingUtil;
import com.alibaba.dts.common.util.StringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;

import com.ali.dpath.DPath;
import org.apache.commons.lang.StringUtils;

/**
 * 客户端各项参数配置
 *
 * @author tianyao.myc
 */
public class ClientConfigImpl implements Constants, ClientConfig {

    private static final Logger logger = SchedulerXLoggerFactory.getLogger(ClientConfigImpl.class);

    /**
     * 远程通信服务线程数量
     */
    private int remotingThreads = DEFAULT_REMOTING_THREADS;

    /**
     * 心跳间隔时间
     */
    private long heartBeatIntervalTime = 12 * DEFAULT_HEART_BEAT_INTERVAL_TIME;

    /**
     * 连接超时时间
     */
    private long connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;

    /**
     * 分组ID
     */
    private String groupId;

    private boolean enableIsolateEnvSupport = false;
    // 蓝绿发布
    private boolean enableBlueGreenDeploy = false;

    public boolean isEnableBlueGreenDeploy() {
        return enableBlueGreenDeploy;
    }

    public void setEnableBlueGreenDeploy(boolean enableBlueGreenDeploy) {
        this.enableBlueGreenDeploy = enableBlueGreenDeploy;
    }

    public boolean isEnableIsolateEnvSupport() {
        return enableIsolateEnvSupport;
    }

    public void setEnableIsolateEnvSupport(boolean enableIsolateEnvSupport) {
        this.enableIsolateEnvSupport = enableIsolateEnvSupport;
    }
    private static Object lock = new Object();
    private static Map clientIdTable = new ConcurrentHashMap();

    /**
     * ZK地址列表
     */
    private String zkHosts;

    /**
     * ZK根目录
     */
    private String namespace = DEFAULT_ZK_ROOT_PATH;

    /**
     * ZK会话超时时间
     */
    private int zkSessionTimeout = DEFAULT_ZK_SESSION_TIMEOUT;

    /**
     * ZK连接超时时间
     */
    private int zkConnectionTimeout = DEFAULT_ZK_CONNECTION_TIMEOUT;

    /**
     * 是否Spring环境
     */
    private boolean isSpring = false;

    /**
     * 队列大小
     */
    private int queueSize = QUEUE_SIZE;

    /**
     * 消费线程数量
     */
    private int consumerThreads = DEFAULT_CONSUMER_THREAD_AMOUNT;

    /**
     * 消费线程数量Map
     */
    private Map consumerThreadsMap = null;

    /**
     * 客户端版本信息
     */
    private String version;

    /**
     * 一次从服务端拉取的任务数量
     */
    private int pageSize = DEFAULT_PAGE_SIZE;

    /**
     * 一次从服务端拉取的任务数量Map
     */
    private Map pageSizeMap = null;

    /**
     * 访问键
     */
    private String accessKey;

    //秘钥
    private String secretKey;

    /**
     * 本地地址
     */
    private String localAddress;

    /**
     * 客户端ID
     */
    private String clientId;

    /**
     * 宕机重试
     */
    private boolean crashRetry = false;

    //空队列暂停拉取间隔时间
    private long pullTaskListOverSleepTime = 20 * 1000L;

    /**
     * 失败任务处理器Map
     */
    private Map failureJobProcessorMap = null;

    /**
     * 停止任务处理器
     */
    private StopJobProcessor stopJobProcessor = null;

    private boolean finishLog = true;

    private boolean isEveryTimeNew = false;

    private boolean zkHostsAutoChange = true;

    private long maxBodySize = 64 * 1024L;

    private String environment;

    private String signature;

    /**
     * 任务Map
     */
    private Map jobMap;

    /**
     * 机器信息
     */
    private Machine machine;

    private String domainName;

    private String serviceGroup;

    private String regionName;

    private String serviceGroupId;

    private boolean autoInit = true;

    private boolean isAgent = false;

    private boolean newInstance = true;

    private boolean newVersion = false;

    private List isolatedUnits = new ArrayList();

    private List isolatedSites = new ArrayList();

    // 蓝绿发布使用机器的环境标签
    private String machineEnv;
    // 蓝绿发布存储原始分组id
    private String orgGroupId;
    // 蓝绿发布映射分组id
    private String blueGreenGroupId;
    // 蓝绿发布机器应用分组
    private String machineGroup;
    // 是否开启vipserver应用分组查询(日常环境不支持)
    private boolean enableMachineGroup = true;

    /**
     * INI配置文件路径
     */
    private String configPath;

    private ClientContextImpl clientContext;

    public ClientConfigImpl(ClientContextImpl clientContext) {
        this.clientContext = clientContext;
    }

    public String getServiceGroupId() {
        return serviceGroupId;
    }

    public void setServiceGroupId(String serviceGroupId) {
        this.serviceGroupId = serviceGroupId;
    }

    private long connectTime;

    public long getConnectTime() {
        return connectTime;
    }

    public void setConnectTime(long connectTime) {
        this.connectTime = connectTime;
    }

    private int innerDebug = 0;

    public int getInnerDebug() {
        return innerDebug;
    }

    public void setInnerDebug(int innerDebug) {
        this.innerDebug = innerDebug;
    }

    private DiamondHelper.DataListener dataListener = new DiamondHelper.DataListener() {
        @Override
        public void receiveConfigInfo(String dataId, String configInfo) {
            domainName = configInfo;
        }
    };

    public void initConfig() throws InitException{
        if (!StringUtil.isBlank(this.configPath)) {

            try {
                Map configMap = IniUtil.getIniValuesFromFile(this.configPath, DTS_BASE_SECTION);

                if (configMap != null && !configMap.isEmpty()) {

                    String groupId = configMap.get("groupId");
                    if (StringUtil.isNotBlank(groupId)) {
                        this.groupId = groupId;
                    }

                    String domainName = configMap.get("domainName");
                    if (StringUtil.isNotBlank(domainName)) {
                        this.domainName = domainName;
                    }

                    String regionName = configMap.get("regionName");
                    if (StringUtil.isNotBlank(regionName)) {
                        this.regionName = regionName;
                    }

                    String innerDebug = configMap.get("innerDebug");
                    if (StringUtil.isNotBlank(innerDebug)) {
                        this.innerDebug = Integer.valueOf(innerDebug) ;
                    }

                    String newVersion = configMap.get("newVersion");
                    if (StringUtil.isNotBlank(newVersion)) {
                        this.newVersion = Boolean.valueOf(newVersion) ;
                    }
                }
            } catch (Exception e) {
                throw new InitException("[ClientConfig]: initConfig error", e);
            }
        }
    }

    /**
     * 初始化
     *
     * com.alibaba.dts.common.exception.InitException
     */
    public void init() throws InitException {

        try {
            this.version = "2.3.3";//Manifests.read("App-Version");
        } catch (Throwable e) {
            throw new InitException("[ClientConfig]: init version error", e);
        }

        this.localAddress = RemotingUtil.getLocalAddress(Constants.ENVIRONMENT_SCX.equals(getEnvironment()));

        try {
            logger.warn("[ClientConfigImpl]: init clientId"
                    + ", thread:" + Thread.currentThread().getName()
                    + ", groupId:" + groupId);

            if (clientIdTable.containsKey(groupId)) {
                this.clientId = clientIdTable.get(groupId);
            } else {
                this.clientId = UUID.randomUUID().toString() + COLON + this.localAddress;
                clientIdTable.put(groupId, clientId);
            }
        } catch (Throwable e) {
            throw new InitException("[ClientConfig]: init clientId error", e);
        }

        if (Constants.ENVIRONMENT_SCX.equals(this.getEnvironment())) {
            if (StringUtil.isBlank(this.domainName)) {
                this.domainName = DEFAULT_DOMAIN_NAME;
            }
        } else {
            if (StringUtil.isBlank(this.domainName)) {
                try {
                    this.domainName = DiamondHelper.getData(HttpService.DOMAIN_NAME_DATA_ID, 10 * 1000L);
                    DiamondHelper.addListener(HttpService.DOMAIN_NAME_DATA_ID, dataListener);
                } catch (Throwable e) {
                    throw new InitException("[ClientConfig]: get domainName from diamond error", e);
                }
            }
        }

        if (StringUtil.isBlank(this.domainName)) {
            throw new InitException("[ClientConfig]: domainName is empty error, domainName:" + this.domainName);
        }
        // 蓝绿发布开关是否打开
        if (!Constants.ENVIRONMENT_SCX.equals(this.getEnvironment()) && !Constants.ENVIRONMENT_PRIVATE_CLOUD.equals(this.getEnvironment())
            && enableBlueGreenDeploy) {
            synchronized (lock) {
                // 解决重复调用init,保证orgGroupId只初始化一次
                if (StringUtils.isBlank(orgGroupId)) {
                    // 根据ip和应用分组获取机器打标
                    String clientIp = RemotingUtil.getLocalAddress();
                    // 获取机器的应用分组
                    String machineGroup = StringUtils.EMPTY;
                    String enableMachineGroupConfig  = StringUtils.EMPTY;
                    try {
                        // 日常环境不支持vipserver调用
                        enableMachineGroupConfig = DiamondHelper.getData(ENABLE_MACHINE_GROUP, 10*1000L);
                        if (StringUtils.isNotBlank(enableMachineGroupConfig)) {
                            enableMachineGroup = Boolean.parseBoolean(enableMachineGroupConfig);
                        }
                    } catch (Exception e) {
                        enableMachineGroup = true;
                        logger.warn("enableMachineGroupConfig:" + enableMachineGroupConfig +" parse error.",e);
                    }
                    // 预发和线上环境调用vipserver获取应用分组
                    if (enableMachineGroup) {
                        machineGroup = calculateMachineGroup(clientIp);
                        logger.warn("machineGroup is: "+machineGroup);
                        // 保存该机器的应用分组名称
                        setMachineGroup(machineGroup);
                    }
                    // DPath获取机器标签
                    String machineEnv = DPath.envOf(machineGroup, clientIp);
                    // 保存原始分组id和原始环境标签
                    this.orgGroupId = getGroupId();
                    this.machineEnv = machineEnv;
                    if (!Constants.DEFAULT_PATH_ENV.equals(machineEnv)) {
                        // 非Base环境重新获取对应分组
                        String realGroupId = calculateRealGroupIdForDeploy(groupId, machineEnv);
                        this.groupId = realGroupId;
                        clientContext.getNodeConfig().setGroupId(realGroupId);
                        // 保存蓝绿映射分组id
                        this.setBlueGreenGroupId(realGroupId);
                    }
                    logger.warn("blue-green deploy ip: " + clientIp + " machineGroup: "+machineGroup+ " env:" + machineEnv
                        + " orgGroupId: "+getOrgGroupId() + " newGroupId: "+ getBlueGreenGroupId());
                } else {
                    logger.warn("blue-green deploy orgGroupId: "+getOrgGroupId() + " has initialized blueGreenGroupId: "+ getBlueGreenGroupId());
                }
            }
        }
        // 蓝绿发布优先级高
        if (!Constants.ENVIRONMENT_SCX.equals(this.getEnvironment()) && enableIsolateEnvSupport
            && !enableBlueGreenDeploy) {
            setRealGroupId(domainName, groupId);
            //            setRealGroupId("localhost:8080", groupId);
        }
    }

    private void setRealGroupId(String domainName, String groupId) throws InitException {
        //TODO 计算真正的GROUPID
        String realGroupId = calculateRealGroupId(domainName, groupId);
        this.groupId = realGroupId;
        clientContext.getNodeConfig().setGroupId(realGroupId);
    }

    private String calculateRealGroupId(String domainName, String groupId) throws InitException {
        String ip = RemotingUtil.getLocalAddress();
        if (ip == null) {
            throw new RuntimeException("local ip is null");
        }
        String vipUrl = "http://openapi.vipserver.alibaba-inc.com/vipserver/api/armoryNode?action=view&ip=" + ip;

        String env = requestEnvFromVipServer(vipUrl);

        if (env == null || "".equals(env)) {
            return groupId;
        }

        logger.warn(
            "Your client start in isolated env, original non-isolated groupId:" + groupId + ", current client env:"
                + env + ", getting isolated groupId...");
        String dtsConsoleUrl = "http://" + domainName
            + "/dts-console/apiManager.do?action=ApiAction&event_submit_do_get_real_group=1&env=" + env
            + "&defaultGroupId=" + groupId;
        String realEnvGroupId = requestRealEnvGroupId(dtsConsoleUrl);
        if (realEnvGroupId == null || realEnvGroupId.trim().isEmpty()) {
            throw new InitException(
                "The env is an isolated env, but no isolated env group exists, domainName=" + domainName
                    + ", defaultGroupId=" + groupId);
        }
        logger.warn("Your isolated groupId:" + realEnvGroupId + ", this client running within this group!!!");
        return realEnvGroupId;
    }

    // 蓝绿发布获取机器的应用分组名
    public String calculateMachineGroup(String ip) throws InitException{
        String machineGroup = StringUtils.EMPTY;
        if (ip == null) {
            throw new RuntimeException("local ip is null");
        }
        String vipUrl = "http://jmenv.Api.vip.tbsite.net/vipserver/api/armoryNode?action=view&ip=" + ip;
        String response = clientContext.getHttpService().request(vipUrl).getValue();
        if (response != null) {
            try {
                logger.info("calculateMachineGroup response before escape: " + response);
                response = response.replace("\\", "");
                response = response.replace("\"{", "{");
                response = response.replace("}\"", "}");
                logger.info("calculateMachineGroup response after escape: " + response);
                JSONObject jsonObject = JSON.parseObject(response);
                machineGroup = jsonObject.getJSONObject("msg").getString("nodegroup");
                if (StringUtils.isBlank(machineGroup)) {
                    throw new InitException("calculateMachineGroup error machineGroup is blank.");
                } else {
                    logger.info("calculateMachineGroup machineGroup is "+ machineGroup);
                }
                return machineGroup;
            } catch (Exception e) {
                throw new InitException("calculateMachineGroup failed to parse response", e);
            }
        }
        logger.error("failed to get nodegroup, url=" + vipUrl
            + SchedulerxClient.class.getCanonicalName());
        throw new InitException("failed to get nodegroup, vipUrl=" + vipUrl);
    }


    // 蓝绿发布使用
    public String calculateRealGroupIdForDeploy(String groupId, String env) throws InitException{
        // 备用机器分组console重新获取分组
        String dtsConsoleUrl = "http://" + domainName
            + "/dts-console/apiManager.do?action=ApiAction&event_submit_do_get_real_group=1&env=" + env
            + "&defaultGroupId=" + groupId+"&source=bluegreen";
        String realEnvGroupId = requestRealEnvGroupId(dtsConsoleUrl);
        if (realEnvGroupId == null || realEnvGroupId.trim().isEmpty()) {
            throw new InitException(
                "The env is a green blue deploy env, but get real group fail, domainName=" + domainName
                    + ", defaultGroupId=" + groupId + " env: "+env);
        }
        return realEnvGroupId;
    }

    private String requestEnvFromVipServer(String vipUrl) throws InitException {
        String response = clientContext.getHttpService().request(vipUrl).getValue();
        if (response != null) {
            try {
                logger.info("response before escape: " + response);
                response = response.replace("\\", "");
                response = response.replace("\"{", "{");
                response = response.replace("}\"", "}");
                logger.info("response after escape: " + response);
                JSONObject jsonObject = JSON.parseObject(response);
                return jsonObject.getJSONObject("msg").getString("ipGroup");
            } catch (Exception e) {
                throw new InitException("failed to parse response", e);
            }
        }

        logger.error("failed to get env, url=" + vipUrl
            + ", if the app env is daily, pls set enableIsolateEnvSupport=false as a property of "
            + SchedulerxClient.class.getCanonicalName());
        throw new InitException("failed to get env, vipUrl=" + vipUrl);
    }

    private String requestRealEnvGroupId(String dtsConsoleUrl) throws InitException {
        String response = clientContext.getHttpService().request(dtsConsoleUrl).getValue();
        if (response != null) {
            Response envGroupResponse = JSON.parseObject(response, new TypeReference>() {
            });
            if (envGroupResponse != null && envGroupResponse.isSuccess()) {
                EnvGroup envGroup = envGroupResponse.getData();
                if (envGroup != null && envGroup.getRealGroupId() != null && !envGroup.getRealGroupId().trim()
                    .isEmpty()) {
                    return envGroup.getRealGroupId();
                }
            }
        }
        throw new InitException(
            "The env is an isolated env or blue-green deploy, but no isolated env group exists, dtsConsoleUrl=" + dtsConsoleUrl);
    }

    static class Response {
        private boolean success;
        private T data;

        public boolean isSuccess() {
            return success;
        }

        public void setSuccess(boolean success) {
            this.success = success;
        }

        public T getData() {
            return data;
        }

        public void setData(T data) {
            this.data = data;
        }
    }

    @Override
    public void removeDataListener() {
        DiamondHelper.removeListener(HttpService.DOMAIN_NAME_DATA_ID, this.dataListener);
    }

    public int getRemotingThreads() {
        return remotingThreads;
    }

    public void setRemotingThreads(int remotingThreads) {
        if (remotingThreads <= 0) {
            this.remotingThreads = DEFAULT_REMOTING_THREADS;
            logger.warn("[ClientConfig]: setRemotingThreads error, you set remotingThreads:" + remotingThreads);
            return;
        }
        if (remotingThreads > 10 * DEFAULT_REMOTING_THREADS) {
            this.remotingThreads = 10 * DEFAULT_REMOTING_THREADS;
            logger.warn(
                "[ClientConfig]: setRemotingThreads too large, you set remotingThreads:" + remotingThreads + ", max:"
                    + (10 * DEFAULT_REMOTING_THREADS));
            return;
        }
        this.remotingThreads = remotingThreads;
    }

    public long getHeartBeatIntervalTime() {
        return heartBeatIntervalTime;
    }

    public void setHeartBeatIntervalTime(long heartBeatIntervalTime) {
        if (heartBeatIntervalTime <= 0L) {
            this.heartBeatIntervalTime = DEFAULT_HEART_BEAT_INTERVAL_TIME;
            logger.warn("[ClientConfig]: setHeartBeatIntervalTime error, you set heartBeatIntervalTime:"
                + heartBeatIntervalTime);
            return;
        }
        if (heartBeatIntervalTime > 20 * DEFAULT_HEART_BEAT_INTERVAL_TIME) {
            this.heartBeatIntervalTime = 20 * DEFAULT_HEART_BEAT_INTERVAL_TIME;
            logger.warn("[ClientConfig]: setHeartBeatIntervalTime too large, you set heartBeatIntervalTime:"
                + heartBeatIntervalTime + ", max:" + (20 * DEFAULT_HEART_BEAT_INTERVAL_TIME));
            return;
        }
        this.heartBeatIntervalTime = heartBeatIntervalTime;
    }

    public long getConnectionTimeout() {
        return connectionTimeout;
    }

    public void setConnectionTimeout(long connectionTimeout) {
        if (connectionTimeout <= 0L) {
            this.connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
            logger.warn("[ClientConfig]: setConnectionTimeout error, you set connectionTimeout:" + connectionTimeout);
            return;
        }
        if (connectionTimeout > 10 * DEFAULT_CONNECTION_TIMEOUT) {
            this.connectionTimeout = 10 * DEFAULT_CONNECTION_TIMEOUT;
            logger.warn("[ClientConfig]: setConnectionTimeout too large, you set connectionTimeout:" + connectionTimeout
                + ", max:" + (10 * DEFAULT_CONNECTION_TIMEOUT));
            return;
        }
        this.connectionTimeout = connectionTimeout;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getZkHosts() {
        return zkHosts;
    }

    public void setZkHosts(String zkHosts) {
        this.zkHosts = zkHosts;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

    public int getZkSessionTimeout() {
        return zkSessionTimeout;
    }

    public void setZkSessionTimeout(int zkSessionTimeout) {
        if (zkSessionTimeout <= 0) {
            this.zkSessionTimeout = DEFAULT_ZK_SESSION_TIMEOUT;
            logger.warn("[ClientConfig]: setZkSessionTimeout error, you set zkSessionTimeout:" + zkSessionTimeout);
            return;
        }
        if (zkSessionTimeout > 20 * DEFAULT_ZK_SESSION_TIMEOUT) {
            this.zkSessionTimeout = 20 * DEFAULT_ZK_SESSION_TIMEOUT;
            logger.warn(
                "[ClientConfig]: setZkSessionTimeout too large, you set zkSessionTimeout:" + zkSessionTimeout + ", max:"
                    + (20 * DEFAULT_ZK_SESSION_TIMEOUT));
            return;
        }
        this.zkSessionTimeout = zkSessionTimeout;
    }

    public int getZkConnectionTimeout() {
        return zkConnectionTimeout;
    }

    public void setZkConnectionTimeout(int zkConnectionTimeout) {
        if (zkConnectionTimeout <= 0) {
            this.zkConnectionTimeout = DEFAULT_ZK_CONNECTION_TIMEOUT;
            logger.warn(
                "[ClientConfig]: setZkConnectionTimeout error, you set zkConnectionTimeout:" + zkConnectionTimeout);
            return;
        }
        if (zkConnectionTimeout > 20 * DEFAULT_ZK_CONNECTION_TIMEOUT) {
            this.zkConnectionTimeout = 20 * DEFAULT_ZK_CONNECTION_TIMEOUT;
            logger.warn(
                "[ClientConfig]: setZkConnectionTimeout too large, you set zkConnectionTimeout:" + zkConnectionTimeout
                    + ", max:" + (20 * DEFAULT_ZK_CONNECTION_TIMEOUT));
            return;
        }
        this.zkConnectionTimeout = zkConnectionTimeout;
    }

    public boolean isSpring() {
        return isSpring;
    }

    public void setSpring(boolean isSpring) {
        this.isSpring = isSpring;
    }

    public int getQueueSize() {
        return queueSize;
    }

    public void setQueueSize(int queueSize) {
        if (queueSize <= 0) {
            this.queueSize = QUEUE_SIZE;
            logger.warn("[ClientConfig]: setQueueSize error, you set queueSize:" + queueSize);
            return;
        }
        if (queueSize > 10 * QUEUE_SIZE) {
            this.queueSize = 10 * QUEUE_SIZE;
            logger.warn("[ClientConfig]: setQueueSize too large, you set queueSize:" + queueSize + ", max:" + (10
                * QUEUE_SIZE));
            return;
        }
        this.queueSize = queueSize;
    }

    public int getConsumerThreads() {
        return consumerThreads;
    }

    public void setConsumerThreads(int consumerThreads) {
        this.consumerThreads = checkConsumerThreads(consumerThreads);
    }

    public int checkConsumerThreads(int consumerThreads) {
        if (consumerThreads <= 0) {
            logger.warn("[ClientConfig]: setConsumerThreads error, you set consumerThreads:" + consumerThreads);
            return DEFAULT_CONSUMER_THREAD_AMOUNT;
        }
        if (consumerThreads > 100 * DEFAULT_CONSUMER_THREAD_AMOUNT) {
            logger.warn(
                "[ClientConfig]: setConsumerThreads too large, you set consumerThreads:" + consumerThreads + ", max:"
                    + (100 * DEFAULT_CONSUMER_THREAD_AMOUNT));
            return 100 * DEFAULT_CONSUMER_THREAD_AMOUNT;
        }
        return consumerThreads;
    }

    public Map getConsumerThreadsMap() {
        return consumerThreadsMap;
    }

    public void setConsumerThreadsMap(Map consumerThreadsMap) {
        this.consumerThreadsMap = consumerThreadsMap;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = checkPageSize(pageSize);
    }

    public int checkPageSize(int pageSize) {
        if (pageSize <= 0) {
            logger.warn("[ClientConfig]: setPageSize error, you set pageSize:" + pageSize);
            return DEFAULT_PAGE_SIZE;
        }
        if (pageSize > 2 * DEFAULT_PAGE_SIZE) {
            logger.warn("[ClientConfig]: setPageSize too large, you set pageSize:" + pageSize + ", max:" + (2
                * DEFAULT_PAGE_SIZE));
            return 2 * DEFAULT_PAGE_SIZE;
        }
        return pageSize;
    }

    public Map getPageSizeMap() {
        return pageSizeMap;
    }

    public void setPageSizeMap(Map pageSizeMap) {
        this.pageSizeMap = pageSizeMap;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getLocalAddress() {
        return localAddress;
    }

    public void setLocalAddress(String localAddress) {
        this.localAddress = localAddress;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public boolean isCrashRetry() {
        return crashRetry;
    }

    public void setCrashRetry(boolean crashRetry) {
        this.crashRetry = crashRetry;
    }

    public long getPullTaskListOverSleepTime() {
        return pullTaskListOverSleepTime;
    }

    public void setPullTaskListOverSleepTime(long pullTaskListOverSleepTime) {
        this.pullTaskListOverSleepTime = pullTaskListOverSleepTime;
    }

    public Map getFailureJobProcessorMap() {
        return failureJobProcessorMap;
    }

    public void setFailureJobProcessorMap(
        Map failureJobProcessorMap) {
        this.failureJobProcessorMap = failureJobProcessorMap;
    }

    public boolean isFinishLog() {
        return finishLog;
    }

    public void setFinishLog(boolean finishLog) {
        this.finishLog = finishLog;
    }

    public StopJobProcessor getStopJobProcessor() {
        return stopJobProcessor;
    }

    public void setStopJobProcessor(StopJobProcessor stopJobProcessor) {
        this.stopJobProcessor = stopJobProcessor;
    }

    public boolean isEveryTimeNew() {
        return isEveryTimeNew;
    }

    public void setEveryTimeNew(boolean isEveryTimeNew) {
        this.isEveryTimeNew = isEveryTimeNew;
    }

    public boolean isZkHostsAutoChange() {
        return zkHostsAutoChange;
    }

    public void setZkHostsAutoChange(boolean zkHostsAutoChange) {
        this.zkHostsAutoChange = zkHostsAutoChange;
    }

    public long getMaxBodySize() {
        return maxBodySize;
    }

    public void setMaxBodySize(long maxBodySize) {
        this.maxBodySize = maxBodySize;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getEnvironment() {
        return environment;
    }

    public void setEnvironment(String environment) {
        this.environment = environment;
    }

    public Map getJobMap() {
        return jobMap;
    }

    public void setJobMap(Map jobMap) {
        this.jobMap = jobMap;
    }

    public Machine getMachine() {
        return machine;
    }

    public void setMachine(Machine machine) {
        this.machine = machine;
    }

    public String getDomainName() {
        return domainName;
    }

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    public String getServiceGroup() {
        return serviceGroup;
    }

    public void setServiceGroup(String serviceGroup) {
        this.serviceGroup = serviceGroup;
    }

    public String getRegionName() {
        return regionName;
    }

    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public boolean isAutoInit() {
        return autoInit;
    }

    public void setAutoInit(boolean autoInit) {
        this.autoInit = autoInit;
    }

    public String getConfigPath() {
        return configPath;
    }

    public void setConfigPath(String configPath) {
        this.configPath = configPath;
    }

    public boolean isAgent() {
        return isAgent;
    }

    public void setAgent(boolean isAgent) {
        this.isAgent = isAgent;
    }

    public boolean isNewInstance() {
        return newInstance;
    }

    public void setNewInstance(boolean newInstance) {
        this.newInstance = newInstance;
    }

    public boolean isNewVersion() {
        return newVersion;
    }

    public void setNewVersion(boolean newVersion) {
        this.newVersion = newVersion;
    }

    public String getMachineEnv() {
        return machineEnv;
    }

    public void setMachineEnv(String machineEnv) {
        this.machineEnv = machineEnv;
    }

    public String getOrgGroupId() {
        return orgGroupId;
    }

    public void setOrgGroupId(String orgGroupId) {
        this.orgGroupId = orgGroupId;
    }

    public String getBlueGreenGroupId() {
        return blueGreenGroupId;
    }

    public void setBlueGreenGroupId(String blueGreenGroupId) {
        this.blueGreenGroupId = blueGreenGroupId;
    }

    public String getMachineGroup() {
        return machineGroup;
    }

    public void setMachineGroup(String machineGroup) {
        this.machineGroup = machineGroup;
    }

    public boolean isEnableMachineGroup() {
        return enableMachineGroup;
    }

    public void setEnableMachineGroup(boolean enableMachineGroup) {
        this.enableMachineGroup = enableMachineGroup;
    }

    @Override
    public String toString() {
        return "ClientConfig [remotingThreads=" + remotingThreads
            + ", heartBeatIntervalTime=" + heartBeatIntervalTime
            + ", connectionTimeout=" + connectionTimeout + ", groupId="
            + groupId + ", zkHosts=" + zkHosts + ", namespace=" + namespace
            + ", zkSessionTimeout=" + zkSessionTimeout
            + ", zkConnectionTimeout=" + zkConnectionTimeout
            + ", isSpring=" + isSpring + ", queueSize=" + queueSize
            + ", consumerThreads=" + consumerThreads
            + ", consumerThreadsMap=" + consumerThreadsMap + ", version="
            + version + ", pageSize=" + pageSize + ", pageSizeMap="
            + pageSizeMap + ", accessKey=" + accessKey + ", secretKey="
            + secretKey + ", localAddress=" + localAddress + ", clientId="
            + clientId + ", crashRetry=" + crashRetry
            + ", pullTaskListOverSleepTime=" + pullTaskListOverSleepTime
            + ", failureJobProcessorMap=" + failureJobProcessorMap
            + ", stopJobProcessor=" + stopJobProcessor + ", finishLog="
            + finishLog + ", isEveryTimeNew=" + isEveryTimeNew
            + ", zkHostsAutoChange=" + zkHostsAutoChange + ", maxBodySize="
            + maxBodySize + ", environment=" + environment + ", signature="
            + signature + ", jobMap=" + jobMap + ", machine=" + machine
            + ", domainName=" + domainName + ", serviceGroup="
            + serviceGroup + ", regionName=" + regionName +
            " ,enableBlueGreenDeploy= "+enableBlueGreenDeploy +
            ", machineGroup= "+machineGroup + " ,machineEnv="+machineEnv
            + ", serviceGroupId=" + serviceGroupId + ", autoInit="
            + autoInit + ", isAgent=" + isAgent + ", newInstance="
            + newInstance + ", configPath=" + configPath + ", connectTime="
            + connectTime + ", innerDebug=" + innerDebug + ", newVersion="
            + newVersion + "]";
    }

    @Override
    public List getIsolatedUnites() {
        return isolatedUnits;
    }

    @Override
    public void setIsolatedUnits(List units) {
        this.isolatedUnits = units;
    }

    @Override
    public List getIsolatedSites() {
        return isolatedSites;
    }

    @Override
    public void setIsolatedSites(List sites) {
        this.isolatedSites = sites;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy