當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSourcing類代碼示例

本文整理匯總了Java中com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing的典型用法代碼示例。如果您正苦於以下問題:Java DataSourcing類的具體用法?Java DataSourcing怎麽用?Java DataSourcing使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataSourcing類屬於com.alibaba.otter.canal.instance.manager.model.CanalParameter包,在下文中一共展示了DataSourcing類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatGroupDbAddress

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
public String formatGroupDbAddress(SourcingType defaultType, List<List<DataSourcing>> groupDbAddresses) {
    StringBuilder builder = new StringBuilder();
    for (List<DataSourcing> groupDbAddress : groupDbAddresses) {
        List<String> address = new ArrayList<String>();
        for (DataSourcing dbAddress : groupDbAddress) {
            StringBuilder dbAddressBuilder = new StringBuilder();
            dbAddressBuilder.append(dbAddress.getDbAddress().getAddress().getHostAddress());
            dbAddressBuilder.append(":");
            dbAddressBuilder.append(String.valueOf(dbAddress.getDbAddress().getPort()));
            if (!defaultType.equals(dbAddress.getType())) {
                dbAddressBuilder.append(":").append(dbAddress.getType().name());
            }

            address.add(dbAddressBuilder.toString());
        }
        builder.append(StringUtils.join(address, ',')).append(";");
    }

    return builder.toString();
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:21,代碼來源:NumberFormatUtil.java

示例2: getUrl

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
public String getUrl() {
    CanalParameter parameter = getCanalParameter();
    if (parameter.getHaMode().isMedia()) {
        return "media://" + parameter.getMediaGroup();
    } else {
        StringBuilder address = new StringBuilder("jdbc://");
        for (List<DataSourcing> groupAddress : parameter.getGroupDbAddresses()) {
            int i = 0;
            for (DataSourcing dbAddress : groupAddress) {
                ++i;
                address.append(dbAddress.getDbAddress().getAddress().getHostAddress())
                    .append(":")
                    .append(dbAddress.getDbAddress().getPort());

                if (i < groupAddress.size()) {
                    address.append(',');
                }
            }

            address.append(';');
        }

        return address.toString();
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:26,代碼來源:SeniorCanal.java

示例3: formatGroupDbAddress

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
public String formatGroupDbAddress(SourcingType defaultType, List<List<DataSourcing>> groupDbAddresses) {
    StringBuilder builder = new StringBuilder();
    for (List<DataSourcing> groupDbAddress : groupDbAddresses) {
        List<String> address = new ArrayList<String>();
        for (DataSourcing dbAddress : groupDbAddress) {
            StringBuilder dbAddressBuilder = new StringBuilder();
            dbAddressBuilder.append(dbAddress.getDbAddress().getAddress().getHostName());
            dbAddressBuilder.append(":");
            dbAddressBuilder.append(String.valueOf(dbAddress.getDbAddress().getPort()));
            if (!defaultType.equals(dbAddress.getType())) {
                dbAddressBuilder.append(":").append(dbAddress.getType().name());
            }

            address.add(dbAddressBuilder.toString());
        }
        builder.append(StringUtils.join(address, ',')).append(";");
    }

    return builder.toString();
}
 
開發者ID:alibaba,項目名稱:otter,代碼行數:21,代碼來源:NumberFormatUtil.java

示例4: getUrl

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
public String getUrl() {
    CanalParameter parameter = getCanalParameter();
    if (parameter.getHaMode().isMedia()) {
        return "media://" + parameter.getMediaGroup();
    } else {
        StringBuilder address = new StringBuilder("jdbc://");
        for (List<DataSourcing> groupAddress : parameter.getGroupDbAddresses()) {
            int i = 0;
            for (DataSourcing dbAddress : groupAddress) {
                ++i;
                address.append(dbAddress.getDbAddress().getAddress().getHostName())
                    .append(":")
                    .append(dbAddress.getDbAddress().getPort());

                if (i < groupAddress.size()) {
                    address.append(',');
                }
            }

            address.append(';');
        }

        return address.toString();
    }
}
 
開發者ID:alibaba,項目名稱:otter,代碼行數:26,代碼來源:SeniorCanal.java

示例5: initEventParser

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
protected void initEventParser() {
    logger.info("init eventParser begin...");
    SourcingType type = parameters.getSourcingType();

    List<List<DataSourcing>> groupDbAddresses = parameters.getGroupDbAddresses();
    if (!CollectionUtils.isEmpty(groupDbAddresses)) {
        int size = groupDbAddresses.get(0).size();// 取第一個分組的數量,主備分組的數量必須一致
        List<CanalEventParser> eventParsers = new ArrayList<CanalEventParser>();
        for (int i = 0; i < size; i++) {
            List<InetSocketAddress> dbAddress = new ArrayList<InetSocketAddress>();
            SourcingType lastType = null;
            for (List<DataSourcing> groupDbAddress : groupDbAddresses) {
                if (lastType != null && !lastType.equals(groupDbAddress.get(i).getType())) {
                    throw new CanalException(String.format("master/slave Sourcing type is unmatch. %s vs %s",
                        lastType,
                        groupDbAddress.get(i).getType()));
                }

                lastType = groupDbAddress.get(i).getType();
                dbAddress.add(groupDbAddress.get(i).getDbAddress());
            }

            // 初始化其中的一個分組parser
            eventParsers.add(doInitEventParser(lastType, dbAddress));
        }

        if (eventParsers.size() > 1) { // 如果存在分組,構造分組的parser
            GroupEventParser groupEventParser = new GroupEventParser();
            groupEventParser.setEventParsers(eventParsers);
            this.eventParser = groupEventParser;
        } else {
            this.eventParser = eventParsers.get(0);
        }
    } else {
        // 創建一個空數據庫地址的parser,可能使用了tddl指定地址,啟動的時候才會從tddl獲取地址
        this.eventParser = doInitEventParser(type, new ArrayList<InetSocketAddress>());
    }

    logger.info("init eventParser end! \n\t load CanalEventParser:{}", eventParser.getClass().getName());
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:41,代碼來源:CanalInstanceWithManager.java

示例6: getGroupSize

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
private int getGroupSize() {
    List<List<DataSourcing>> groupDbAddresses = parameters.getGroupDbAddresses();
    if (!CollectionUtils.isEmpty(groupDbAddresses)) {
        return groupDbAddresses.get(0).size();
    } else {
        // 可能是基於tddl的啟動
        return 1;
    }
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:10,代碼來源:CanalInstanceWithManager.java

示例7: doEdit

import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; //導入依賴的package包/類
/**
 * 修改canal
 */
public void doEdit(@FormGroup("canalInfo") Group canalInfo,
                   @FormGroup("canalParameterInfo") Group canalParameterInfo,
                   @FormField(name = "formCanalError", group = "canalInfo") CustomErrors err,
                   @FormField(name = "formHeartBeatError", group = "canalParameterInfo") CustomErrors heartBeatErr,
                   Navigator nav) throws Exception {
    Canal canal = new Canal();
    CanalParameter parameter = new CanalParameter();
    canalInfo.setProperties(canal);
    canalParameterInfo.setProperties(parameter);

    String zkClustersString = canalParameterInfo.getField("zkClusters").getStringValue();
    String[] zkClusters = StringUtils.split(zkClustersString, ";");
    parameter.setZkClusters(Arrays.asList(zkClusters));

    Long zkClusterId = canalParameterInfo.getField("autoKeeperClusterId").getLongValue();
    parameter.setZkClusterId(zkClusterId);

    String dbAddressesString = canalParameterInfo.getField("groupDbAddresses").getStringValue();
    if (StringUtils.isNotEmpty(dbAddressesString)) {
        List<List<DataSourcing>> dbSocketAddress = new ArrayList<List<DataSourcing>>();
        String[] dbAddresses = StringUtils.split(dbAddressesString, ";");
        for (String dbAddressString : dbAddresses) {
            List<DataSourcing> groupDbSocketAddress = new ArrayList<DataSourcing>();
            String[] groupDbAddresses = StringUtils.split(dbAddressString, ",");
            for (String groupDbAddress : groupDbAddresses) {
                String strs[] = StringUtils.split(groupDbAddress, ":");
                InetSocketAddress address = new InetSocketAddress(strs[0].trim(), Integer.valueOf(strs[1]));
                SourcingType type = parameter.getSourcingType();
                if (strs.length > 2) {
                    type = SourcingType.valueOf(strs[2]);
                }
                groupDbSocketAddress.add(new DataSourcing(type, address));
            }
            dbSocketAddress.add(groupDbSocketAddress);
        }

        parameter.setGroupDbAddresses(dbSocketAddress);
    }

    String positionsString = canalParameterInfo.getField("positions").getStringValue();
    if (StringUtils.isNotEmpty(positionsString)) {
        String positions[] = StringUtils.split(positionsString, ";");
        parameter.setPositions(Arrays.asList(positions));
    }

    if (parameter.getDetectingEnable() && StringUtils.startsWithIgnoreCase(parameter.getDetectingSQL(), "select")) {
        heartBeatErr.setMessage("invaliedHeartBeat");
        return;
    }

    canal.setCanalParameter(parameter);

    try {
        canalService.modify(canal);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidCanal");
        return;
    }

    nav.redirectToLocation("canalList.htm");
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:65,代碼來源:CanalAction.java


注:本文中的com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。