Skip to content

Commit

Permalink
fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
robberphex committed Dec 25, 2023
1 parent 6a4efa8 commit c447046
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
12 changes: 6 additions & 6 deletions mse-simple-demo/C/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@
<version>1.4.199</version>
</dependency>

<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>spring-boot-starter-ahas-sentinel-client</artifactId>
<version>1.10.11</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>

<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
<version>1.8.6</version>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.alibabacloud.mse.demo.c;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
Expand All @@ -21,6 +26,7 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;

@Slf4j
@RestController
class CController {

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

@GetMapping("/flow")
public String flow(HttpServletRequest request) throws ExecutionException, InterruptedException {
long sleepTime = 5 + RANDOM.nextInt(5);
silentSleep(sleepTime);
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
try (Entry entry1 = SphU.entry("HelloWorld-c-flow-1", EntryType.IN)) {
log.debug("Hello Sentinel!1");
try (Entry entry2 = SphU.entry("H\"elloWorld-c-flow-2", EntryType.IN)) {
log.debug("Hello Sentinel!2");
long sleepTime = 5 + RANDOM.nextInt(5);
silentSleep(sleepTime);
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
} catch (BlockException e) {
throw new RuntimeException(e);
}
} catch (BlockException e) {
throw new RuntimeException(e);
}
}

@GetMapping("/params/{hot}")
Expand Down

0 comments on commit c447046

Please sign in to comment.