Skip to content

Commit

Permalink
fix checkStyle error
Browse files Browse the repository at this point in the history
  • Loading branch information
xwm1992 committed Jun 28, 2024
1 parent 8f4748f commit 50a204e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public List<RecordPosition> handler(FetchPositionRequest request, Metadata metad
CanalRecordPartition partition = new CanalRecordPartition();
partition.setTimeStamp(position.getTimestamp());
partition.setJournalName(position.getJournalName());
recordPosition.setRecordPartition(partition);
CanalRecordOffset offset = new CanalRecordOffset();
offset.setOffset(position.getPosition());
recordPosition.setRecordPartition(partition);
recordPosition.setRecordOffset(offset);
recordPositionList.add(recordPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

import org.apache.eventmesh.connector.canal.template.MysqlSqlTemplate;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.lob.LobHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RuntimeInstance {

private Map<String, RegisterServerInfo> adminServerInfoMap = new HashMap<>();

// private final RegistryService registryService;
private final RegistryService registryService;

private Runtime runtime;

Expand All @@ -57,20 +57,20 @@ public class RuntimeInstance {

public RuntimeInstance(RuntimeInstanceConfig runtimeInstanceConfig) {
this.runtimeInstanceConfig = runtimeInstanceConfig;
// this.registryService = RegistryFactory.getInstance(runtimeInstanceConfig.getRegistryPluginType());
this.registryService = RegistryFactory.getInstance(runtimeInstanceConfig.getRegistryPluginType());
}

public void init() throws Exception {
// registryService.init();
// QueryInstances queryInstances = new QueryInstances();
// queryInstances.setServiceName(runtimeInstanceConfig.getAdminServiceName());
// queryInstances.setHealth(true);
// List<RegisterServerInfo> adminServerRegisterInfoList = registryService.selectInstances(queryInstances);
// if (!adminServerRegisterInfoList.isEmpty()) {
// adminServerAddr = getRandomAdminServerAddr(adminServerRegisterInfoList);
// } else {
// throw new RuntimeException("admin server address is empty, please check");
// }
registryService.init();
QueryInstances queryInstances = new QueryInstances();
queryInstances.setServiceName(runtimeInstanceConfig.getAdminServiceName());
queryInstances.setHealth(true);
List<RegisterServerInfo> adminServerRegisterInfoList = registryService.selectInstances(queryInstances);
if (!adminServerRegisterInfoList.isEmpty()) {
adminServerAddr = getRandomAdminServerAddr(adminServerRegisterInfoList);
} else {
throw new RuntimeException("admin server address is empty, please check");
}
runtimeInstanceConfig.setAdminServerAddr(adminServerAddr);
runtimeFactory = initRuntimeFactory(runtimeInstanceConfig);
runtime = runtimeFactory.createRuntime(runtimeInstanceConfig);
Expand All @@ -80,19 +80,19 @@ public void init() throws Exception {
public void start() throws Exception {
if (!StringUtils.isBlank(adminServerAddr)) {

// registryService.subscribe((event) -> {
// log.info("runtime receive registry event: {}", event);
// List<RegisterServerInfo> registerServerInfoList = event.getInstances();
// Map<String, RegisterServerInfo> registerServerInfoMap = new HashMap<>();
// for (RegisterServerInfo registerServerInfo : registerServerInfoList) {
// registerServerInfoMap.put(registerServerInfo.getAddress(), registerServerInfo);
// }
// if (!registerServerInfoMap.isEmpty()) {
// adminServerInfoMap = registerServerInfoMap;
// updateAdminServerAddr();
// }
//
// }, runtimeInstanceConfig.getAdminServiceName());
registryService.subscribe((event) -> {
log.info("runtime receive registry event: {}", event);
List<RegisterServerInfo> registerServerInfoList = event.getInstances();
Map<String, RegisterServerInfo> registerServerInfoMap = new HashMap<>();
for (RegisterServerInfo registerServerInfo : registerServerInfoList) {
registerServerInfoMap.put(registerServerInfo.getAddress(), registerServerInfo);
}
if (!registerServerInfoMap.isEmpty()) {
adminServerInfoMap = registerServerInfoMap;
updateAdminServerAddr();
}

}, runtimeInstanceConfig.getAdminServiceName());
runtime.start();
isStarted = true;
} else {
Expand Down

0 comments on commit 50a204e

Please sign in to comment.