Skip to content

Commit c447046

Browse files
committed
fix compile error
1 parent 6a4efa8 commit c447046

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

mse-simple-demo/C/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@
9696
<version>1.4.199</version>
9797
</dependency>
9898

99-
<dependency>
100-
<groupId>com.alibaba.csp</groupId>
101-
<artifactId>spring-boot-starter-ahas-sentinel-client</artifactId>
102-
<version>1.10.11</version>
103-
</dependency>
104-
10599
<dependency>
106100
<groupId>mysql</groupId>
107101
<artifactId>mysql-connector-java</artifactId>
108102
<version>8.0.31</version>
109103
</dependency>
104+
105+
<dependency>
106+
<groupId>com.alibaba.csp</groupId>
107+
<artifactId>sentinel-core</artifactId>
108+
<version>1.8.6</version>
109+
</dependency>
110110
</dependencies>
111111

112112
<dependencyManagement>

mse-simple-demo/C/src/main/java/com/alibabacloud/mse/demo/c/CController.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.alibabacloud.mse.demo.c;
22

3+
import com.alibaba.csp.sentinel.Entry;
4+
import com.alibaba.csp.sentinel.EntryType;
5+
import com.alibaba.csp.sentinel.SphU;
6+
import com.alibaba.csp.sentinel.slots.block.BlockException;
7+
import lombok.extern.slf4j.Slf4j;
38
import org.apache.http.HttpResponse;
49
import org.apache.http.client.HttpClient;
510
import org.apache.http.client.config.RequestConfig;
@@ -21,6 +26,7 @@
2126
import java.util.concurrent.ThreadLocalRandom;
2227
import java.util.concurrent.TimeUnit;
2328

29+
@Slf4j
2430
@RestController
2531
class CController {
2632

@@ -90,9 +96,19 @@ public String spring_boot(HttpServletRequest request) {
9096

9197
@GetMapping("/flow")
9298
public String flow(HttpServletRequest request) throws ExecutionException, InterruptedException {
93-
long sleepTime = 5 + RANDOM.nextInt(5);
94-
silentSleep(sleepTime);
95-
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
99+
try (Entry entry1 = SphU.entry("HelloWorld-c-flow-1", EntryType.IN)) {
100+
log.debug("Hello Sentinel!1");
101+
try (Entry entry2 = SphU.entry("H\"elloWorld-c-flow-2", EntryType.IN)) {
102+
log.debug("Hello Sentinel!2");
103+
long sleepTime = 5 + RANDOM.nextInt(5);
104+
silentSleep(sleepTime);
105+
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
106+
} catch (BlockException e) {
107+
throw new RuntimeException(e);
108+
}
109+
} catch (BlockException e) {
110+
throw new RuntimeException(e);
111+
}
96112
}
97113

98114
@GetMapping("/params/{hot}")

0 commit comments

Comments
 (0)