mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
modify
This commit is contained in:
@@ -16,30 +16,30 @@ public class CanalInstanceController {
|
||||
@Autowired
|
||||
CanalInstanceService canalInstanceConfigService;
|
||||
|
||||
@GetMapping(value = "/canalInstances")
|
||||
@GetMapping(value = "/instances")
|
||||
public BaseModel<List<CanalInstanceConfig>> nodeServers(CanalInstanceConfig canalInstanceConfig,
|
||||
@PathVariable String env) {
|
||||
return BaseModel.getInstance(canalInstanceConfigService.findList(canalInstanceConfig));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/canalInstance")
|
||||
@PostMapping(value = "/iInstance")
|
||||
public BaseModel<String> save(@RequestBody CanalInstanceConfig canalInstanceConfig, @PathVariable String env) {
|
||||
canalInstanceConfigService.save(canalInstanceConfig);
|
||||
return BaseModel.getInstance("success");
|
||||
}
|
||||
|
||||
@GetMapping(value = "/canalInstance/{id}")
|
||||
@GetMapping(value = "/instance/{id}")
|
||||
public BaseModel<CanalInstanceConfig> detail(@PathVariable Long id, @PathVariable String env) {
|
||||
return BaseModel.getInstance(canalInstanceConfigService.detail(id));
|
||||
}
|
||||
|
||||
@PutMapping(value = "/canalInstance")
|
||||
@PutMapping(value = "/instance")
|
||||
public BaseModel<String> update(@RequestBody CanalInstanceConfig canalInstanceConfig, @PathVariable String env) {
|
||||
canalInstanceConfigService.updateContent(canalInstanceConfig);
|
||||
return BaseModel.getInstance("success");
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/nodeServer/{id}")
|
||||
@DeleteMapping(value = "/instance/{id}")
|
||||
public BaseModel<String> delete(@PathVariable Long id, @PathVariable String env) {
|
||||
canalInstanceConfigService.delete(id);
|
||||
return BaseModel.getInstance("success");
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JMXConnection {
|
||||
CanalServerMXBean canalServerMXBean = jmxConnection.getCanalServerMXBean();
|
||||
return function.apply(canalServerMXBean);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage());
|
||||
} finally {
|
||||
jmxConnection.close();
|
||||
}
|
||||
|
||||
@@ -24,15 +24,13 @@ public class CanalInstanceConfig extends Model {
|
||||
}
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
private String content;
|
||||
private Date modifiedTime;
|
||||
private Long id;
|
||||
private String name;
|
||||
private String content;
|
||||
private Date modifiedTime;
|
||||
|
||||
@Transient
|
||||
private NodeServer nodeServer;
|
||||
@Transient
|
||||
private Integer status = 0;
|
||||
private String nodeIp;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -66,19 +64,11 @@ public class CanalInstanceConfig extends Model {
|
||||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
public NodeServer getNodeServer() {
|
||||
return nodeServer;
|
||||
public String getNodeIp() {
|
||||
return nodeIp;
|
||||
}
|
||||
|
||||
public void setNodeServer(NodeServer nodeServer) {
|
||||
this.nodeServer = nodeServer;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
public void setNodeIp(String nodeIp) {
|
||||
this.nodeIp = nodeIp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@ package com.alibaba.otter.canal.admin.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.otter.canal.admin.service.CanalInstanceService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.otter.canal.admin.jmx.CanalServerMXBean;
|
||||
import com.alibaba.otter.canal.admin.jmx.JMXConnection;
|
||||
import com.alibaba.otter.canal.admin.model.CanalInstanceConfig;
|
||||
import com.alibaba.otter.canal.admin.model.NodeServer;
|
||||
import com.alibaba.otter.canal.admin.service.CanalInstanceService;
|
||||
|
||||
import io.ebean.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CanalInstanceServiceImpl implements CanalInstanceService {
|
||||
@@ -25,6 +25,7 @@ public class CanalInstanceServiceImpl implements CanalInstanceService {
|
||||
query.where().like("name", "%" + canalInstanceConfig.getName() + "%");
|
||||
}
|
||||
}
|
||||
query.order().asc("id");
|
||||
List<CanalInstanceConfig> canalInstanceConfigs = query.findList();
|
||||
|
||||
// check all canal instances running status
|
||||
@@ -39,8 +40,7 @@ public class CanalInstanceServiceImpl implements CanalInstanceService {
|
||||
for (String instance : instances) {
|
||||
for (CanalInstanceConfig cig : canalInstanceConfigs) {
|
||||
if (instance.equals(cig.getName())) {
|
||||
cig.setNodeServer(nodeServer);
|
||||
cig.setStatus(1);
|
||||
cig.setNodeIp(nodeServer.getIp());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user