Skip to content

Commit cf02910

Browse files
author
karl
committed
流量防护demo
1 parent 99a2088 commit cf02910

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

mse-simple-demo/B/src/main/java/com/alibabacloud/mse/demo/BController.java

+2
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ private void init() {
6969
public String flow(HttpServletRequest request) throws ExecutionException, InterruptedException {
7070
long sleepTime = 5 + RANDOM.nextInt(5);
7171
silentSleep(sleepTime);
72+
7273
return "B" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " -> " + sleepTime;
7374
}
7475

7576
@GetMapping("/params/{hot}")
7677
public String params(HttpServletRequest request,@PathVariable("hot") String hot) throws ExecutionException, InterruptedException {
7778
long sleepTime = 5 + RANDOM.nextInt(5);
7879
silentSleep(sleepTime);
80+
helloServiceC.hello(hot);
7981
return "B" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " -> " + sleepTime+":"+hot;
8082
}
8183

mse-simple-demo/gateway/src/main/java/com/alibabacloud/mse/demo/DemoController.java

+42-42
Original file line numberDiff line numberDiff line change
@@ -197,48 +197,48 @@ public void run() {
197197
} catch (Exception ignore) {
198198
}
199199

200-
201-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
202-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/flow-c");
203-
httpClient.execute(httpGet);
204-
205-
} catch (Exception ignore) {
206-
}
207-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
208-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/flow-c");
209-
httpGet.addHeader("x-mse-tag", "gray");
210-
httpClient.execute(httpGet);
211-
212-
} catch (Exception ignore) {
213-
}
214-
215-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
216-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/isolate-c");
217-
httpClient.execute(httpGet);
218-
219-
} catch (Exception ignore) {
220-
}
221-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
222-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/isolate-c");
223-
httpGet.addHeader("x-mse-tag", "gray");
224-
httpClient.execute(httpGet);
225-
226-
} catch (Exception ignore) {
227-
}
228-
229-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
230-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/params-c/hot");
231-
httpClient.execute(httpGet);
232-
233-
} catch (Exception ignore) {
234-
}
235-
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
236-
HttpGet httpGet = new HttpGet("http://localhost:20000/B/params-c/hot");
237-
httpGet.addHeader("x-mse-tag", "gray");
238-
httpClient.execute(httpGet);
239-
240-
} catch (Exception ignore) {
241-
}
200+
//
201+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
202+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/flow-c");
203+
// httpClient.execute(httpGet);
204+
//
205+
// } catch (Exception ignore) {
206+
// }
207+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
208+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/flow-c");
209+
// httpGet.addHeader("x-mse-tag", "gray");
210+
// httpClient.execute(httpGet);
211+
//
212+
// } catch (Exception ignore) {
213+
// }
214+
//
215+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
216+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/isolate-c");
217+
// httpClient.execute(httpGet);
218+
//
219+
// } catch (Exception ignore) {
220+
// }
221+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
222+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/isolate-c");
223+
// httpGet.addHeader("x-mse-tag", "gray");
224+
// httpClient.execute(httpGet);
225+
//
226+
// } catch (Exception ignore) {
227+
// }
228+
//
229+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
230+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/params-c/hot");
231+
// httpClient.execute(httpGet);
232+
//
233+
// } catch (Exception ignore) {
234+
// }
235+
// try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
236+
// HttpGet httpGet = new HttpGet("http://localhost:20000/B/params-c/hot");
237+
// httpGet.addHeader("x-mse-tag", "gray");
238+
// httpClient.execute(httpGet);
239+
//
240+
// } catch (Exception ignore) {
241+
// }
242242

243243

244244
}

0 commit comments

Comments
 (0)