File tree Expand file tree Collapse file tree 7 files changed +81
-21
lines changed
other/openshift/message-board
account-service/src/main/java/org/hibernate/demo/message/account/core/service
message-board-web/src/app
message-service/src/main/java/org/hibernate/demo/message/post/core/service Expand file tree Collapse file tree 7 files changed +81
-21
lines changed Original file line number Diff line number Diff line change
1
+ package org .hibernate .demo .message .account .core .service ;
2
+
3
+ import java .util .List ;
4
+ import javax .ejb .Stateless ;
5
+ import javax .inject .Inject ;
6
+ import javax .ws .rs .GET ;
7
+ import javax .ws .rs .Path ;
8
+ import javax .ws .rs .Produces ;
9
+ import javax .ws .rs .core .MediaType ;
10
+
11
+ import org .hibernate .demo .message .account .core .entity .User ;
12
+ import org .hibernate .demo .message .account .core .repo .UserRepo ;
13
+
14
+ import org .slf4j .Logger ;
15
+
16
+ @ Path ("/health" )
17
+ @ Stateless
18
+ public class HealthCheck {
19
+
20
+ @ Inject
21
+ private Logger log ;
22
+
23
+ @ Inject
24
+ private UserRepo repo ;
25
+
26
+ @ GET
27
+ @ Produces (MediaType .APPLICATION_JSON )
28
+ public List <User > healthCheck () {
29
+ log .info ( "healthCheck invoked by OCP" );
30
+
31
+ return repo .findAll ();
32
+ }
33
+
34
+ }
Original file line number Diff line number Diff line change 13
13
import javax .ws .rs .GET ;
14
14
import javax .ws .rs .POST ;
15
15
import javax .ws .rs .Path ;
16
- import javax .ws .rs .PathParam ;
17
16
import javax .ws .rs .Produces ;
17
+ import javax .ws .rs .QueryParam ;
18
18
import javax .ws .rs .core .MediaType ;
19
19
20
20
import org .hibernate .demo .message .account .core .entity .User ;
@@ -37,9 +37,8 @@ public List<User> findAllUsers() {
37
37
}
38
38
39
39
@ GET
40
- @ Path ( "{username}" )
41
40
@ Produces (MediaType .APPLICATION_JSON )
42
- public User findByUsername (@ PathParam ("username" ) String username ) {
41
+ public User findByUsername (@ QueryParam ("username" ) String username ) {
43
42
return repo .findByUserName ( username );
44
43
}
45
44
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export class LoginService {
22
22
}
23
23
24
24
login ( userName : String ) : Observable < User > {
25
- const url = `http://web-message-board.192.168.42.57.nip.io//users/ ?username=${ userName } ` ;
25
+ const url = `account-service/user ?username=${ userName } ` ;
26
26
console . log ( url ) ;
27
27
return this . http . get < User > ( url ) . map (
28
28
user => {
Original file line number Diff line number Diff line change 5
5
< a *ngFor ="let user of users "
6
6
routerLink ="/message/{{user.userName}} " (click) ="onSelect(user) "
7
7
[class.text-danger] ="user.userName === userName "
8
- [class.text-info] ="user.userName != userName "> < span
9
- class ="badge " [class.badge-danger] ="user.userName === userName "
10
- [class.badge-info] ="user.userName != userName "> {{ user.id }}</ span >
11
- {{ user.userName }}
8
+ [class.text-info] ="user.userName != userName ">
9
+ < div >
10
+ < span class ="badge " [class.badge-danger] ="user.userName === userName " [class.badge-info] ="user.userName != userName "> {{ user.id }}</ span >
11
+ {{ user.userName }}
12
+ </ div >
12
13
</ a >
13
14
</ div >
14
15
</ div >
Original file line number Diff line number Diff line change
1
+ package org .hibernate .demo .message .post .core .service ;
2
+
3
+ import java .util .List ;
4
+ import javax .ejb .Stateless ;
5
+ import javax .inject .Inject ;
6
+ import javax .ws .rs .GET ;
7
+ import javax .ws .rs .Path ;
8
+ import javax .ws .rs .Produces ;
9
+ import javax .ws .rs .core .MediaType ;
10
+
11
+ import org .hibernate .demo .message .post .core .entity .Message ;
12
+
13
+ import org .slf4j .Logger ;
14
+
15
+ @ Path ("/health" )
16
+ @ Stateless
17
+ public class HealthCheck {
18
+
19
+ @ Inject
20
+ private Logger log ;
21
+
22
+ @ Inject
23
+ private MessageService service ;
24
+
25
+ @ GET
26
+ @ Produces (MediaType .APPLICATION_JSON )
27
+ public List <Message > healthCheck () {
28
+ log .info ( "healthCheck invoked by OCP" );
29
+
30
+ return service .findMessagesByUser ( "andrea" );
31
+ }
32
+
33
+ }
Original file line number Diff line number Diff line change @@ -40,13 +40,6 @@ public class MessageService {
40
40
@ Inject
41
41
private Logger log ;
42
42
43
- @ GET
44
- @ Path ( "{username}" )
45
- @ Produces ( MediaType .APPLICATION_JSON )
46
- public List <Message > findMessagesUser ( @ PathParam ( "username" ) String username ) {
47
- return findMessagesByUser ( username );
48
- }
49
-
50
43
@ GET
51
44
@ Produces ( MediaType .APPLICATION_JSON )
52
45
public List <Message > findMessagesByUser ( @ QueryParam ( "username" ) String username ) {
Original file line number Diff line number Diff line change @@ -34,13 +34,13 @@ oc new-app --image-stream=eap71-openshift:latest~./nocontent -e OPENSHIFT_KUBE_P
34
34
oc start-build message-service --from-dir=./message-service --follow
35
35
36
36
# Setting liveness probes
37
- oc set probe dc/account-service --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/account-service/user
38
- oc set probe dc/message-service --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/message-service/messages/fabio
39
- oc set probe dc/message-board-web --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/
37
+ oc set probe dc/account-service --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/account-service/health
38
+ oc set probe dc/message-service --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/message-service/health
39
+ # oc set probe dc/message-board-web --liveness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/
40
40
41
41
# Setting readiness probes
42
- oc set probe dc/account-service --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/account-service/user
43
- oc set probe dc/message-service --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/message-service/messages/fabio
44
- oc set probe dc/message-board-web --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/
42
+ oc set probe dc/account-service --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/account-service/health
43
+ oc set probe dc/message-service --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/message-service/health
44
+ # oc set probe dc/message-board-web --readiness --failure-threshold 3 --initial-delay-seconds 30 --get-url=http://:8080/
45
45
46
46
oc get pods -w
You can’t perform that action at this time.
0 commit comments