集群同步-》同步消费位点

This commit is contained in:
许晓东
2021-10-25 00:10:08 +08:00
parent 66e7ea0676
commit 5ccf9013e5
13 changed files with 233 additions and 6 deletions

View File

@@ -30,4 +30,6 @@ public interface ConsumerService {
ResponseData resetPartitionToTargetOffset(String groupId, TopicPartition partition, long offset);
ResponseData getGroupIdList();
ResponseData getSubscribeTopicList(String groupId);
}

View File

@@ -0,0 +1,15 @@
package com.xuxd.kafka.console.service;
import com.xuxd.kafka.console.beans.ResponseData;
import java.util.Properties;
/**
* kafka-console-ui.
*
* @author xuxd
* @date 2021-10-24 23:12:43
**/
public interface OperationService {
ResponseData syncConsumerOffset(String groupId, String topic, Properties thatProps);
}

View File

@@ -138,4 +138,8 @@ public class ConsumerServiceImpl implements ConsumerService {
Set<String> stateGroup = consumerConsole.getConsumerGroupIdList(null);
return ResponseData.create().data(stateGroup).success();
}
@Override public ResponseData getSubscribeTopicList(String groupId) {
return ResponseData.create().data(consumerConsole.listSubscribeTopics(groupId).keySet()).success();
}
}

View File

@@ -0,0 +1,29 @@
package com.xuxd.kafka.console.service.impl;
import com.xuxd.kafka.console.beans.ResponseData;
import com.xuxd.kafka.console.service.OperationService;
import java.util.Properties;
import kafka.console.OperationConsole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import scala.Tuple2;
/**
* kafka-console-ui.
*
* @author xuxd
* @date 2021-10-24 23:12:54
**/
@Service
public class OperationServiceImpl implements OperationService {
@Autowired
private OperationConsole operationConsole;
@Override public ResponseData syncConsumerOffset(String groupId, String topic, Properties thatProps) {
Tuple2<Object, String> tuple2 = operationConsole.syncConsumerOffset(groupId, topic, thatProps);
return (boolean) tuple2._1() ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
}
}