Commit ed132fe2 by Nepxion

增加图形化灰度发布功能

parent 788bb2ec
......@@ -113,6 +113,24 @@ public class ServiceController {
return result;
}
public static String remoteConfigUpdate(String group, String serviceId, String config) {
String url = getUrl() + "/console/remote-config/update/" + group + "/" + serviceId;
// 解决中文乱码
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> entity = new HttpEntity<String>(config, headers);
String result = restTemplate.postForEntity(url, entity, String.class).getBody();
if (!StringUtils.equals(result, "OK") && !StringUtils.equals(result, "NO")) {
ServiceErrorHandler errorHandler = (ServiceErrorHandler) restTemplate.getErrorHandler();
result = errorHandler.getCause();
}
return result;
}
public static List<ResultEntity> configUpdate(String serviceId, String config) {
String url = getUrl() + "/console/config/update-sync/" + serviceId;
......@@ -145,6 +163,19 @@ public class ServiceController {
return result;
}
public static String remoteConfigClear(String group, String serviceId) {
String url = getUrl() + "/console/remote-config/clear/" + group + "/" + serviceId;
String result = restTemplate.postForEntity(url, null, String.class).getBody();
if (!StringUtils.equals(result, "OK") && !StringUtils.equals(result, "NO")) {
ServiceErrorHandler errorHandler = (ServiceErrorHandler) restTemplate.getErrorHandler();
result = errorHandler.getCause();
}
return result;
}
public static List<ResultEntity> configClear(String serviceId) {
String url = getUrl() + "/console/config/clear/" + serviceId;
......
......@@ -19,18 +19,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class ResultEntity implements Serializable {
private static final long serialVersionUID = -3322655604556025836L;
private String serviceId;
private String url;
private String result;
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getUrl() {
return url;
}
......
......@@ -812,19 +812,21 @@ public class ServiceTopology extends AbstractTopology {
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 versionControlEnabled = ruleToConfigCenterRadioButtonMenuItem.isSelected();
boolean ruleControlEnabled = ruleToConfigCenterRadioButtonMenuItem.isSelected();
if (!versionControlEnabled && !ruleControlEnabled) {
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;
boolean versionEnabled = instance.isDiscoveryControlEnabled();
if (versionEnabled) {
versionControlEnabled = true;
}
boolean ruleEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled();
if (ruleEnabled) {
ruleControlEnabled = true;
}
}
}
......@@ -865,7 +867,7 @@ public class ServiceTopology extends AbstractTopology {
InstanceEntity instance = (InstanceEntity) node.getUserObject();
boolean versionControlEnabled = instance.isDiscoveryControlEnabled();
boolean ruleControlEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled();
boolean ruleControlEnabled = instance.isDiscoveryControlEnabled() && instance.isConfigRestControlEnabled() && !ruleToConfigCenterRadioButtonMenuItem.isSelected();
if (versionTabbedPane.getTabCount() == 1) {
versionTabbedPane.addTab(ConsoleLocale.getString("label_local_version"), localVersionPanel, ConsoleLocale.getString("label_local_version"));
......@@ -1009,18 +1011,35 @@ public class ServiceTopology extends AbstractTopology {
if (group != null) {
String serviceId = (String) group.getUserObject();
List<ResultEntity> results = null;
try {
results = ServiceController.configUpdate(serviceId, dynamicRule);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
refreshGrayState(group);
if (ruleToConfigCenterRadioButtonMenuItem.isSelected()) {
String filter = getFilter(group);
String result = null;
try {
result = ServiceController.remoteConfigUpdate(filter, serviceId, dynamicRule);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
return;
}
refreshGrayState(group);
showResult(results);
return;
}
showResult(result);
} else {
List<ResultEntity> results = null;
try {
results = ServiceController.configUpdate(serviceId, dynamicRule);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
refreshGrayState(group);
return;
}
showResult(results);
}
refreshGrayState(group);
} else if (node != null) {
......@@ -1054,18 +1073,34 @@ public class ServiceTopology extends AbstractTopology {
public void execute(ActionEvent e) {
if (group != null) {
String serviceId = (String) group.getUserObject();
List<ResultEntity> results = null;
try {
results = ServiceController.configClear(serviceId);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
if (ruleToConfigCenterRadioButtonMenuItem.isSelected()) {
String filter = getFilter(group);
String result = null;
try {
result = ServiceController.remoteConfigClear(filter, serviceId);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
refreshGrayState(group);
refreshGrayState(group);
return;
}
return;
}
showResult(results);
showResult(result);
} else {
List<ResultEntity> results = null;
try {
results = ServiceController.configClear(serviceId);
} catch (Exception ex) {
JExceptionDialog.traceException(HandleManager.getFrame(ServiceTopology.this), ConsoleLocale.getString("query_data_failure"), ex);
refreshGrayState(group);
return;
}
showResult(results);
}
refreshGrayState(group);
} else if (node != null) {
......
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