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