Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-boot-admin
Commits
1d8d7ccc
Commit
1d8d7ccc
authored
Dec 27, 2016
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve hover status info for down/offline apps
parent
14d8c01b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
22 deletions
+56
-22
statusInfo.tpl.html
...er-ui/modules/applications/components/statusInfo.tpl.html
+3
-2
StatusInfo.java
...main/java/de/codecentric/boot/admin/model/StatusInfo.java
+2
-2
StatusUpdater.java
...ava/de/codecentric/boot/admin/registry/StatusUpdater.java
+21
-13
StatusUpdaterTest.java
...de/codecentric/boot/admin/registry/StatusUpdaterTest.java
+30
-5
No files found.
spring-boot-admin-server-ui/modules/applications/components/statusInfo.tpl.html
View file @
1d8d7ccc
...
...
@@ -4,10 +4,11 @@
<table
class=
"table cable-condensed"
>
<tr
ng-repeat=
"detail in $ctrl.details | orderBy:'name'"
>
<td
style=
"text-transform: capitalize;"
ng-bind=
"detail.name"
></td>
<td
ng-bind=
"detail.status
"
class=
"status-{{detail.status}}"
></td>
<td
ng-bind=
"detail.status"
class=
"status-{{detail.status}}"
></td>
</tr>
</table>
<div
style=
"max-width: 400px;"
class=
"alert alert-error"
ng-if=
"$ctrl.statusInfo.details.message"
>
<div
style=
"max-width: 400px;"
class=
"alert alert-error"
ng-if=
"$ctrl.statusInfo.details.message || $ctrl.statusInfo.details.error"
>
<b
style=
"word-break: break-all;"
ng-if=
"$ctrl.statusInfo.details.status"
ng-bind=
"$ctrl.statusInfo.details.status + ' ' + $ctrl.statusInfo.details.error"
></b>
<b
style=
"word-break: break-all;"
ng-if=
"$ctrl.statusInfo.details.exception"
ng-bind=
"$ctrl.statusInfo.details.exception + ':'"
></b><br>
<span
ng-bind=
"$ctrl.statusInfo.details.message"
></span>
</div>
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/model/StatusInfo.java
View file @
1d8d7ccc
...
...
@@ -32,7 +32,7 @@ public class StatusInfo implements Serializable {
private
final
String
status
;
private
final
long
timestamp
;
private
final
Map
<
String
,
?
extends
Serializable
>
details
;
private
final
Map
<
String
,
Serializable
>
details
;
protected
StatusInfo
(
String
status
,
long
timestamp
,
Map
<
String
,
?
extends
Serializable
>
details
)
{
...
...
@@ -87,7 +87,7 @@ public class StatusInfo implements Serializable {
return
timestamp
;
}
public
Map
<
String
,
?
extends
Serializable
>
getDetails
()
{
public
Map
<
String
,
Serializable
>
getDetails
()
{
return
details
;
}
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/StatusUpdater.java
View file @
1d8d7ccc
...
...
@@ -100,31 +100,39 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
protected
StatusInfo
queryStatus
(
Application
application
)
{
LOGGER
.
trace
(
"Updating status for {}"
,
application
);
try
{
ResponseEntity
<
Map
<
String
,
Serializable
>>
response
=
applicationOps
.
getHealth
(
application
);
if
(
response
.
hasBody
()
&&
response
.
getBody
().
get
(
"status"
)
instanceof
String
)
{
return
StatusInfo
.
valueOf
((
String
)
response
.
getBody
().
get
(
"status"
),
response
.
getBody
());
}
else
if
(
response
.
getStatusCode
().
is2xxSuccessful
())
{
return
StatusInfo
.
ofUp
();
}
else
{
return
StatusInfo
.
ofDown
();
}
return
convertStatusInfo
(
applicationOps
.
getHealth
(
application
));
}
catch
(
Exception
ex
)
{
if
(
"OFFLINE"
.
equals
(
application
.
getStatusInfo
().
getStatus
()))
{
LOGGER
.
debug
(
"Couldn't retrieve status for {}"
,
application
,
ex
);
}
else
{
LOGGER
.
info
(
"Couldn't retrieve status for {}"
,
application
,
ex
);
}
return
StatusInfo
.
ofOffline
(
toDetails
(
ex
));
return
convertStatusInfo
(
ex
);
}
}
private
StatusInfo
convertStatusInfo
(
ResponseEntity
<
Map
<
String
,
Serializable
>>
response
)
{
if
(
response
.
hasBody
()
&&
response
.
getBody
().
get
(
"status"
)
instanceof
String
)
{
return
StatusInfo
.
valueOf
((
String
)
response
.
getBody
().
get
(
"status"
),
response
.
getBody
());
}
if
(
response
.
getStatusCode
().
is2xxSuccessful
())
{
return
StatusInfo
.
ofUp
();
}
Map
<
String
,
Serializable
>
details
=
new
HashMap
<>();
details
.
put
(
"status"
,
response
.
getStatusCodeValue
());
details
.
put
(
"error"
,
response
.
getStatusCode
().
getReasonPhrase
());
if
(
response
.
hasBody
())
{
details
.
putAll
(
response
.
getBody
());
}
return
StatusInfo
.
ofDown
(
details
);
}
pr
otected
Map
<
String
,
Serializable
>
toDetails
(
Exception
ex
)
{
pr
ivate
StatusInfo
convertStatusInfo
(
Exception
ex
)
{
Map
<
String
,
Serializable
>
details
=
new
HashMap
<>();
details
.
put
(
"message"
,
ex
.
getMessage
());
details
.
put
(
"exception"
,
ex
.
getClass
().
getName
());
return
details
;
return
StatusInfo
.
ofOffline
(
details
)
;
}
public
void
setStatusLifetime
(
long
statusLifetime
)
{
...
...
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/registry/StatusUpdaterTest.java
View file @
1d8d7ccc
...
...
@@ -92,8 +92,7 @@ public class StatusUpdaterTest {
}
@Test
public
void
test_update_noBody
()
{
// HTTP 200 - UP
public
void
test_update_up_noBody
()
{
when
(
applicationOps
.
getHealth
(
any
(
Application
.
class
)))
.
thenReturn
(
ResponseEntity
.
ok
((
Map
<
String
,
Serializable
>)
null
));
...
...
@@ -102,14 +101,36 @@ public class StatusUpdaterTest {
assertThat
(
store
.
find
(
"id"
).
getStatusInfo
().
getStatus
(),
CoreMatchers
.
is
(
"UP"
));
// HTTP != 200 - DOWN
}
@Test
public
void
test_update_down
()
{
when
(
applicationOps
.
getHealth
(
any
(
Application
.
class
)))
.
thenReturn
(
ResponseEntity
.
status
(
503
).
body
(
Collections
.<
String
,
Serializable
>
singletonMap
(
"foo"
,
"bar"
)));
updater
.
updateStatus
(
Application
.
create
(
"foo"
).
withId
(
"id"
).
withHealthUrl
(
"health"
).
build
());
StatusInfo
statusInfo
=
store
.
find
(
"id"
).
getStatusInfo
();
assertThat
(
statusInfo
.
getStatus
(),
CoreMatchers
.
is
(
"DOWN"
));
assertThat
(
statusInfo
.
getDetails
(),
hasEntry
(
"foo"
,
(
Serializable
)
"bar"
));
}
@Test
public
void
test_update_down_noBody
()
{
when
(
applicationOps
.
getHealth
(
any
(
Application
.
class
)))
.
thenReturn
(
ResponseEntity
.
status
(
503
).
body
((
Map
<
String
,
Serializable
>)
null
));
updater
.
updateStatus
(
Application
.
create
(
"foo"
).
withId
(
"id"
).
withHealthUrl
(
"health"
).
build
());
assertThat
(
store
.
find
(
"id"
).
getStatusInfo
().
getStatus
(),
CoreMatchers
.
is
(
"DOWN"
));
StatusInfo
statusInfo
=
store
.
find
(
"id"
).
getStatusInfo
();
assertThat
(
statusInfo
.
getStatus
(),
CoreMatchers
.
is
(
"DOWN"
));
assertThat
(
statusInfo
.
getDetails
(),
hasEntry
(
"status"
,
(
Serializable
)
503
));
assertThat
(
statusInfo
.
getDetails
(),
hasEntry
(
"error"
,
(
Serializable
)
"Service Unavailable"
));
}
@Test
...
...
@@ -121,7 +142,11 @@ public class StatusUpdaterTest {
.
withStatusInfo
(
StatusInfo
.
ofUp
()).
build
();
updater
.
updateStatus
(
app
);
assertThat
(
store
.
find
(
"id"
).
getStatusInfo
().
getStatus
(),
CoreMatchers
.
is
(
"OFFLINE"
));
StatusInfo
statusInfo
=
store
.
find
(
"id"
).
getStatusInfo
();
assertThat
(
statusInfo
.
getStatus
(),
CoreMatchers
.
is
(
"OFFLINE"
));
assertThat
(
statusInfo
.
getDetails
(),
hasEntry
(
"message"
,
(
Serializable
)
"error"
));
assertThat
(
statusInfo
.
getDetails
(),
hasEntry
(
"exception"
,
(
Serializable
)
"org.springframework.web.client.ResourceAccessException"
));
}
@Test
...
...
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