com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter.java Source code

Java tutorial

Introduction

Here is the source code for com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter.java

Source

/*
 * Copyright (C) 2010-2101 Alibaba Group Holding Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.otter.shared.common.model.config.pipeline;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.util.ReflectionUtils;

import com.alibaba.otter.shared.common.model.config.Transient;
import com.alibaba.otter.shared.common.model.config.channel.ChannelParameter;
import com.alibaba.otter.shared.common.model.config.channel.ChannelParameter.RemedyAlgorithm;
import com.alibaba.otter.shared.common.model.config.channel.ChannelParameter.SyncConsistency;
import com.alibaba.otter.shared.common.model.config.channel.ChannelParameter.SyncMode;
import com.alibaba.otter.shared.common.model.config.parameter.SystemParameter;
import com.alibaba.otter.shared.common.model.config.parameter.SystemParameter.RetrieverType;
import com.alibaba.otter.shared.common.utils.OtterToStringStyle;

/**
 * pipeline?
 * 
 * @author jianghang 2011-9-2 ?10:42:27
 */
public class PipelineParameter implements Serializable {

    private static final long serialVersionUID = 8112362911827913152L;
    private Long pipelineId;
    private Long parallelism = 3L; // 
    private LoadBanlanceAlgorithm lbAlgorithm = LoadBanlanceAlgorithm.Random; // ?
    private Boolean home = false; // ?
    private SelectorMode selectorMode = SelectorMode.Canal; // ???
    private String destinationName;
    private Short mainstemClientId; // mainstemid
    private Integer mainstemBatchsize = 10000 * 10; // mainstem?
    private Integer extractPoolSize = 5; // extract???
    private Integer loadPoolSize = 5; // load???
    private Integer fileLoadPoolSize = 5; // ?

    private Boolean dumpEvent = true; // ??dumpevent
    private Boolean dumpSelector = true; // ??dumpSelector?
    private Boolean dumpSelectorDetail = true; // ??dumpSelector?
    private PipeChooseMode pipeChooseType = PipeChooseMode.AUTOMATIC; // pipe?
    private Boolean useBatch = true; // ?batch?
    private Boolean skipSelectException = false; // ?select
    private Boolean skipLoadException = false; // ?load
    private ArbitrateMode arbitrateMode = ArbitrateMode.ZOOKEEPER; // ?
    private Long batchTimeout = -1L; // ???,-1?0>0(??)
    private Boolean fileDetect = false; // ???
    private Boolean skipFreedom = false; // ??
    private Boolean useLocalFileMutliThread = false; // ??local
                                                     // file??
    private Boolean useFileEncrypt = false; // ??
    private Boolean useExternalIp = false; // ?Ip
    private Boolean useTableTransform = true; // ????true?
    private Boolean enableCompatibleMissColumn = true; // ?????
    private Boolean skipNoRow = false; // ??
    private String channelInfo; // ??retl_markmessageParsecheck?
    private Boolean dryRun = false; // ??dry
                                    // run?load???
    private Boolean ddlSync = true; // ??ddl?
    private Boolean skipDdlException = false; // ?ddl

    // ================================= channel parameter
    // ================================

    @Transient
    private Boolean enableRemedy; // ???
    @Transient
    private RemedyAlgorithm remedyAlgorithm; // ?
    @Transient
    private Integer remedyDelayThresoldForMedia; // ???????
    @Transient
    private SyncMode syncMode; // ??/?
    @Transient
    private SyncConsistency syncConsistency; // ??

    // ================================= system parameter
    // ================================
    @Transient
    private String systemSchema; // retl??
    @Transient
    private String systemMarkTable; // ???
    @Transient
    private String systemMarkTableColumn; // ?????
    @Transient
    private String systemMarkTableInfo; // ???info?BI_SYNC
    @Transient
    private String systemBufferTable; // otter?buffer
    @Transient
    private String systemDualTable; // otter?
    @Transient
    private RetrieverType retriever; // ?

