|
|
|
@ -60,6 +60,8 @@ public class ProviderController {
|
|
|
|
|
|
|
|
|
|
private boolean ifBadGateway = false;
|
|
|
|
|
|
|
|
|
|
private int delay = 1000;
|
|
|
|
|
|
|
|
|
|
// 获取本机ip
|
|
|
|
|
public static String getInet4Address() {
|
|
|
|
|
Enumeration<NetworkInterface> nis;
|
|
|
|
@ -91,6 +93,14 @@ public class ProviderController {
|
|
|
|
|
return echoHello;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/setDelay", method = RequestMethod.GET)
|
|
|
|
|
public String setSleepTime(@RequestParam("delay") int delay) {
|
|
|
|
|
this.delay = delay;
|
|
|
|
|
String result = "set delay time success, delay: " + delay;
|
|
|
|
|
LOG.info(result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/echo/{param}", method = RequestMethod.GET)
|
|
|
|
|
public ResponseEntity<String> echo(@PathVariable String param) {
|
|
|
|
|
if (ifBadGateway) {
|
|
|
|
@ -143,7 +153,7 @@ public class ProviderController {
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = "/echo/slow/{param}", method = RequestMethod.GET)
|
|
|
|
|
public String echoSlow(@PathVariable String param, @RequestParam(required = false) Integer delay) throws InterruptedException {
|
|
|
|
|
int sleepTime = delay == null ? 1000 : delay;
|
|
|
|
|
int sleepTime = delay == null ? this.delay : delay;
|
|
|
|
|
LOG.info("slow request param: [" + param + "], Start sleep: [" + sleepTime + "]ms");
|
|
|
|
|
Thread.sleep(sleepTime);
|
|
|
|
|
LOG.info("slow request param: [" + param + "], End sleep: [" + sleepTime + "]ms");
|
|
|
|
|