Commit 347fef54 by Nepxion

增加图形化灰度发布功能

parent 1a2d2978
package com.nepxion.discovery.console.desktop.constant;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
public class ConsoleConstant {
public static final String SPRING_APPLICATION_DISCOVERY_PLUGIN = "spring.application.discovery.plugin";
public static final String SPRING_APPLICATION_REGISTER_CONTROL_ENABLED = "spring.application.register.control.enabled";
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";
public static final String NO_FILTER_DESCRIPTION = "[No filter]";
}
......@@ -18,6 +18,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.nepxion.discovery.console.desktop.constant.ConsoleConstant;
import com.nepxion.discovery.console.desktop.context.PropertiesContext;
public class InstanceEntity implements Serializable {
......@@ -97,7 +98,7 @@ public class InstanceEntity implements Serializable {
}
public String getFilter() {
String filterKey = PropertiesContext.getProperties().getString("filter");
String filterKey = PropertiesContext.getProperties().getString(ConsoleConstant.FILTER);
if (StringUtils.isEmpty(filterKey)) {
return "";
}
......@@ -111,7 +112,7 @@ public class InstanceEntity implements Serializable {
}
public String getPlugin() {
String plugin = metaData.get("discovery.plugin");
String plugin = metaData.get(ConsoleConstant.SPRING_APPLICATION_DISCOVERY_PLUGIN);
if (plugin == null) {
return "";
}
......@@ -119,6 +120,33 @@ public class InstanceEntity implements Serializable {
return plugin;
}
public boolean isRegisterControlEnabled() {
String flag = metaData.get(ConsoleConstant.SPRING_APPLICATION_REGISTER_CONTROL_ENABLED);
if (flag == null) {
return true;
}
return Boolean.valueOf(flag);
}
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);
......
......@@ -44,6 +44,7 @@ import com.nepxion.cots.twaver.element.TGroupType;
import com.nepxion.cots.twaver.element.TNode;
import com.nepxion.cots.twaver.graph.TGraphBackground;
import com.nepxion.cots.twaver.graph.TGraphManager;
import com.nepxion.discovery.console.desktop.constant.ConsoleConstant;
import com.nepxion.discovery.console.desktop.controller.ServiceController;
import com.nepxion.discovery.console.desktop.entity.InstanceEntity;
import com.nepxion.discovery.console.desktop.entity.ResultEntity;
......@@ -77,7 +78,6 @@ import com.nepxion.swing.textfield.number.JNumberTextField;
public class ServiceTopology extends AbstractTopology {
private static final long serialVersionUID = 1L;
private static final String NO_FILTER = "[No filter]";
private LocationEntity groupLocationEntity = new LocationEntity(120, 250, 280, 0);
private LocationEntity nodeLocationEntity = new LocationEntity(0, 0, 120, 100);
......@@ -175,19 +175,19 @@ public class ServiceTopology extends AbstractTopology {
}
private String getFilter(TElement element) {
return element.getClientProperty("filter").toString();
return element.getClientProperty(ConsoleConstant.FILTER).toString();
}
private void setFilter(TElement element, String filter) {
element.putClientProperty("filter", filter);
element.putClientProperty(ConsoleConstant.FILTER, filter);
}
private String getPlugin(TElement element) {
return element.getClientProperty("plugin").toString();
return element.getClientProperty(ConsoleConstant.PLUGIN).toString();
}
private void setPlugin(TElement element, String plugin) {
element.putClientProperty("plugin", plugin);
element.putClientProperty(ConsoleConstant.PLUGIN, plugin);
}
private boolean isPlugin(TElement element) {
......@@ -208,7 +208,7 @@ public class ServiceTopology extends AbstractTopology {
String filter = getValidFilter(instances);
String plugin = getValidPlugin(instances);
if (!StringUtils.equals(filterId, NO_FILTER) && !StringUtils.equals(filterId, filter)) {
if (!StringUtils.equals(filterId, ConsoleConstant.NO_FILTER_DESCRIPTION) && !StringUtils.equals(filterId, filter)) {
return;
}
......@@ -288,7 +288,7 @@ public class ServiceTopology extends AbstractTopology {
if (filters.contains("")) {
filters.remove("");
}
filters.add(NO_FILTER);
filters.add(ConsoleConstant.NO_FILTER_DESCRIPTION);
return filters.toArray();
}
......@@ -497,7 +497,7 @@ public class ServiceTopology extends AbstractTopology {
globalFilter = filterPanel.getFilter();
String title = ConsoleLocale.getString("title_service_cluster_gray_release");
if (!StringUtils.equals(globalFilter, NO_FILTER)) {
if (!StringUtils.equals(globalFilter, ConsoleConstant.NO_FILTER_DESCRIPTION)) {
title += " [" + globalFilter + "]";
}
background.setTitle(title);
......@@ -654,7 +654,7 @@ public class ServiceTopology extends AbstractTopology {
setLayout(new FiledLayout(FiledLayout.COLUMN, FiledLayout.FULL, 5));
add(filterComboBox);
add(new JLabel(NO_FILTER + " - " + ConsoleLocale.getString("no_service_cluster_filter")));
add(new JLabel(ConsoleConstant.NO_FILTER_DESCRIPTION + " - " + ConsoleLocale.getString("no_service_cluster_filter")));
}
@SuppressWarnings("unchecked")
......
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