Commit f45e6e03 by Nepxion

增加图形化灰度发布功能

parent 75709c7c
......@@ -11,6 +11,8 @@ package com.nepxion.discovery.console.desktop.constant;
public class ConsoleConstant {
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 PLUGIN = "plugin";
......
......@@ -120,6 +120,24 @@ public class InstanceEntity implements Serializable {
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
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
......
......@@ -769,10 +769,27 @@ public class ServiceTopology extends AbstractTopology {
return panel;
}
@SuppressWarnings("unchecked")
public void setGray(TGroup group) {
this.group = group;
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) {
versionTabbedPane.remove(1);
}
......@@ -784,11 +801,15 @@ public class ServiceTopology extends AbstractTopology {
localVersionTextField.setText("");
updateVersionButton.setText(ConsoleLocale.getString("button_batch_update_version"));
clearVersionButton.setText(ConsoleLocale.getString("button_batch_clear_version"));
updateVersionButton.setEnabled(versionControlEnabled);
clearVersionButton.setEnabled(versionControlEnabled);
dynamicRuleTextArea.setText("");
localRuleTextArea.setText("");
updateRuleButton.setText(ConsoleLocale.getString("button_batch_update_rule"));
clearRuleButton.setText(ConsoleLocale.getString("button_batch_clear_rule"));
updateRuleButton.setEnabled(ruleControlEnabled);
clearRuleButton.setEnabled(ruleControlEnabled);
}
public void setGray(TNode node) {
......@@ -796,6 +817,9 @@ public class ServiceTopology extends AbstractTopology {
this.node = node;
InstanceEntity instance = (InstanceEntity) node.getUserObject();
boolean versionControlEnabled = instance.isDiscoveryControlEnabled();
boolean ruleControlEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled();
if (versionTabbedPane.getTabCount() == 1) {
versionTabbedPane.addTab(ConsoleLocale.getString("label_local_version"), localVersionPanel, ConsoleLocale.getString("label_local_version"));
}
......@@ -807,11 +831,15 @@ public class ServiceTopology extends AbstractTopology {
localVersionTextField.setText(instance.getVersion());
updateVersionButton.setText(ConsoleLocale.getString("button_update_version"));
clearVersionButton.setText(ConsoleLocale.getString("button_clear_version"));
updateVersionButton.setEnabled(versionControlEnabled);
clearVersionButton.setEnabled(versionControlEnabled);
dynamicRuleTextArea.setText(instance.getDynamicRule());
localRuleTextArea.setText(instance.getRule());
updateRuleButton.setText(ConsoleLocale.getString("button_update_rule"));
clearRuleButton.setText(ConsoleLocale.getString("button_clear_rule"));
updateRuleButton.setEnabled(ruleControlEnabled);
clearRuleButton.setEnabled(ruleControlEnabled);
}
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