Commit f45e6e03 by Nepxion

增加图形化灰度发布功能

parent 75709c7c
...@@ -11,6 +11,8 @@ package com.nepxion.discovery.console.desktop.constant; ...@@ -11,6 +11,8 @@ package com.nepxion.discovery.console.desktop.constant;
public class ConsoleConstant { public class ConsoleConstant {
public static final String SPRING_APPLICATION_DISCOVERY_PLUGIN = "spring.application.discovery.plugin"; public static final String SPRING_APPLICATION_DISCOVERY_PLUGIN = "spring.application.discovery.plugin";
public static final String SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED = "spring.application.discovery.control.enabled";
public static final String SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED = "spring.application.config.rest.control.enabled";
public static final String FILTER = "filter"; public static final String FILTER = "filter";
public static final String PLUGIN = "plugin"; public static final String PLUGIN = "plugin";
......
...@@ -120,6 +120,24 @@ public class InstanceEntity implements Serializable { ...@@ -120,6 +120,24 @@ public class InstanceEntity implements Serializable {
return plugin; return plugin;
} }
public boolean isDiscoveryControlEnabled() {
String flag = metaData.get(ConsoleConstant.SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED);
if (flag == null) {
return true;
}
return Boolean.valueOf(flag);
}
public boolean isConfigRestControlEnabled() {
String flag = metaData.get(ConsoleConstant.SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED);
if (flag == null) {
return true;
}
return Boolean.valueOf(flag);
}
@Override @Override
public int hashCode() { public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this); return HashCodeBuilder.reflectionHashCode(this);
......
...@@ -769,10 +769,27 @@ public class ServiceTopology extends AbstractTopology { ...@@ -769,10 +769,27 @@ public class ServiceTopology extends AbstractTopology {
return panel; return panel;
} }
@SuppressWarnings("unchecked")
public void setGray(TGroup group) { public void setGray(TGroup group) {
this.group = group; this.group = group;
this.node = null; this.node = null;
boolean versionControlEnabled = false;
boolean ruleControlEnabled = false;
for (Iterator<TNode> iterator = group.children(); iterator.hasNext();) {
TNode node = iterator.next();
InstanceEntity instance = (InstanceEntity) node.getUserObject();
boolean versionEnabled = instance.isDiscoveryControlEnabled();
if (versionEnabled) {
versionControlEnabled = true;
}
boolean ruleEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled();
if (ruleEnabled) {
ruleControlEnabled = true;
}
}
if (versionTabbedPane.getTabCount() == 2) { if (versionTabbedPane.getTabCount() == 2) {
versionTabbedPane.remove(1); versionTabbedPane.remove(1);
} }
...@@ -784,11 +801,15 @@ public class ServiceTopology extends AbstractTopology { ...@@ -784,11 +801,15 @@ public class ServiceTopology extends AbstractTopology {
localVersionTextField.setText(""); localVersionTextField.setText("");
updateVersionButton.setText(ConsoleLocale.getString("button_batch_update_version")); updateVersionButton.setText(ConsoleLocale.getString("button_batch_update_version"));
clearVersionButton.setText(ConsoleLocale.getString("button_batch_clear_version")); clearVersionButton.setText(ConsoleLocale.getString("button_batch_clear_version"));
updateVersionButton.setEnabled(versionControlEnabled);
clearVersionButton.setEnabled(versionControlEnabled);
dynamicRuleTextArea.setText(""); dynamicRuleTextArea.setText("");
localRuleTextArea.setText(""); localRuleTextArea.setText("");
updateRuleButton.setText(ConsoleLocale.getString("button_batch_update_rule")); updateRuleButton.setText(ConsoleLocale.getString("button_batch_update_rule"));
clearRuleButton.setText(ConsoleLocale.getString("button_batch_clear_rule")); clearRuleButton.setText(ConsoleLocale.getString("button_batch_clear_rule"));
updateRuleButton.setEnabled(ruleControlEnabled);
clearRuleButton.setEnabled(ruleControlEnabled);
} }
public void setGray(TNode node) { public void setGray(TNode node) {
...@@ -796,6 +817,9 @@ public class ServiceTopology extends AbstractTopology { ...@@ -796,6 +817,9 @@ public class ServiceTopology extends AbstractTopology {
this.node = node; this.node = node;
InstanceEntity instance = (InstanceEntity) node.getUserObject(); InstanceEntity instance = (InstanceEntity) node.getUserObject();
boolean versionControlEnabled = instance.isDiscoveryControlEnabled();
boolean ruleControlEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled();
if (versionTabbedPane.getTabCount() == 1) { if (versionTabbedPane.getTabCount() == 1) {
versionTabbedPane.addTab(ConsoleLocale.getString("label_local_version"), localVersionPanel, ConsoleLocale.getString("label_local_version")); versionTabbedPane.addTab(ConsoleLocale.getString("label_local_version"), localVersionPanel, ConsoleLocale.getString("label_local_version"));
} }
...@@ -807,11 +831,15 @@ public class ServiceTopology extends AbstractTopology { ...@@ -807,11 +831,15 @@ public class ServiceTopology extends AbstractTopology {
localVersionTextField.setText(instance.getVersion()); localVersionTextField.setText(instance.getVersion());
updateVersionButton.setText(ConsoleLocale.getString("button_update_version")); updateVersionButton.setText(ConsoleLocale.getString("button_update_version"));
clearVersionButton.setText(ConsoleLocale.getString("button_clear_version")); clearVersionButton.setText(ConsoleLocale.getString("button_clear_version"));
updateVersionButton.setEnabled(versionControlEnabled);
clearVersionButton.setEnabled(versionControlEnabled);
dynamicRuleTextArea.setText(instance.getDynamicRule()); dynamicRuleTextArea.setText(instance.getDynamicRule());
localRuleTextArea.setText(instance.getRule()); localRuleTextArea.setText(instance.getRule());
updateRuleButton.setText(ConsoleLocale.getString("button_update_rule")); updateRuleButton.setText(ConsoleLocale.getString("button_update_rule"));
clearRuleButton.setText(ConsoleLocale.getString("button_clear_rule")); clearRuleButton.setText(ConsoleLocale.getString("button_clear_rule"));
updateRuleButton.setEnabled(ruleControlEnabled);
clearRuleButton.setEnabled(ruleControlEnabled);
} }
private JSecurityAction createUpdateVersionAction() { private JSecurityAction createUpdateVersionAction() {
......
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