Преглед на файлове

Improve demo for Sentinel cluster flow control

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao преди 5 години
родител
ревизия
59c721691b
променени са 2 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. +2
    -0
      sentinel-demo/sentinel-demo-cluster/sentinel-demo-cluster-embedded/src/main/java/com/alibaba/csp/sentinel/demo/cluster/init/DemoClusterInitFunc.java
  2. +5
    -0
      sentinel-demo/sentinel-demo-cluster/sentinel-demo-cluster-server-alone/pom.xml

+ 2
- 0
sentinel-demo/sentinel-demo-cluster/sentinel-demo-cluster-embedded/src/main/java/com/alibaba/csp/sentinel/demo/cluster/init/DemoClusterInitFunc.java Целия файл

@@ -16,6 +16,7 @@
package com.alibaba.csp.sentinel.demo.cluster.init;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

import com.alibaba.csp.sentinel.cluster.ClusterStateManager;
@@ -157,6 +158,7 @@ public class DemoClusterInitFunc implements InitFunc {
// Otherwise it's unassigned, should be set to NOT_STARTED.
boolean canBeClient = groupList.stream()
.flatMap(e -> e.getClientSet().stream())
.filter(Objects::nonNull)
.anyMatch(e -> e.equals(getCurrentMachineId()));
return canBeClient ? ClusterStateManager.CLUSTER_CLIENT : ClusterStateManager.CLUSTER_NOT_STARTED;
}


+ 5
- 0
sentinel-demo/sentinel-demo-cluster/sentinel-demo-cluster-server-alone/pom.xml Целия файл

@@ -35,5 +35,10 @@
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</project>

Loading…
Отказ
Запис