本文整理汇总了Java中com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType类的典型用法代码示例。如果您正苦于以下问题:Java SourcingType类的具体用法?Java SourcingType怎么用?Java SourcingType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SourcingType类属于com.alibaba.otter.canal.instance.manager.model.CanalParameter包,在下文中一共展示了SourcingType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatGroupDbAddress
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的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();
}
示例2: formatGroupDbAddress
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的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();
}
示例3: initEventParser
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的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());
}
示例4: buildCanal
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的package包/类
protected Canal buildCanal() {
Canal canal = new Canal();
canal.setId(1L);
canal.setName(DESTINATION);
canal.setDesc("test");
CanalParameter parameter = new CanalParameter();
parameter.setZkClusters(Arrays.asList("127.0.0.1:2188"));
parameter.setMetaMode(MetaMode.MEMORY);
parameter.setHaMode(HAMode.HEARTBEAT);
parameter.setIndexMode(IndexMode.MEMORY);
parameter.setStorageMode(StorageMode.MEMORY);
parameter.setMemoryStorageBufferSize(32 * 1024);
parameter.setSourcingType(SourcingType.MYSQL);
parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306),
new InetSocketAddress(MYSQL_ADDRESS, 3306)));
parameter.setDbUsername(USERNAME);
parameter.setDbPassword(PASSWORD);
parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000003\",\"position\":14217L,\"timestamp\":\"1505998863000\"}",
"{\"journalName\":\"mysql-bin.000003\",\"position\":14377L,\"timestamp\":\"1505998863000\"}"));
parameter.setSlaveId(1234L);
parameter.setDefaultConnectionTimeoutInSeconds(30);
parameter.setConnectionCharset("UTF-8");
parameter.setConnectionCharsetNumber((byte) 33);
parameter.setReceiveBufferSize(8 * 1024);
parameter.setSendBufferSize(8 * 1024);
parameter.setDetectingEnable(false);
parameter.setDetectingIntervalInSeconds(10);
parameter.setDetectingRetryTimes(3);
parameter.setDetectingSQL(DETECTING_SQL);
canal.setCanalParameter(parameter);
return canal;
}
示例5: buildCanal
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的package包/类
protected Canal buildCanal() {
Canal canal = new Canal();
canal.setId(1L);
canal.setName(DESTINATION);
canal.setDesc("test");
CanalParameter parameter = new CanalParameter();
parameter.setZkClusters(Arrays.asList("127.0.0.1:2188"));
parameter.setMetaMode(MetaMode.MIXED); // 冷备,可选择混合模式
parameter.setHaMode(HAMode.HEARTBEAT);
parameter.setIndexMode(IndexMode.META);// 内存版store,需要选择meta做为index
parameter.setStorageMode(StorageMode.MEMORY);
parameter.setMemoryStorageBufferSize(32 * 1024);
parameter.setSourcingType(SourcingType.MYSQL);
parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306),
new InetSocketAddress(MYSQL_ADDRESS, 3306)));
parameter.setDbUsername(USERNAME);
parameter.setDbPassword(PASSWORD);
parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}",
"{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}"));
parameter.setSlaveId(1234L);
parameter.setDefaultConnectionTimeoutInSeconds(30);
parameter.setConnectionCharset("UTF-8");
parameter.setConnectionCharsetNumber((byte) 33);
parameter.setReceiveBufferSize(8 * 1024);
parameter.setSendBufferSize(8 * 1024);
parameter.setDetectingEnable(false);
parameter.setDetectingIntervalInSeconds(10);
parameter.setDetectingRetryTimes(3);
parameter.setDetectingSQL(DETECTING_SQL);
canal.setCanalParameter(parameter);
return canal;
}
示例6: buildCanal
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的package包/类
private Canal buildCanal() {
Canal canal = new Canal();
canal.setId(1L);
canal.setName(DESTINATION);
canal.setDesc("test");
CanalParameter parameter = new CanalParameter();
parameter.setZkClusters(Arrays.asList("127.0.0.1:2188"));
parameter.setMetaMode(MetaMode.MEMORY);
parameter.setHaMode(HAMode.HEARTBEAT);
parameter.setIndexMode(IndexMode.MEMORY);
parameter.setStorageMode(StorageMode.MEMORY);
parameter.setMemoryStorageBufferSize(32 * 1024);
parameter.setSourcingType(SourcingType.MYSQL);
parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306),
new InetSocketAddress(MYSQL_ADDRESS, 3306)));
parameter.setDbUsername(USERNAME);
parameter.setDbPassword(PASSWORD);
parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}",
"{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}"));
parameter.setSlaveId(1234L);
parameter.setDefaultConnectionTimeoutInSeconds(30);
parameter.setConnectionCharset("UTF-8");
parameter.setConnectionCharsetNumber((byte) 33);
parameter.setReceiveBufferSize(8 * 1024);
parameter.setSendBufferSize(8 * 1024);
parameter.setDetectingEnable(false);
parameter.setDetectingIntervalInSeconds(10);
parameter.setDetectingRetryTimes(3);
parameter.setDetectingSQL(DETECTING_SQL);
canal.setCanalParameter(parameter);
return canal;
}
示例7: doEdit
import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; //导入依赖的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");
}