mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
format
This commit is contained in:
@@ -238,7 +238,8 @@ public class MQMessageUtils {
|
|||||||
* @return 分区message数组
|
* @return 分区message数组
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Message[] messagePartition(EntryRowData[] datas, long id, Integer partitionsNum, String pkHashConfigs,boolean databaseHash) {
|
public static Message[] messagePartition(EntryRowData[] datas, long id, Integer partitionsNum,
|
||||||
|
String pkHashConfigs, boolean databaseHash) {
|
||||||
if (partitionsNum == null) {
|
if (partitionsNum == null) {
|
||||||
partitionsNum = 1;
|
partitionsNum = 1;
|
||||||
}
|
}
|
||||||
@@ -451,7 +452,8 @@ public class MQMessageUtils {
|
|||||||
* @param databaseHash 是否取消根据database进行hash
|
* @param databaseHash 是否取消根据database进行hash
|
||||||
* @return 拆分后的flatMessage数组
|
* @return 拆分后的flatMessage数组
|
||||||
*/
|
*/
|
||||||
public static FlatMessage[] messagePartition(FlatMessage flatMessage, Integer partitionsNum, String pkHashConfigs,boolean databaseHash) {
|
public static FlatMessage[] messagePartition(FlatMessage flatMessage, Integer partitionsNum, String pkHashConfigs,
|
||||||
|
boolean databaseHash) {
|
||||||
if (partitionsNum == null) {
|
if (partitionsNum == null) {
|
||||||
partitionsNum = 1;
|
partitionsNum = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public class MQProperties {
|
|||||||
// 是否取消根据database进行hash
|
// 是否取消根据database进行hash
|
||||||
private boolean databaseHash = true;
|
private boolean databaseHash = true;
|
||||||
|
|
||||||
|
|
||||||
public static class CanalDestination {
|
public static class CanalDestination {
|
||||||
|
|
||||||
private String canalDestination;
|
private String canalDestination;
|
||||||
@@ -349,6 +348,7 @@ public class MQProperties {
|
|||||||
public void setDatabaseHash(boolean databaseHash) {
|
public void setDatabaseHash(boolean databaseHash) {
|
||||||
this.databaseHash = databaseHash;
|
this.databaseHash = databaseHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MQProperties [servers=" + servers + ", retries=" + retries + ", batchSize=" + batchSize + ", lingerMs="
|
return "MQProperties [servers=" + servers + ", retries=" + retries + ", batchSize=" + batchSize + ", lingerMs="
|
||||||
@@ -365,6 +365,4 @@ public class MQProperties {
|
|||||||
+ ",databaseHash=" + databaseHash + "]";
|
+ ",databaseHash=" + databaseHash + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import com.alibaba.mq.amqp.utils.UserUtils;
|
import com.alibaba.mq.amqp.utils.UserUtils;
|
||||||
import com.rabbitmq.client.impl.CredentialsProvider;
|
import com.rabbitmq.client.impl.CredentialsProvider;
|
||||||
|
|
||||||
|
|
||||||
public class AliyunCredentialsProvider implements CredentialsProvider {
|
public class AliyunCredentialsProvider implements CredentialsProvider {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access Key ID
|
* Access Key ID
|
||||||
*/
|
*/
|
||||||
@@ -29,14 +27,12 @@ public class AliyunCredentialsProvider implements CredentialsProvider {
|
|||||||
*/
|
*/
|
||||||
private final long resourceOwnerId;
|
private final long resourceOwnerId;
|
||||||
|
|
||||||
|
|
||||||
public AliyunCredentialsProvider(final String accessKey, final String accessSecret, final long resourceOwnerId){
|
public AliyunCredentialsProvider(final String accessKey, final String accessSecret, final long resourceOwnerId){
|
||||||
this.AliyunAccessKey = accessKey;
|
this.AliyunAccessKey = accessKey;
|
||||||
this.AliyunAccessSecret = accessSecret;
|
this.AliyunAccessSecret = accessSecret;
|
||||||
this.resourceOwnerId = resourceOwnerId;
|
this.resourceOwnerId = resourceOwnerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return UserUtils.getUserName(AliyunAccessKey, resourceOwnerId);
|
return UserUtils.getUserName(AliyunAccessKey, resourceOwnerId);
|
||||||
@@ -51,5 +47,4 @@ public class AliyunCredentialsProvider implements CredentialsProvider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,8 @@ public class CanalRocketMQProducer extends AbstractMQProducer implements CanalMQ
|
|||||||
com.alibaba.otter.canal.protocol.Message[] messages = MQMessageUtils.messagePartition(datas,
|
com.alibaba.otter.canal.protocol.Message[] messages = MQMessageUtils.messagePartition(datas,
|
||||||
message.getId(),
|
message.getId(),
|
||||||
destination.getPartitionsNum(),
|
destination.getPartitionsNum(),
|
||||||
destination.getPartitionHash(),databaseHash);
|
destination.getPartitionHash(),
|
||||||
|
databaseHash);
|
||||||
int length = messages.length;
|
int length = messages.length;
|
||||||
|
|
||||||
ExecutorTemplate template = new ExecutorTemplate(executor);
|
ExecutorTemplate template = new ExecutorTemplate(executor);
|
||||||
@@ -171,7 +172,8 @@ public class CanalRocketMQProducer extends AbstractMQProducer implements CanalMQ
|
|||||||
for (FlatMessage flatMessage : flatMessages) {
|
for (FlatMessage flatMessage : flatMessages) {
|
||||||
FlatMessage[] partitionFlatMessage = MQMessageUtils.messagePartition(flatMessage,
|
FlatMessage[] partitionFlatMessage = MQMessageUtils.messagePartition(flatMessage,
|
||||||
destination.getPartitionsNum(),
|
destination.getPartitionsNum(),
|
||||||
destination.getPartitionHash(),databaseHash);
|
destination.getPartitionHash(),
|
||||||
|
databaseHash);
|
||||||
int length = partitionFlatMessage.length;
|
int length = partitionFlatMessage.length;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
partitionFlatMessages.get(i).add(partitionFlatMessage[i]);
|
partitionFlatMessages.get(i).add(partitionFlatMessage[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user