diff --git a/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java b/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java index 30df9f67..072255d8 100644 --- a/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java +++ b/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java @@ -105,4 +105,10 @@ public class QuickstartCalleeController { LOG.info("Quickstart Callee Service [{}:{}] is called right.", ip, port); return String.format("Quickstart Callee Service [%s:%s] is called right.", ip, port); } + + @GetMapping("/faultDetect") + public String health() { + LOG.info("Quickstart Callee Service [{}:{}] is detected right.", ip, port); + return String.format("Quickstart Callee Service [%s:%s] is detected right.", ip, port); + } } diff --git a/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java b/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java index 9d97dfd8..d4de94f3 100644 --- a/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java +++ b/spring-cloud-tencent-examples/quickstart-example/quickstart-callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java @@ -107,34 +107,56 @@ public class QuickstartCalleeController { @GetMapping("/circuitBreak") public ResponseEntity circuitBreak() throws InterruptedException { if (ifBadGateway) { + LOG.info("Quickstart Callee Service [{}:{}] is called wrong.", ip, port); return new ResponseEntity<>("failed for call quickstart callee service.", HttpStatus.BAD_GATEWAY); } if (ifDelay) { - Thread.sleep(100); + Thread.sleep(200); + LOG.info("Quickstart Callee Service [{}:{}] is called slow.", ip, port); + return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is called slow.", ip, port), HttpStatus.OK); } - LOG.info("Quickstart Callee Service [{}:{}] is called wrong.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is called wrong.", ip, port), HttpStatus.OK); + LOG.info("Quickstart Callee Service [{}:{}] is called right.", ip, port); + return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is called right.", ip, port), HttpStatus.OK); } @GetMapping("/setBadGateway") - public void setBadGateway(@RequestParam boolean param) { + public String setBadGateway(@RequestParam boolean param) { + this.ifBadGateway = param; if (param) { LOG.info("info is set to return HttpStatus.BAD_GATEWAY."); + return "info is set to return HttpStatus.BAD_GATEWAY."; } else { LOG.info("info is set to return HttpStatus.OK."); + return "info is set to return HttpStatus.OK."; } - this.ifBadGateway = param; } @GetMapping("/setDelay") - public void setDelay(@RequestParam boolean param) { + public String setDelay(@RequestParam boolean param) { + this.ifDelay = param; if (param) { - LOG.info("info is set to delay 100ms."); + LOG.info("info is set to delay 200ms."); + return "info is set to delay 200ms."; } else { LOG.info("info is set to no delay."); + return "info is set to no delay."; } - this.ifDelay = param; + } + + @GetMapping("/faultDetect") + public ResponseEntity health() throws InterruptedException { + if (ifBadGateway) { + LOG.info("Quickstart Callee Service [{}:{}] is detected wrong.", ip, port); + return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected wrong.", ip, port), HttpStatus.BAD_GATEWAY); + } + if (ifDelay) { + Thread.sleep(200); + LOG.info("Quickstart Callee Service [{}:{}] is detected slow.", ip, port); + return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected slow.", ip, port), HttpStatus.OK); + } + LOG.info("Quickstart Callee Service [{}:{}] is detected right.", ip, port); + return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected right.", ip, port), HttpStatus.OK); } }