Commit 8630fc97 by Nepxion

增加图形化灰度发布功能

parent 9dbf5780
......@@ -56,6 +56,18 @@ public class ServiceController {
return restTemplate.postForEntity(url, routeServiceIds, RouterEntity.class).getBody();
}
public static String configUpdate(String serviceId, String config) {
String url = getUrl() + "/console/config/update-sync/" + serviceId;
return restTemplate.postForEntity(url, config, String.class).getBody();
}
public static String configClear(String serviceId) {
String url = getUrl() + "/console/config/clear/" + serviceId;
return restTemplate.postForEntity(url, null, String.class).getBody();
}
public static String getUrl() {
String url = PropertiesContext.getProperties().getString("url");
if (!url.endsWith("/")) {
......
......@@ -377,11 +377,10 @@ public class ServiceTopology extends AbstractTopology {
grayPanel.setPreferredSize(new Dimension(1280, 900));
}
if (node != null) {
InstanceEntity instance = (InstanceEntity) node.getUserObject();
grayPanel.setGray(instance);
} else {
grayPanel.setGray(null);
if (group != null) {
grayPanel.setGray(group);
} else if (node != null) {
grayPanel.setGray(node);
}
JBasicOptionPane.showOptionDialog(HandleManager.getFrame(ServiceTopology.this), grayPanel, ConsoleLocale.getString("execute_gray_router"), JBasicOptionPane.DEFAULT_OPTION, JBasicOptionPane.PLAIN_MESSAGE, ConsoleIconFactory.getSwingIcon("banner/navigator.png"), new Object[] { SwingLocale.getString("close") }, null, true);
......@@ -457,6 +456,9 @@ public class ServiceTopology extends AbstractTopology {
private JBasicTextArea localRuleTextArea;
private JBasicTabbedPane ruleTabbedPane;
private TGroup group;
private TNode node;
public GrayPanel() {
setLayout(new BorderLayout());
add(createVersionPanel(), BorderLayout.NORTH);
......@@ -533,32 +535,39 @@ public class ServiceTopology extends AbstractTopology {
return panel;
}
public void setGray(InstanceEntity instance) {
if (instance != null) {
if (versionTabbedPane.getTabCount() == 1) {
versionTabbedPane.addTab("初始(本地)版本", localVersionPanel, "初始(本地)版本");
}
if (ruleTabbedPane.getTabCount() == 1) {
ruleTabbedPane.addTab("初始(本地)规则", new JBasicScrollPane(localRuleTextArea), "初始(本地)规则");
}
public void setGray(TGroup group) {
this.group = group;
this.node = null;
localVersionTextField.setText(instance.getVersion());
dynamicVersionTextField.setText(instance.getDynamicVersion());
localRuleTextArea.setText(instance.getRule());
dynamicRuleTextArea.setText(instance.getDynamicRule());
} else {
if (versionTabbedPane.getTabCount() == 2) {
versionTabbedPane.remove(1);
}
if (ruleTabbedPane.getTabCount() == 2) {
ruleTabbedPane.remove(1);
}
if (versionTabbedPane.getTabCount() == 2) {
versionTabbedPane.remove(1);
}
if (ruleTabbedPane.getTabCount() == 2) {
ruleTabbedPane.remove(1);
}
localVersionTextField.setText("");
dynamicVersionTextField.setText("");
localRuleTextArea.setText("");
dynamicRuleTextArea.setText("");
localVersionTextField.setText("");
dynamicVersionTextField.setText("");
localRuleTextArea.setText("");
dynamicRuleTextArea.setText("");
}
public void setGray(TNode node) {
this.group = null;
this.node = node;
InstanceEntity instance = (InstanceEntity) node.getUserObject();
if (versionTabbedPane.getTabCount() == 1) {
versionTabbedPane.addTab("初始(本地)版本", localVersionPanel, "初始(本地)版本");
}
if (ruleTabbedPane.getTabCount() == 1) {
ruleTabbedPane.addTab("初始(本地)规则", new JBasicScrollPane(localRuleTextArea), "初始(本地)规则");
}
localVersionTextField.setText(instance.getVersion());
dynamicVersionTextField.setText(instance.getDynamicVersion());
localRuleTextArea.setText(instance.getRule());
dynamicRuleTextArea.setText(instance.getDynamicRule());
}
private JSecurityAction createUpdateVersionAction() {
......@@ -590,7 +599,19 @@ public class ServiceTopology extends AbstractTopology {
private static final long serialVersionUID = 1L;
public void execute(ActionEvent e) {
String dynamicRule = dynamicRuleTextArea.getText();
if (group != null) {
String serviceId = (String) group.getUserObject();
String result = ServiceController.configUpdate(serviceId, dynamicRule);
System.out.println(result);
refreshGrayState(group);
} else if (node != null) {
InstanceEntity instance = (InstanceEntity) node.getUserObject();
refreshGrayState(node);
}
}
};
......@@ -602,7 +623,17 @@ public class ServiceTopology extends AbstractTopology {
private static final long serialVersionUID = 1L;
public void execute(ActionEvent e) {
if (group != null) {
String serviceId = (String) group.getUserObject();
String result = ServiceController.configClear(serviceId);
System.out.println(result);
refreshGrayState(group);
} else if (node != null) {
InstanceEntity instance = (InstanceEntity) node.getUserObject();
refreshGrayState(node);
}
}
};
......
......@@ -7,8 +7,8 @@ service_topology=服务拓扑
show_topology=显示服务拓扑
execute_gray_release=执行灰度发布
refresh_gray_state=刷新灰度状态
execute_gray_router=执行灰度路由
refresh_gray_state=刷新灰度状态
service_list=服务列表
execute_router=执行路由
......
......@@ -7,8 +7,8 @@ service_topology=\u670d\u52a1\u62d3\u6251
show_topology=\u663e\u793a\u670d\u52a1\u62d3\u6251
execute_gray_release=\u6267\u884c\u7070\u5ea6\u53d1\u5e03
refresh_gray_state=\u5237\u65b0\u7070\u5ea6\u72b6\u6001
execute_gray_router=\u6267\u884c\u7070\u5ea6\u8def\u7531
refresh_gray_state=\u5237\u65b0\u7070\u5ea6\u72b6\u6001
service_list=\u670d\u52a1\u5217\u8868
execute_router=\u6267\u884c\u8def\u7531
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment