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
0551a0c3
Commit
0551a0c3
authored
Jul 18, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加图形化灰度发布功能
parent
6831b694
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
20 deletions
+128
-20
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/controller/ServiceController.java
+34
-12
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/entity/ResultEntity.java
+65
-0
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/ServiceTopology.java
+29
-8
No files found.
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/controller/ServiceController.java
View file @
0551a0c3
...
@@ -20,6 +20,7 @@ import org.springframework.web.client.RestTemplate;
...
@@ -20,6 +20,7 @@ import org.springframework.web.client.RestTemplate;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.nepxion.discovery.console.desktop.context.PropertiesContext
;
import
com.nepxion.discovery.console.desktop.context.PropertiesContext
;
import
com.nepxion.discovery.console.desktop.entity.InstanceEntity
;
import
com.nepxion.discovery.console.desktop.entity.InstanceEntity
;
import
com.nepxion.discovery.console.desktop.entity.ResultEntity
;
import
com.nepxion.discovery.console.desktop.entity.RouterEntity
;
import
com.nepxion.discovery.console.desktop.entity.RouterEntity
;
import
com.nepxion.discovery.console.desktop.serializer.JacksonSerializer
;
import
com.nepxion.discovery.console.desktop.serializer.JacksonSerializer
;
...
@@ -35,49 +36,61 @@ public class ServiceController {
...
@@ -35,49 +36,61 @@ public class ServiceController {
String
json
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
String
json
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
return
JacksonSerializer
.
fromJson
(
json
,
new
TypeReference
<
Map
<
String
,
List
<
InstanceEntity
>>>()
{
return
convert
(
json
,
new
TypeReference
<
Map
<
String
,
List
<
InstanceEntity
>>>()
{
});
});
}
}
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
String
>
getVersions
(
InstanceEntity
instance
)
{
public
static
List
<
String
>
getVersions
(
InstanceEntity
instance
)
{
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/version/view"
;
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/version/view"
;
return
restTemplate
.
getForEntity
(
url
,
List
.
class
).
getBody
();
String
json
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
return
convert
(
json
,
new
TypeReference
<
List
<
String
>>()
{
});
}
}
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
String
>
getRules
(
InstanceEntity
instance
)
{
public
static
List
<
String
>
getRules
(
InstanceEntity
instance
)
{
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/config/view"
;
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/config/view"
;
return
restTemplate
.
getForEntity
(
url
,
List
.
class
).
getBody
();
String
json
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
return
convert
(
json
,
new
TypeReference
<
List
<
String
>>()
{
});
}
}
public
static
RouterEntity
routes
(
InstanceEntity
instance
,
String
routeServiceIds
)
{
public
static
RouterEntity
routes
(
InstanceEntity
instance
,
String
routeServiceIds
)
{
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/router/routes"
;
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/router/routes"
;
return
restTemplate
.
postForEntity
(
url
,
routeServiceIds
,
RouterEntity
.
class
).
getBody
();
String
json
=
restTemplate
.
postForEntity
(
url
,
routeServiceIds
,
String
.
class
).
getBody
();
return
convert
(
json
,
new
TypeReference
<
RouterEntity
>()
{
});
}
}
public
static
String
configUpdate
(
String
serviceId
,
String
config
)
{
public
static
List
<
ResultEntity
>
configUpdate
(
String
serviceId
,
String
config
)
{
String
url
=
getUrl
()
+
"/console/config/update-sync/"
+
serviceId
;
String
url
=
getUrl
()
+
"/console/config/update-sync/"
+
serviceId
;
// 解决中文乱码
// 解决中文乱码
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
HttpEntity
<
String
>
entity
=
new
HttpEntity
<
String
>(
config
,
headers
);
HttpEntity
<
String
>
entity
=
new
HttpEntity
<
String
>(
config
,
headers
);
return
restTemplate
.
postForEntity
(
url
,
entity
,
String
.
class
).
getBody
();
String
json
=
restTemplate
.
postForEntity
(
url
,
entity
,
String
.
class
).
getBody
();
return
convert
(
json
,
new
TypeReference
<
List
<
ResultEntity
>>()
{
});
}
}
public
static
String
configClear
(
String
serviceId
)
{
public
static
List
<
ResultEntity
>
configClear
(
String
serviceId
)
{
String
url
=
getUrl
()
+
"/console/config/clear/"
+
serviceId
;
String
url
=
getUrl
()
+
"/console/config/clear/"
+
serviceId
;
return
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
).
getBody
();
String
json
=
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
).
getBody
();
return
convert
(
json
,
new
TypeReference
<
List
<
ResultEntity
>>()
{
});
}
}
p
ublic
static
String
getUrl
()
{
p
rivate
static
String
getUrl
()
{
String
url
=
PropertiesContext
.
getProperties
().
getString
(
"url"
);
String
url
=
PropertiesContext
.
getProperties
().
getString
(
"url"
);
if
(!
url
.
endsWith
(
"/"
))
{
if
(!
url
.
endsWith
(
"/"
))
{
url
+=
"/"
;
url
+=
"/"
;
...
@@ -85,4 +98,12 @@ public class ServiceController {
...
@@ -85,4 +98,12 @@ public class ServiceController {
return
url
;
return
url
;
}
}
private
static
<
T
>
T
convert
(
String
json
,
TypeReference
<
T
>
typeReference
)
{
try
{
return
JacksonSerializer
.
fromJson
(
json
,
typeReference
);
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
json
);
}
}
}
}
\ No newline at end of file
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/entity/ResultEntity.java
0 → 100644
View file @
0551a0c3
package
com
.
nepxion
.
discovery
.
console
.
desktop
.
entity
;
/**
* <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
*/
import
java.io.Serializable
;
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
;
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
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getResult
()
{
return
result
;
}
public
void
setResult
(
String
result
)
{
this
.
result
=
result
;
}
@Override
public
int
hashCode
()
{
return
HashCodeBuilder
.
reflectionHashCode
(
this
);
}
@Override
public
boolean
equals
(
Object
object
)
{
return
EqualsBuilder
.
reflectionEquals
(
this
,
object
);
}
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
);
}
}
\ No newline at end of file
discovery-console-desktop/src/main/java/com/nepxion/discovery/console/desktop/workspace/ServiceTopology.java
View file @
0551a0c3
...
@@ -42,6 +42,7 @@ import com.nepxion.cots.twaver.element.TNode;
...
@@ -42,6 +42,7 @@ import com.nepxion.cots.twaver.element.TNode;
import
com.nepxion.cots.twaver.graph.TGraphManager
;
import
com.nepxion.cots.twaver.graph.TGraphManager
;
import
com.nepxion.discovery.console.desktop.controller.ServiceController
;
import
com.nepxion.discovery.console.desktop.controller.ServiceController
;
import
com.nepxion.discovery.console.desktop.entity.InstanceEntity
;
import
com.nepxion.discovery.console.desktop.entity.InstanceEntity
;
import
com.nepxion.discovery.console.desktop.entity.ResultEntity
;
import
com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory
;
import
com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory
;
import
com.nepxion.discovery.console.desktop.locale.ConsoleLocale
;
import
com.nepxion.discovery.console.desktop.locale.ConsoleLocale
;
import
com.nepxion.discovery.console.desktop.util.UIUtil
;
import
com.nepxion.discovery.console.desktop.util.UIUtil
;
...
@@ -95,6 +96,7 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -95,6 +96,7 @@ public class ServiceTopology extends AbstractTopology {
private
GrayPanel
grayPanel
;
private
GrayPanel
grayPanel
;
private
RouterTopology
routerTopology
;
private
RouterTopology
routerTopology
;
private
LayoutDialog
layoutDialog
;
private
LayoutDialog
layoutDialog
;
private
JBasicTextArea
resultTextArea
;
public
ServiceTopology
()
{
public
ServiceTopology
()
{
initializeToolBar
();
initializeToolBar
();
...
@@ -296,8 +298,8 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -296,8 +298,8 @@ public class ServiceTopology extends AbstractTopology {
try
{
try
{
updateGrayState
(
node
);
updateGrayState
(
node
);
}
catch
(
Exception
e
x
)
{
}
catch
(
Exception
e
)
{
JExceptionDialog
.
traceException
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
ConsoleLocale
.
getString
(
"query_data_failure"
),
e
x
);
JExceptionDialog
.
traceException
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
ConsoleLocale
.
getString
(
"query_data_failure"
),
e
);
group
.
removeChild
(
node
);
group
.
removeChild
(
node
);
dataBox
.
removeElement
(
node
);
dataBox
.
removeElement
(
node
);
...
@@ -316,8 +318,8 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -316,8 +318,8 @@ public class ServiceTopology extends AbstractTopology {
try
{
try
{
updateGrayState
(
node
);
updateGrayState
(
node
);
}
catch
(
Exception
e
x
)
{
}
catch
(
Exception
e
)
{
JExceptionDialog
.
traceException
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
ConsoleLocale
.
getString
(
"query_data_failure"
),
e
x
);
JExceptionDialog
.
traceException
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
ConsoleLocale
.
getString
(
"query_data_failure"
),
e
);
iterator
.
remove
();
iterator
.
remove
();
dataBox
.
removeElement
(
node
);
dataBox
.
removeElement
(
node
);
...
@@ -327,6 +329,17 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -327,6 +329,17 @@ public class ServiceTopology extends AbstractTopology {
updateGroup
(
group
);
updateGroup
(
group
);
}
}
private
void
showResult
(
Object
result
)
{
if
(
resultTextArea
==
null
)
{
resultTextArea
=
new
JBasicTextArea
();
resultTextArea
.
setLineWrap
(
true
);
resultTextArea
.
setPreferredSize
(
new
Dimension
(
800
,
800
));
}
resultTextArea
.
setText
(
result
.
toString
());
JBasicOptionPane
.
showOptionDialog
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
new
JBasicScrollPane
(
resultTextArea
),
"执行结果"
,
JBasicOptionPane
.
DEFAULT_OPTION
,
JBasicOptionPane
.
PLAIN_MESSAGE
,
ConsoleIconFactory
.
getSwingIcon
(
"banner/edit.png"
),
new
Object
[]
{
SwingLocale
.
getString
(
"close"
)
},
null
,
true
);
}
@Override
@Override
public
void
showLayout
()
{
public
void
showLayout
()
{
if
(
layoutDialog
==
null
)
{
if
(
layoutDialog
==
null
)
{
...
@@ -601,18 +614,25 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -601,18 +614,25 @@ public class ServiceTopology extends AbstractTopology {
public
void
execute
(
ActionEvent
e
)
{
public
void
execute
(
ActionEvent
e
)
{
String
dynamicRule
=
dynamicRuleTextArea
.
getText
();
String
dynamicRule
=
dynamicRuleTextArea
.
getText
();
if
(
StringUtils
.
isEmpty
(
dynamicRule
))
{
JBasicOptionPane
.
showMessageDialog
(
HandleManager
.
getFrame
(
ServiceTopology
.
this
),
"规则不能为空"
,
SwingLocale
.
getString
(
"warning"
),
JBasicOptionPane
.
WARNING_MESSAGE
);
return
;
}
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
String
serviceId
=
(
String
)
group
.
getUserObject
();
String
serviceId
=
(
String
)
group
.
getUserObject
();
String
result
=
ServiceController
.
configUpdate
(
serviceId
,
dynamicRule
);
List
<
ResultEntity
>
results
=
ServiceController
.
configUpdate
(
serviceId
,
dynamicRule
);
showResult
(
results
);
System
.
out
.
println
(
result
);
refreshGrayState
(
group
);
refreshGrayState
(
group
);
}
else
if
(
node
!=
null
)
{
}
else
if
(
node
!=
null
)
{
InstanceEntity
instance
=
(
InstanceEntity
)
node
.
getUserObject
();
InstanceEntity
instance
=
(
InstanceEntity
)
node
.
getUserObject
();
refreshGrayState
(
node
);
refreshGrayState
(
node
);
}
}
}
}
};
};
...
@@ -626,9 +646,10 @@ public class ServiceTopology extends AbstractTopology {
...
@@ -626,9 +646,10 @@ public class ServiceTopology extends AbstractTopology {
public
void
execute
(
ActionEvent
e
)
{
public
void
execute
(
ActionEvent
e
)
{
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
String
serviceId
=
(
String
)
group
.
getUserObject
();
String
serviceId
=
(
String
)
group
.
getUserObject
();
String
result
=
ServiceController
.
configClear
(
serviceId
);
List
<
ResultEntity
>
results
=
ServiceController
.
configClear
(
serviceId
);
showResult
(
results
);
System
.
out
.
println
(
result
);
refreshGrayState
(
group
);
refreshGrayState
(
group
);
}
else
if
(
node
!=
null
)
{
}
else
if
(
node
!=
null
)
{
InstanceEntity
instance
=
(
InstanceEntity
)
node
.
getUserObject
();
InstanceEntity
instance
=
(
InstanceEntity
)
node
.
getUserObject
();
...
...
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