    /**
     * ?pipeline?
     */
    public void merge(PipelineParameter pipelineParameter) {
        try {
            Field[] fields = this.getClass().getDeclaredFields();
            for (int i = 0; i < fields.length; i++) {
                Field field = fields[i];
                // Skip static and final fields.
                if (Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())) {
                    continue;
                }

                ReflectionUtils.makeAccessible(field);
                Object srcValue = field.get(pipelineParameter);
                if (srcValue != null) { // null
                    field.set(this, srcValue);
                }
            }
        } catch (Exception e) {
            // ignore
        }
    }

    /**
     * ?system?
     */
    public void merge(SystemParameter globalParmeter) {
        try {
            BeanUtils.copyProperties(this, globalParmeter);
        } catch (Exception e) {
            // ignore
        }
    }

    /**
     * ?channel?
     */
    public void merge(ChannelParameter channelParameter) {
        try {
            BeanUtils.copyProperties(this, channelParameter);
        } catch (Exception e) {
            // ignore
        }
    }

    public static enum LoadBanlanceAlgorithm {
        /**  */
        RoundRbin,
        /** ? */
        Random,
        /** Stick */
        Stick;

        public boolean isRoundRbin() {
            return this.equals(LoadBanlanceAlgorithm.RoundRbin);
        }

        public boolean isRandom() {
            return this.equals(LoadBanlanceAlgorithm.Random);
        }

        public boolean isStick() {
            return this.equals(LoadBanlanceAlgorithm.Stick);
        }
    }

    public static enum ArbitrateMode {
        /**  */
        MEMORY,
        /** rpc */
        RPC,
        /** zk watcher */
        ZOOKEEPER,
        /**  */
        AUTOMATIC;

        public boolean isMemory() {
            return this.equals(ArbitrateMode.MEMORY);
        }

        public boolean isRpc() {
            return this.equals(ArbitrateMode.RPC);
        }

        public boolean isZookeeper() {
            return this.equals(ArbitrateMode.ZOOKEEPER);
        }

        public boolean isAutomatic() {
            return this.equals(ArbitrateMode.AUTOMATIC);
        }
    }

    public static enum PipeChooseMode {
        /**  */
        AUTOMATIC,
        /** RPC */
        RPC,
        /** HTTP */
        HTTP;

        public boolean isAutomatic() {
            return this.equals(PipeChooseMode.AUTOMATIC);
        }

        public boolean isRpc() {
            return this.equals(PipeChooseMode.RPC);
        }

        public boolean isHttp() {
            return this.equals(PipeChooseMode.HTTP);
        }
    }

    public static enum SelectorMode {

        Eromanga, Canal;

        public boolean isEromanga() {
            return this.equals(SelectorMode.Eromanga);
        }

        public boolean isCanal() {
            return this.equals(SelectorMode.Canal);
        }

    }

    // ======================== setter / getter ===========================

    public Long getPipelineId() {
        return pipelineId;
    }

    public void setPipelineId(Long pipelineId) {
        this.pipelineId = pipelineId;
    }

    public Long getParallelism() {
        return parallelism;
    }

    public void setParallelism(Long parallelism) {
        this.parallelism = parallelism;
    }

    public LoadBanlanceAlgorithm getLbAlgorithm() {
        return lbAlgorithm;
    }

    public void setLbAlgorithm(LoadBanlanceAlgorithm lbAlgorithm) {
        this.lbAlgorithm = lbAlgorithm;
    }

    public Short getMainstemClientId() {
        return mainstemClientId;
    }

    public void setMainstemClientId(short mainstemClientId) {
        this.mainstemClientId = mainstemClientId;
    }

    public Integer getMainstemBatchsize() {
        return mainstemBatchsize;
    }

    public Boolean isHome() {
        return home;
    }

    public void setHome(Boolean home) {
        this.home = home;
    }

    public Integer getLoadPoolSize() {
        return loadPoolSize;
    }

    public void setLoadPoolSize(Integer loadPoolSize) {
        this.loadPoolSize = loadPoolSize;
    }

    public Integer getExtractPoolSize() {
        return extractPoolSize;
    }

    public void setExtractPoolSize(int extractPoolSize) {
        this.extractPoolSize = extractPoolSize;
    }

    public Boolean isDumpEvent() {
        return dumpEvent;
    }

    public void setDumpEvent(Boolean dumpEvent) {
        this.dumpEvent = dumpEvent;
    }

    public PipeChooseMode getPipeChooseType() {
        return pipeChooseType;
    }

    public void setPipeChooseType(PipeChooseMode pipeChooseType) {
        this.pipeChooseType = pipeChooseType;
    }

    public Boolean isUseBatch() {
        return useBatch;
    }

    public Boolean getSkipLoadException() {
        // ?
        return skipLoadException == null ? false : skipLoadException;
    }

    public void setSkipLoadException(Boolean skipLoadException) {
        this.skipLoadException = skipLoadException;
    }

    public void setSelectorMode(SelectorMode selectorMode) {
        this.selectorMode = selectorMode;
    }

    public Boolean getHome() {
        return home;
    }

    public Boolean getDumpEvent() {
        return dumpEvent;
    }

    public void setExtractPoolSize(Integer extractPoolSize) {
        this.extractPoolSize = extractPoolSize;
    }

    public Boolean getDumpSelector() {
        // ?
        return dumpSelector == null ? true : dumpSelector;
    }

    public void setDumpSelector(Boolean dumpSelector) {
        this.dumpSelector = dumpSelector;
    }

    public Boolean getDumpSelectorDetail() {
        // ?
        return dumpSelectorDetail == null ? true : dumpSelectorDetail;
    }

    public void setDumpSelectorDetail(Boolean dumpSelectorDetail) {
        this.dumpSelectorDetail = dumpSelectorDetail;
    }

    public SelectorMode getSelectorMode() {
        return selectorMode;
    }

    public ArbitrateMode getArbitrateMode() {
        return arbitrateMode == null ? ArbitrateMode.ZOOKEEPER : arbitrateMode;
    }

    public void setArbitrateMode(ArbitrateMode arbitrateMode) {
        this.arbitrateMode = arbitrateMode;
    }

    public Long getBatchTimeout() {
        return batchTimeout == null ? -1 : batchTimeout;
    }

    public void setBatchTimeout(Long batchTimeout) {
        this.batchTimeout = batchTimeout;
    }

    public Boolean getFileDetect() {
        return fileDetect == null ? false : fileDetect;
    }

    public void setFileDetect(Boolean fileDetect) {
        this.fileDetect = fileDetect;
    }

    public Integer getFileLoadPoolSize() {
        return fileLoadPoolSize == null ? 5 : fileLoadPoolSize;
    }

    public void setFileLoadPoolSize(Integer fileLoadPoolSize) {
        this.fileLoadPoolSize = fileLoadPoolSize;
    }

    public Boolean getSkipFreedom() {
        return skipFreedom == null ? false : skipFreedom;
    }

    public void setSkipFreedom(Boolean skipFreedom) {
        this.skipFreedom = skipFreedom;
    }

    public String getDestinationName() {
        return destinationName;
    }

    public void setDestinationName(String destinationName) {
        this.destinationName = destinationName;
    }

    public Boolean getUseLocalFileMutliThread() {
        return useLocalFileMutliThread == null ? false : useLocalFileMutliThread;
    }

    public void setUseLocalFileMutliThread(Boolean useLocalFileMutliThread) {
        this.useLocalFileMutliThread = useLocalFileMutliThread;
    }

    public Boolean getUseExternalIp() {
        return useExternalIp == null ? false : useExternalIp;
    }

    public void setUseExternalIp(Boolean useExternalIp) {
        this.useExternalIp = useExternalIp;
    }

    public Boolean getUseFileEncrypt() {
        return useFileEncrypt == null ? false : useFileEncrypt;
    }

    public void setUseFileEncrypt(Boolean useFileEncrypt) {
        this.useFileEncrypt = useFileEncrypt;
    }

    public Boolean getUseTableTransform() {
        return useTableTransform == null ? true : useTableTransform;
    }

    public void setUseTableTransform(Boolean useTableTransform) {
        this.useTableTransform = useTableTransform;
    }

    public Boolean getSkipNoRow() {
        return skipNoRow == null ? false : skipNoRow;
    }

    public void setSkipNoRow(Boolean skipNoRow) {
        this.skipNoRow = skipNoRow;
    }

    public Boolean getEnableCompatibleMissColumn() {
        return enableCompatibleMissColumn == null ? true : enableCompatibleMissColumn;
    }

    public void setEnableCompatibleMissColumn(Boolean enableCompatibleMissColumn) {
        this.enableCompatibleMissColumn = enableCompatibleMissColumn;
    }

    public String getChannelInfo() {
        return channelInfo;
    }

    public void setChannelInfo(String channelInfo) {
        this.channelInfo = channelInfo;
    }

    public Boolean getDryRun() {
        return dryRun == null ? false : dryRun;
    }

    public Boolean isDryRun() {
        return dryRun == null ? false : dryRun;
    }

    public void setDryRun(Boolean dryRun) {
        this.dryRun = dryRun;
    }

    public Boolean getDdlSync() {
        return ddlSync == null ? true : ddlSync;
    }

    public void setDdlSync(Boolean ddlSync) {
        this.ddlSync = ddlSync;
    }

    public Boolean getSkipDdlException() {
        return skipDdlException == null ? false : skipDdlException;
    }

    public void setSkipDdlException(Boolean skipDdlException) {
        this.skipDdlException = skipDdlException;
    }

    // =============================channel parameter ==========================

    public Boolean getEnableRemedy() {
        return enableRemedy;
    }

    public Boolean isEnableRemedy() {
        return enableRemedy;
    }

    public void setEnableRemedy(Boolean enableRemedy) {
        this.enableRemedy = enableRemedy;
    }

    public SyncMode getSyncMode() {
        return syncMode;
    }

    public void setSyncMode(SyncMode syncMode) {
        this.syncMode = syncMode;
    }

    public SyncConsistency getSyncConsistency() {
        return syncConsistency;
    }

    public void setSyncConsistency(SyncConsistency syncConsistency) {
        this.syncConsistency = syncConsistency;
    }

    public RemedyAlgorithm getRemedyAlgorithm() {
        return remedyAlgorithm;
    }

    public void setRemedyAlgorithm(RemedyAlgorithm remedyAlgorithm) {
        this.remedyAlgorithm = remedyAlgorithm;
    }

    // ============================= system parameter
    // ================================

    public Boolean getUseBatch() {
        return useBatch;
    }

    public void setUseBatch(Boolean useBatch) {
        this.useBatch = useBatch;
    }

    public void setMainstemClientId(Short mainstemClientId) {
        this.mainstemClientId = mainstemClientId;
    }

    public void setMainstemBatchsize(Integer mainstemBatchsize) {
        this.mainstemBatchsize = mainstemBatchsize;
    }

    public String getSystemSchema() {
        return systemSchema;
    }

    public void setSystemSchema(String systemSchema) {
        this.systemSchema = systemSchema;
    }

    public String getSystemMarkTable() {
        return systemMarkTable;
    }

    public void setSystemMarkTable(String systemMarkTable) {
        this.systemMarkTable = systemMarkTable;
    }

    public String getSystemBufferTable() {
        return systemBufferTable;
    }

    public void setSystemBufferTable(String systemBufferTable) {
        this.systemBufferTable = systemBufferTable;
    }

    public RetrieverType getRetriever() {
        return retriever;
    }

    public void setRetriever(RetrieverType retriever) {
        this.retriever = retriever;
    }

    public String getSystemMarkTableColumn() {
        return systemMarkTableColumn;
    }

    public void setSystemMarkTableColumn(String systemMarkTableColumn) {
        this.systemMarkTableColumn = systemMarkTableColumn;
    }

    public String getSystemDualTable() {
        return systemDualTable;
    }

    public void setSystemDualTable(String systemDualTable) {
        this.systemDualTable = systemDualTable;
    }

    public String getSystemMarkTableInfo() {
        return systemMarkTableInfo;
    }

    public void setSystemMarkTableInfo(String systemMarkTableInfo) {
        this.systemMarkTableInfo = systemMarkTableInfo;
    }

    public Integer getRemedyDelayThresoldForMedia() {
        return remedyDelayThresoldForMedia;
    }

    public void setRemedyDelayThresoldForMedia(Integer remedyDelayThresoldForMedia) {
        this.remedyDelayThresoldForMedia = remedyDelayThresoldForMedia;
    }

    public Boolean getSkipSelectException() {
        return skipSelectException == null ? false : skipSelectException;
    }

    public void setSkipSelectException(Boolean skipSelectException) {
        this.skipSelectException = skipSelectException;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, OtterToStringStyle.DEFAULT_STYLE);
    }

}