本文整理汇总了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();
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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());
}
示例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;
}
}
示例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");
}