Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
e799431e
Commit
e799431e
authored
Jul 20, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加图形化灰度发布功能
parent
b08fc455
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
23 deletions
+82
-23
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/entity/InstanceEntity.java
+23
-1
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/ServiceTopology.java
+56
-20
discovery-console-desktop/src/main/resources/config/console.properties
+3
-2
No files found.
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/entity/InstanceEntity.java
View file @
e799431e
...
...
@@ -12,11 +12,14 @@ package com.nepxion.discovery.console.desktop.entity;
import
java.io.Serializable
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
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.context.PropertiesContext
;
public
class
InstanceEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
3001191508072178378L
;
...
...
@@ -93,8 +96,27 @@ public class InstanceEntity implements Serializable {
this
.
rule
=
rule
;
}
public
String
getFilter
()
{
String
filterKey
=
PropertiesContext
.
getProperties
().
getString
(
"filter"
);
if
(
StringUtils
.
isEmpty
(
filterKey
))
{
return
""
;
}
String
filter
=
metaData
.
get
(
filterKey
);
if
(
filter
==
null
)
{
return
""
;
}
return
filter
;
}
public
String
getPlugin
()
{
return
metaData
.
get
(
"discovery.plugin"
);
String
plugin
=
metaData
.
get
(
"discovery.plugin"
);
if
(
plugin
==
null
)
{
return
""
;
}
return
plugin
;
}
@Override
...
...
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/ServiceTopology.java
View file @
e799431e
...
...
@@ -24,10 +24,12 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.swing.BorderFactory
;
import
javax.swing.Box
;
import
javax.swing.BoxLayout
;
import
javax.swing.DefaultComboBoxModel
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JToolBar
;
...
...
@@ -55,6 +57,7 @@ import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityTy
import
com.nepxion.swing.action.JSecurityAction
;
import
com.nepxion.swing.button.ButtonManager
;
import
com.nepxion.swing.button.JClassicButton
;
import
com.nepxion.swing.combobox.JBasicComboBox
;
import
com.nepxion.swing.dialog.JExceptionDialog
;
import
com.nepxion.swing.dialog.JOptionDialog
;
import
com.nepxion.swing.handle.HandleManager
;
...
...
@@ -90,10 +93,11 @@ public class ServiceTopology extends AbstractTopology {
private
Map
<
String
,
List
<
InstanceEntity
>>
instanceMap
;
private
JBasicComboBox
filterComboBox
;
private
GrayPanel
grayPanel
;
private
JBasicTextArea
resultTextArea
;
private
RouterTopology
routerTopology
;
private
LayoutDialog
layoutDialog
;
private
JBasicTextArea
resultTextArea
;
public
ServiceTopology
()
{
initializeToolBar
();
...
...
@@ -162,14 +166,41 @@ public class ServiceTopology extends AbstractTopology {
return
null
;
}
});
setGroupAutoExpand
(
true
);
setLinkAutoHide
(
true
);
}
@SuppressWarnings
(
"unchecked"
)
private
void
addServices
(
Map
<
String
,
List
<
InstanceEntity
>>
instanceMap
)
{
List
<
String
>
filterList
=
new
ArrayList
<
String
>();
filterList
.
add
(
""
);
// 表示不过滤
for
(
Map
.
Entry
<
String
,
List
<
InstanceEntity
>>
entry
:
instanceMap
.
entrySet
())
{
addService
(
entry
.
getKey
(),
entry
.
getValue
());
List
<
InstanceEntity
>
instances
=
entry
.
getValue
();
if
(
CollectionUtils
.
isNotEmpty
(
instances
))
{
for
(
InstanceEntity
instance
:
instances
)
{
String
filter
=
instance
.
getFilter
();
if
(!
filterList
.
contains
(
filter
))
{
filterList
.
add
(
filter
);
}
}
}
}
if
(
filterComboBox
==
null
)
{
filterComboBox
=
new
JBasicComboBox
();
filterComboBox
.
setPreferredSize
(
new
Dimension
(
300
,
filterComboBox
.
getPreferredSize
().
height
));
}
filterComboBox
.
setModel
(
new
DefaultComboBoxModel
<>(
filterList
.
toArray
()));
JBasicOptionPane
.
showOptionDialog
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
filterComboBox
,
"服务集群过滤"
,
JBasicOptionPane
.
DEFAULT_OPTION
,
JBasicOptionPane
.
PLAIN_MESSAGE
,
ConsoleIconFactory
.
getSwingIcon
(
"banner/navigator.png"
),
new
Object
[]
{
SwingLocale
.
getString
(
"close"
)
},
null
,
true
);
for
(
Map
.
Entry
<
String
,
List
<
InstanceEntity
>>
entry
:
instanceMap
.
entrySet
())
{
String
serviceId
=
entry
.
getKey
();
List
<
InstanceEntity
>
instances
=
entry
.
getValue
();
addService
(
serviceId
,
instances
);
}
}
...
...
@@ -188,19 +219,16 @@ public class ServiceTopology extends AbstractTopology {
if
(
CollectionUtils
.
isNotEmpty
(
instances
))
{
for
(
int
i
=
0
;
i
<
instances
.
size
();
i
++)
{
InstanceEntity
instance
=
instances
.
get
(
i
);
String
filter
=
instance
.
getFilter
();
String
plugin
=
instance
.
getPlugin
();
String
nodeName
=
getNodeName
(
instance
);
TNode
node
=
null
;
if
(
StringUtils
.
isNotEmpty
(
plugin
))
{
node
=
createNode
(
nodeName
,
serviceNodeEntity
,
nodeLocationEntity
,
i
);
setPlugin
(
node
,
plugin
);
setPlugin
(
group
,
plugin
);
}
else
{
node
=
createNode
(
nodeName
,
notServiceNodeEntity
,
nodeLocationEntity
,
i
);
setPlugin
(
node
,
""
);
setPlugin
(
group
,
""
);
}
TNode
node
=
createNode
(
nodeName
,
StringUtils
.
isNotEmpty
(
plugin
)
?
serviceNodeEntity
:
notServiceNodeEntity
,
nodeLocationEntity
,
i
);
setFilter
(
node
,
filter
);
setFilter
(
group
,
filter
);
setPlugin
(
node
,
plugin
);
setPlugin
(
group
,
plugin
);
node
.
setUserObject
(
instance
);
group
.
addChild
(
node
);
...
...
@@ -215,6 +243,14 @@ public class ServiceTopology extends AbstractTopology {
TElementManager
.
addGroupChildren
(
dataBox
,
group
);
}
private
String
getFilter
(
TElement
element
)
{
return
element
.
getClientProperty
(
"filter"
).
toString
();
}
private
void
setFilter
(
TElement
element
,
String
filter
)
{
element
.
putClientProperty
(
"filter"
,
filter
);
}
private
String
getPlugin
(
TElement
element
)
{
return
element
.
getClientProperty
(
"plugin"
).
toString
();
}
...
...
@@ -230,11 +266,11 @@ public class ServiceTopology extends AbstractTopology {
}
private
Object
[]
filterServices
(
TNode
node
)
{
Object
[]
services
=
instanceMap
.
keySet
().
toArray
();
List
<
Object
>
filterServices
=
new
ArrayList
<
Object
>();
Set
<
String
>
services
=
instanceMap
.
keySet
();
List
<
String
>
filterServices
=
new
ArrayList
<
String
>();
for
(
Object
service
:
services
)
{
TGroup
group
=
getGroup
(
service
.
toString
()
);
for
(
String
service
:
services
)
{
TGroup
group
=
getGroup
(
service
);
// node.getParent() != group 表示自己不能路由自己,暂时不禁止
if
(
group
!=
null
&&
isPlugin
(
group
))
{
filterServices
.
add
(
service
);
...
...
@@ -258,12 +294,12 @@ public class ServiceTopology extends AbstractTopology {
return
null
;
}
private
String
getGroupName
(
String
serviceId
,
int
count
,
String
plugin
)
{
return
ButtonManager
.
getHtmlText
(
serviceId
+
" ["
+
count
+
"]"
+
(
StringUtils
.
isNotEmpty
(
plugin
)
?
"\n"
+
plugin
:
""
));
private
String
getGroupName
(
String
serviceId
,
int
count
,
String
filter
)
{
return
ButtonManager
.
getHtmlText
(
serviceId
+
" ["
+
count
+
"]"
+
(
StringUtils
.
isNotEmpty
(
filter
)
?
"\n"
+
filter
:
""
));
}
private
void
updateGroup
(
TGroup
group
)
{
String
name
=
getGroupName
(
group
.
getUserObject
().
toString
(),
group
.
childrenSize
(),
get
Plugin
(
group
));
String
name
=
getGroupName
(
group
.
getUserObject
().
toString
(),
group
.
childrenSize
(),
get
Filter
(
group
));
group
.
setName
(
name
);
}
...
...
discovery-console-desktop/src/main/resources/config/console.properties
View file @
e799431e
url
=
http://localhost:2222/
\ No newline at end of file
url
=
http://localhost:2222/
filter
=
group
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment