Commit 9dccd96190401b4dcf80af2b68881222b25b628b

Authored by alexyang
1 parent 1b31e29f

删除无用代码

Showing 67 changed files with 90 additions and 4501 deletions

Too many changes to show.

To preserve performance only 67 of 1499 files are displayed.

.idea/compiler.xml
... ... @@ -12,118 +12,47 @@
12 12 <module name="sl-express-ms-track-domain" />
13 13 <module name="sl-express-ms-transport-api" />
14 14 <module name="sl-express-ms-driver-service" />
15   - <module name="sentinel-okhttp-adapter" />
16   - <module name="sentinel-apache-dubbo-adapter" />
17   - <module name="sentinel-transport-spring-mvc" />
18 15 <module name="sl-express-xxl-job" />
19   - <module name="sentinel-demo-transport-spring-mvc" />
20   - <module name="sentinel-demo-basic" />
21 16 <module name="sl-express-ms-track-api" />
22   - <module name="sentinel-datasource-eureka" />
23 17 <module name="sl-express-ms-web-courier" />
24 18 <module name="sl-express-pay" />
25   - <module name="sentinel-demo-motan" />
26   - <module name="sentinel-datasource-zookeeper" />
27 19 <module name="sl-express-ms-user-service" />
28 20 <module name="sl-express-ms-oms-service" />
29   - <module name="sentinel-spring-webflux-adapter" />
30 21 <module name="sl-express-ms-oms-api" />
31 22 <module name="sl-express-ms-trade-domain" />
32   - <module name="sentinel-datasource-extension" />
33   - <module name="sentinel-datasource-etcd" />
34 23 <module name="sl-express-ms-trade-service" />
35 24 <module name="sl-express-ms-sms-domain" />
36   - <module name="sentinel-sofa-rpc-adapter" />
37   - <module name="sentinel-annotation-cdi-interceptor" />
38   - <module name="sentinel-datasource-apollo" />
39 25 <module name="sl-express-ms-web-customer" />
40   - <module name="sentinel-transport-simple-http" />
41   - <module name="sentinel-demo-zookeeper-datasource" />
42 26 <module name="sl-express-ms-transport-info-api" />
43 27 <module name="sl-express-ms-transport-info-service" />
44   - <module name="sentinel-spring-cloud-gateway-adapter" />
45 28 <module name="sl-express-ms-trade-api" />
46   - <module name="sentinel-dubbo-adapter" />
47   - <module name="sentinel-datasource-consul" />
48   - <module name="sentinel-apache-httpclient-adapter" />
49   - <module name="sentinel-zuul2-adapter" />
50 29 <module name="sl-express-gateway" />
51 30 <module name="sl-express-ms-base-service" />
52   - <module name="sentinel-demo-spring-cloud-gateway" />
53   - <module name="sentinel-metric-exporter" />
54 31 <module name="sl-express-ms-courier-api" />
55   - <module name="sentinel-demo-cluster-server-alone" />
56   - <module name="sentinel-logging-slf4j" />
57 32 <module name="sl-express-ms-search-domain" />
58 33 <module name="sl-express-ms-track-service" />
59 34 <module name="sl-express-ms-driver-api" />
60   - <module name="sentinel-demo-rocketmq" />
61 35 <module name="sl-express-ms-sms-api" />
62 36 <module name="sl-express-ms-search-service" />
63 37 <module name="sl-express-ms-service-scope-service" />
64   - <module name="sentinel-reactor-adapter" />
65   - <module name="sentinel-transport-netty-http" />
66 38 <module name="sl-express-ms-service-scope-domain" />
67   - <module name="sentinel-jax-rs-adapter" />
68   - <module name="sentinel-demo-apache-httpclient" />
69 39 <module name="sl-express-ms-carriage-domain" />
70 40 <module name="sl-express-ms-work-domain" />
71   - <module name="sentinel-annotation-aspectj" />
72 41 <module name="sl-express-ms-web-driver" />
73   - <module name="sentinel-cluster-server-default" />
74   - <module name="sentinel-demo-parameter-flow-control" />
75   - <module name="sentinel-parameter-flow-control" />
76 42 <module name="sl-express-ms-base-domain" />
77 43 <module name="sl-express-ms-courier-service" />
78   - <module name="sentinel-motan-adapter" />
79   - <module name="sentinel-zuul-adapter" />
80   - <module name="sentinel-demo-etcd-datasource" />
81 44 <module name="sl-express-common" />
82   - <module name="sentinel-web-servlet" />
83   - <module name="sentinel-datasource-nacos" />
84   - <module name="sentinel-demo-spring-webmvc" />
85   - <module name="sentinel-transport-common" />
86 45 <module name="sl-express-ms-user-api" />
87   - <module name="sentinel-benchmark" />
88   - <module name="sentinel-demo-quarkus" />
89 46 <module name="sl-express-ms-courier-domain" />
90 47 <module name="sl-express-ms-transport-info-domain" />
91   - <module name="sentinel-core" />
92   - <module name="sentinel-cluster-client-default" />
93 48 <module name="sl-express-ms-user-domain" />
94   - <module name="sentinel-demo-slotchain-spi" />
95   - <module name="sentinel-demo-log-logback" />
96 49 <module name="sl-express-ms-search-api" />
97   - <module name="sentinel-demo-zuul2-gateway" />
98   - <module name="sentinel-demo-annotation-spring-aop" />
99   - <module name="sentinel-demo-jax-rs" />
100   - <module name="sentinel-demo-apollo-datasource" />
101   - <module name="sentinel-datasource-spring-cloud-config" />
102   - <module name="sentinel-demo-apache-dubbo" />
103   - <module name="sentinel-demo-command-handler" />
104   - <module name="sentinel-demo-dynamic-file-rule" />
105 50 <module name="sl-express-ms-work-api" />
106 51 <module name="sl-express-ms-sms-service" />
107   - <module name="sentinel-demo-nacos-datasource" />
108   - <module name="sentinel-spring-webmvc-adapter" />
109   - <module name="sentinel-demo-okhttp" />
110   - <module name="sentinel-demo-slot-spi" />
111   - <module name="sentinel-dashboard" />
112 52 <module name="sl-express-ms-work-service" />
113   - <module name="sentinel-demo-annotation-cdi-interceptor" />
114   - <module name="sentinel-demo-sofa-rpc" />
115   - <module name="sentinel-cluster-server-envoy-rls" />
116   - <module name="sentinel-api-gateway-adapter-common" />
117   - <module name="sentinel-grpc-adapter" />
118   - <module name="sentinel-cluster-common-default" />
119   - <module name="sentinel-demo-dubbo" />
120   - <module name="sentinel-demo-cluster-embedded" />
121 53 <module name="sl-express-ms-transport-domain" />
122   - <module name="sentinel-demo-spring-webflux" />
123 54 <module name="sl-express-ms-service-scope-api" />
124 55 <module name="sl-express-mq" />
125   - <module name="sentinel-datasource-redis" />
126   - <module name="sentinel-demo-zuul-gateway" />
127 56 <module name="sl-express-ms-carriage-service" />
128 57 <module name="sl-express-ms-driver-domain" />
129 58 <module name="sl-express-ms-web-manager" />
... ... @@ -131,35 +60,95 @@
131 60 <module name="sl-express-ms-base-api" />
132 61 <module name="sl-express-ms-transport-service" />
133 62 </profile>
134   - <profile name="Annotation profile for sentinel-parent" enabled="true">
135   - <sourceOutputDir name="target/generated-sources/annotations" />
136   - <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
137   - <outputRelativeToContentRoot value="true" />
138   - <processorPath useClasspath="false">
139   - <entry name="$MAVEN_REPOSITORY$/io/quarkus/quarkus-extension-processor/1.4.1.Final/quarkus-extension-processor-1.4.1.Final.jar" />
140   - <entry name="$MAVEN_REPOSITORY$/org/jboss/jdeparser/jdeparser/2.0.2.Final/jdeparser-2.0.2.Final.jar" />
141   - <entry name="$MAVEN_REPOSITORY$/org/jsoup/jsoup/1.12.1/jsoup-1.12.1.jar" />
142   - <entry name="$MAVEN_REPOSITORY$/com/github/javaparser/javaparser-core/3.14.10/javaparser-core-3.14.10.jar" />
143   - <entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.10.3/jackson-databind-2.10.3.jar" />
144   - <entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.10.3/jackson-annotations-2.10.3.jar" />
145   - <entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.10.3/jackson-core-2.10.3.jar" />
146   - <entry name="$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.6.2/junit-jupiter-5.6.2.jar" />
147   - <entry name="$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.6.2/junit-jupiter-api-5.6.2.jar" />
148   - <entry name="$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar" />
149   - <entry name="$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar" />
150   - <entry name="$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2.jar" />
151   - <entry name="$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.6.2/junit-jupiter-params-5.6.2.jar" />
152   - <entry name="$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.6.2/junit-jupiter-engine-5.6.2.jar" />
153   - <entry name="$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.6.2/junit-platform-engine-1.6.2.jar" />
154   - </processorPath>
155   - <module name="sentinel-jax-rs-quarkus-adapter-deployment" />
156   - <module name="sentinel-annotation-quarkus-adapter" />
157   - <module name="sentinel-native-image-quarkus-adapter-deployment" />
158   - <module name="sentinel-annotation-quarkus-adapter-deployment" />
159   - <module name="sentinel-jax-rs-quarkus-adapter" />
160   - <module name="sentinel-native-image-quarkus-adapter" />
161   - </profile>
162 63 </annotationProcessing>
  64 + <bytecodeTargetLevel>
  65 + <module name="sentinel-adapter" target="1.8" />
  66 + <module name="sentinel-annotation-aspectj" target="1.8" />
  67 + <module name="sentinel-annotation-cdi-interceptor" target="1.8" />
  68 + <module name="sentinel-annotation-quarkus-adapter" target="1.8" />
  69 + <module name="sentinel-annotation-quarkus-adapter-deployment" target="1.8" />
  70 + <module name="sentinel-apache-dubbo-adapter" target="1.8" />
  71 + <module name="sentinel-apache-httpclient-adapter" target="1.8" />
  72 + <module name="sentinel-api-gateway-adapter-common" target="1.8" />
  73 + <module name="sentinel-benchmark" target="1.8" />
  74 + <module name="sentinel-cluster" target="1.8" />
  75 + <module name="sentinel-cluster-client-default" target="1.8" />
  76 + <module name="sentinel-cluster-common-default" target="1.8" />
  77 + <module name="sentinel-cluster-server-default" target="1.8" />
  78 + <module name="sentinel-cluster-server-envoy-rls" target="1.8" />
  79 + <module name="sentinel-core" target="1.8" />
  80 + <module name="sentinel-dashboard" target="1.8" />
  81 + <module name="sentinel-datasource-apollo" target="1.8" />
  82 + <module name="sentinel-datasource-consul" target="1.8" />
  83 + <module name="sentinel-datasource-etcd" target="1.8" />
  84 + <module name="sentinel-datasource-eureka" target="1.8" />
  85 + <module name="sentinel-datasource-extension" target="1.8" />
  86 + <module name="sentinel-datasource-nacos" target="1.8" />
  87 + <module name="sentinel-datasource-redis" target="1.8" />
  88 + <module name="sentinel-datasource-spring-cloud-config" target="1.8" />
  89 + <module name="sentinel-datasource-zookeeper" target="1.8" />
  90 + <module name="sentinel-demo" target="1.8" />
  91 + <module name="sentinel-demo-annotation-cdi-interceptor" target="1.8" />
  92 + <module name="sentinel-demo-annotation-spring-aop" target="1.8" />
  93 + <module name="sentinel-demo-apache-dubbo" target="1.8" />
  94 + <module name="sentinel-demo-apache-httpclient" target="1.8" />
  95 + <module name="sentinel-demo-apollo-datasource" target="1.8" />
  96 + <module name="sentinel-demo-basic" target="1.8" />
  97 + <module name="sentinel-demo-cluster" target="1.8" />
  98 + <module name="sentinel-demo-cluster-embedded" target="1.8" />
  99 + <module name="sentinel-demo-cluster-server-alone" target="1.8" />
  100 + <module name="sentinel-demo-command-handler" target="1.8" />
  101 + <module name="sentinel-demo-dubbo" target="1.8" />
  102 + <module name="sentinel-demo-dynamic-file-rule" target="1.8" />
  103 + <module name="sentinel-demo-etcd-datasource" target="1.8" />
  104 + <module name="sentinel-demo-jax-rs" target="1.8" />
  105 + <module name="sentinel-demo-log-logback" target="1.8" />
  106 + <module name="sentinel-demo-motan" target="1.8" />
  107 + <module name="sentinel-demo-nacos-datasource" target="1.8" />
  108 + <module name="sentinel-demo-okhttp" target="1.8" />
  109 + <module name="sentinel-demo-parameter-flow-control" target="1.8" />
  110 + <module name="sentinel-demo-quarkus" target="1.8" />
  111 + <module name="sentinel-demo-rocketmq" target="1.8" />
  112 + <module name="sentinel-demo-slot-spi" target="1.8" />
  113 + <module name="sentinel-demo-slotchain-spi" target="1.8" />
  114 + <module name="sentinel-demo-sofa-rpc" target="1.8" />
  115 + <module name="sentinel-demo-spring-cloud-gateway" target="1.8" />
  116 + <module name="sentinel-demo-spring-webflux" target="1.8" />
  117 + <module name="sentinel-demo-spring-webmvc" target="1.8" />
  118 + <module name="sentinel-demo-transport-spring-mvc" target="1.8" />
  119 + <module name="sentinel-demo-zookeeper-datasource" target="1.8" />
  120 + <module name="sentinel-demo-zuul-gateway" target="1.8" />
  121 + <module name="sentinel-demo-zuul2-gateway" target="1.8" />
  122 + <module name="sentinel-dubbo-adapter" target="1.8" />
  123 + <module name="sentinel-extension" target="1.8" />
  124 + <module name="sentinel-grpc-adapter" target="1.8" />
  125 + <module name="sentinel-jax-rs-adapter" target="1.8" />
  126 + <module name="sentinel-jax-rs-quarkus-adapter" target="1.8" />
  127 + <module name="sentinel-jax-rs-quarkus-adapter-deployment" target="1.8" />
  128 + <module name="sentinel-logging" target="1.8" />
  129 + <module name="sentinel-logging-slf4j" target="1.8" />
  130 + <module name="sentinel-metric-exporter" target="1.8" />
  131 + <module name="sentinel-motan-adapter" target="1.8" />
  132 + <module name="sentinel-native-image-quarkus-adapter" target="1.8" />
  133 + <module name="sentinel-native-image-quarkus-adapter-deployment" target="1.8" />
  134 + <module name="sentinel-okhttp-adapter" target="1.8" />
  135 + <module name="sentinel-parameter-flow-control" target="1.8" />
  136 + <module name="sentinel-parent" target="1.8" />
  137 + <module name="sentinel-quarkus-adapter-parent" target="1.8" />
  138 + <module name="sentinel-reactor-adapter" target="1.8" />
  139 + <module name="sentinel-sofa-rpc-adapter" target="1.8" />
  140 + <module name="sentinel-spring-cloud-gateway-adapter" target="1.8" />
  141 + <module name="sentinel-spring-webflux-adapter" target="1.8" />
  142 + <module name="sentinel-spring-webmvc-adapter" target="1.8" />
  143 + <module name="sentinel-transport" target="1.8" />
  144 + <module name="sentinel-transport-common" target="1.8" />
  145 + <module name="sentinel-transport-netty-http" target="1.8" />
  146 + <module name="sentinel-transport-simple-http" target="1.8" />
  147 + <module name="sentinel-transport-spring-mvc" target="1.8" />
  148 + <module name="sentinel-web-servlet" target="1.8" />
  149 + <module name="sentinel-zuul-adapter" target="1.8" />
  150 + <module name="sentinel-zuul2-adapter" target="1.8" />
  151 + </bytecodeTargetLevel>
163 152 </component>
164 153 <component name="JavacSettings">
165 154 <option name="ADDITIONAL_OPTIONS_OVERRIDE">
... ...
.idea/misc.xml
... ... @@ -58,10 +58,11 @@
58 58 <option value="$PROJECT_DIR$/sl-express-pay/pom.xml" />
59 59 <option value="$PROJECT_DIR$/sl-express-xxl-job/pom.xml" />
60 60 <option value="$PROJECT_DIR$/sentinel/pom.xml" />
  61 + <option value="$PROJECT_DIR$/pom.xml" />
61 62 </list>
62 63 </option>
63 64 </component>
64   - <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
  65 + <component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="azul-13" project-jdk-type="JavaSDK">
65 66 <output url="file://$PROJECT_DIR$/out" />
66 67 </component>
67 68 </project>
68 69 \ No newline at end of file
... ...
.idea/modules.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project version="4">
3   - <component name="ProjectModuleManager">
4   - <modules>
5   - <module fileurl="file://$PROJECT_DIR$/.idea/sl-express.iml" filepath="$PROJECT_DIR$/.idea/sl-express.iml" />
6   - </modules>
7   - </component>
8   -</project>
9 0 \ No newline at end of file
sentinel/.circleci/config.yml deleted 100644 → 0
1   -version: 2
2   -jobs:
3   - integration-test:
4   - docker:
5   - - image: circleci/openjdk:8-jdk
6   - working_directory: ~/sentinel
7   - environment:
8   - MAVEN_OPTS: -Xmx3200m
9   - steps:
10   - - checkout
11   - # Run tests
12   - - run: mvn integration-test
13   -
14   - document-lint:
15   - docker:
16   - # this image is build from Dockerfile
17   - # https://github.com/pouchcontainer/pouchlinter/blob/master/Dockerfile
18   - - image: pouchcontainer/pouchlinter:v0.1.2
19   - working_directory: ~/sentinel
20   - steps:
21   - - checkout
22   - - run:
23   - name: use markdownlint v0.5.0 to lint markdown file (https://github.com/markdownlint/markdownlint)
24   - command: |
25   - find ./ -name "*.md" | grep -v vendor | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036
26   -# - run:
27   -# name: use markdown-link-check(https://github.com/tcort/markdown-link-check) to check links in markdown files
28   -# command: |
29   -# set +e
30   -# for name in $(find . -name \*.md | grep -v vendor | grep -v CHANGELOG); do
31   -# if [ -f $name ]; then
32   -# markdown-link-check -q $name;
33   -# if [ $? -ne 0 ]; then
34   -# code=1
35   -# fi
36   -# fi
37   -# done
38   -# bash -c "exit $code";
39   -# - run:
40   -# name: use opensource tool client9/misspell to correct commonly misspelled English words
41   -# command: |
42   -# find ./* -name "*" | grep -v vendor | xargs misspell -error
43   -# - run:
44   -# name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo
45   -# command: |
46   -# find ./ -name "*.sh" | grep -v vendor | xargs shellcheck
47   -
48   -workflows:
49   - version: 2
50   - ci:
51   - jobs:
52   - - integration-test
53   - - document-lint
sentinel/.codecov.yml deleted 100644 → 0
1   -ignore:
2   - - "sentinel-demo/.*"
3   - - "sentinel-dashboard/.*"
4   - - "sentinel-benchmark/.*"
5   - - "sentinel-transport/.*"
6   - - "sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/base/LongAdder.java"
7   - - "sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/base/Striped64.java"
8   - - "sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/*"
9 0 \ No newline at end of file
sentinel/.github/ISSUE_TEMPLATE.md deleted 100644 → 0
1   -<!-- Here is for bug reports and feature requests ONLY!
2   -
3   -If you're looking for help, please check our mail list and the Gitter room.
4   -
5   -Please try to use English to describe your issue, or at least provide a snippet of English translation.
6   --->
7   -
8   -## Issue Description
9   -
10   -Type: *bug report* or *feature request*
11   -
12   -### Describe what happened (or what feature you want)
13   -
14   -
15   -### Describe what you expected to happen
16   -
17   -
18   -### How to reproduce it (as minimally and precisely as possible)
19   -
20   -1.
21   -2.
22   -3.
23   -
24   -### Tell us your environment
25   -
26   -
27   -### Anything else we need to know?
28   -
29   -
30   -
sentinel/.github/PULL_REQUEST_TEMPLATE.md deleted 100644 → 0
1   -<!-- Thanks for submitting a pull request! Here are some tips for you:
2   -1. Please make sure you have read and understood the contributing guidelines: https://github.com/alibaba/Sentinel/blob/master/CONTRIBUTING.md
3   -2. Please make sure the PR has a corresponding issue.
4   --->
5   -
6   -### Describe what this PR does / why we need it
7   -
8   -
9   -### Does this pull request fix one issue?
10   -
11   -<!--If that, add "Fixes #xxxx" below in the next line. For example, Fixes #15. Otherwise, add "NONE" -->
12   -
13   -### Describe how you did it
14   -
15   -
16   -### Describe how to verify it
17   -
18   -
19   -### Special notes for reviews
sentinel/.github/workflows/ci.yml deleted 100644 → 0
1   -name: Sentinel CI
2   -
3   -on:
4   - push:
5   - branches: [ master ]
6   - pull_request:
7   - branches: [ master ]
8   -
9   -jobs:
10   - build:
11   - runs-on: ubuntu-18.04
12   - strategy:
13   - matrix:
14   - java: [8, 11]
15   - steps:
16   - - name: Checkout
17   - uses: actions/checkout@v2
18   -
19   - - name: Setup Java
20   - uses: actions/setup-java@v1
21   - with:
22   - java-version: ${{ matrix.java }}
23   - architecture: x64
24   -
25   - - name: Test with Maven
26   - run: mvn test
27   -
28   - - name: Build with Maven
29   - run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -DminimumPriority=1
30   -
31   - - name: Run Codecov
32   - run: bash <(curl -s https://codecov.io/bash)
33 0 \ No newline at end of file
sentinel/.gitignore deleted 100644 → 0
1   -# IntelliJ project files
2   -.idea/
3   -*.iml
4   -out
5   -gen
6   -
7   -# Visual Studio Code
8   -.history/
9   -
10   -# Maven
11   -target/
12   -pom.xml.tag
13   -pom.xml.releaseBackup
14   -pom.xml.versionsBackup
15   -pom.xml.next
16   -release.properties
17   -dependency-reduced-pom.xml
18   -buildNumber.properties
19   -.mvn/timing.properties
20   -!/.mvn/wrapper/maven-wrapper.jar
21   -
22   -# Eclipse
23   -.classpath
24   -.settings/
25   -.project
26   -bin/
27   -
28   -# System related
29   -*.DS_Store
30   -Thumbs.db
sentinel/CODE_OF_CONDUCT.md deleted 100644 → 0
1   -# Contributor Covenant Code of Conduct
2   -
3   -## Our Pledge
4   -
5   -In the interest of fostering an open and welcoming environment, we as
6   -contributors and maintainers pledge to making participation in our project and
7   -our community a harassment-free experience for everyone, regardless of age, body
8   -size, disability, ethnicity, gender identity and expression, level of experience,
9   -education, socio-economic status, nationality, personal appearance, race,
10   -religion, or sexual identity and orientation.
11   -
12   -## Our Standards
13   -
14   -Examples of behavior that contributes to creating a positive environment
15   -include:
16   -
17   -* Using welcoming and inclusive language
18   -* Being respectful of differing viewpoints and experiences
19   -* Gracefully accepting constructive criticism
20   -* Focusing on what is best for the community
21   -* Showing empathy towards other community members
22   -
23   -Examples of unacceptable behavior by participants include:
24   -
25   -* The use of sexualized language or imagery and unwelcome sexual attention or
26   - advances
27   -* Trolling, insulting/derogatory comments, and personal or political attacks
28   -* Public or private harassment
29   -* Publishing others' private information, such as a physical or electronic
30   - address, without explicit permission
31   -* Other conduct which could reasonably be considered inappropriate in a
32   - professional setting
33   -
34   -## Our Responsibilities
35   -
36   -Project maintainers are responsible for clarifying the standards of acceptable
37   -behavior and are expected to take appropriate and fair corrective action in
38   -response to any instances of unacceptable behavior.
39   -
40   -Project maintainers have the right and responsibility to remove, edit, or
41   -reject comments, commits, code, wiki edits, issues, and other contributions
42   -that are not aligned to this Code of Conduct, or to ban temporarily or
43   -permanently any contributor for other behaviors that they deem inappropriate,
44   -threatening, offensive, or harmful.
45   -
46   -## Scope
47   -
48   -This Code of Conduct applies both within project spaces and in public spaces
49   -when an individual is representing the project or its community. Examples of
50   -representing a project or community include using an official project e-mail
51   -address, posting via an official social media account, or acting as an appointed
52   -representative at an online or offline event. Representation of a project may be
53   -further defined and clarified by project maintainers.
54   -
55   -## Enforcement
56   -
57   -Instances of abusive, harassing, or otherwise unacceptable behavior may be
58   -reported by contacting the project team at sentinel@linux.alibaba.com. All
59   -complaints will be reviewed and investigated and will result in a response that
60   -is deemed necessary and appropriate to the circumstances. The project team is
61   -obligated to maintain confidentiality with regard to the reporter of an incident.
62   -Further details of specific enforcement policies may be posted separately.
63   -
64   -Project maintainers who do not follow or enforce the Code of Conduct in good
65   -faith may face temporary or permanent repercussions as determined by other
66   -members of the project's leadership.
67   -
68   -## Attribution
69   -
70   -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71   -available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)
72   -
73   -[homepage]: https://www.contributor-covenant.org
sentinel/CONTRIBUTING.md deleted 100644 → 0
1   -# Contributing to Sentinel
2   -
3   -Welcome to Sentinel! This document is a guideline about how to contribute to Sentinel.
4   -If you find something incorrect or missing, please leave comments / suggestions.
5   -
6   -## Before you get started
7   -
8   -### Code of Conduct
9   -
10   -Please make sure to read and observe our [Code of Conduct](./CODE_OF_CONDUCT.md).
11   -
12   -### Setting up your development environment
13   -
14   -You should have JDK 1.8 or later installed in your system.
15   -
16   -## Contributing
17   -
18   -We are always very happy to have contributions, whether for typo fix, bug fix or big new features.
19   -Please do not ever hesitate to ask a question or send a pull request.
20   -
21   -We strongly value documentation and integration with other projects.
22   -We are very glad to accept improvements for these aspects.
23   -
24   -### GitHub workflow
25   -
26   -We use the `master` branch as the development branch, which indicates that this is a unstable branch.
27   -
28   -Here are the workflow for contributors:
29   -
30   -1. Fork to your own
31   -2. Clone fork to local repository
32   -3. Create a new branch and work on it
33   -4. Keep your branch in sync
34   -5. Commit your changes (make sure your commit message concise)
35   -6. Push your commits to your forked repository
36   -7. Create a pull request
37   -
38   -Please follow [the pull request template](./.github/PULL_REQUEST_TEMPLATE.md).
39   -Please make sure the PR has a corresponding issue.
40   -
41   -After creating a PR, one or more reviewers will be assigned to the pull request.
42   -The reviewers will review the code.
43   -
44   -Before merging a PR, squash any fix review feedback, typo, merged, and rebased sorts of commits.
45   -The final commit message should be clear and concise.
46   -
47   -### Open an issue / PR
48   -
49   -We use [GitHub Issues](https://github.com/alibaba/Sentinel/issues) and [Pull Requests](https://github.com/alibaba/Sentinel/pulls) for trackers.
50   -
51   -If you find a typo in document, find a bug in code, or want new features, or want to give suggestions,
52   -you can [open an issue on GitHub](https://github.com/alibaba/Sentinel/issues/new) to report it.
53   -Please follow the guideline message in the issue template.
54   -
55   -If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request.
56   -If your PR contains large changes, e.g. component refactor or new components, please write detailed documents
57   -about its design and usage.
58   -
59   -Note that a single PR should not be too large. If heavy changes are required, it's better to separate the changes
60   -to a few individual PRs.
61   -
62   -### Code review
63   -
64   -All code should be well reviewed by one or more committers. Some principles:
65   -
66   -- Readability: Important code should be well-documented. Comply with our code style.
67   -- Elegance: New functions, classes or components should be well designed.
68   -- Testability: Important code should be well-tested (high unit test coverage).
69   -
70   -## Community
71   -
72   -### Contact us
73   -
74   -#### Mailing list
75   -
76   -If you have any questions or advice, please contact sentinel@linux.alibaba.com.
77   -
78   -#### Gitter
79   -
80   -Our Gitter room: [https://gitter.im/alibaba/Sentinel](https://gitter.im/alibaba/Sentinel).
81 0 \ No newline at end of file
sentinel/LICENSE deleted 100644 → 0
1   - Apache License
2   - Version 2.0, January 2004
3   - http://www.apache.org/licenses/
4   -
5   - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6   -
7   - 1. Definitions.
8   -
9   - "License" shall mean the terms and conditions for use, reproduction,
10   - and distribution as defined by Sections 1 through 9 of this document.
11   -
12   - "Licensor" shall mean the copyright owner or entity authorized by
13   - the copyright owner that is granting the License.
14   -
15   - "Legal Entity" shall mean the union of the acting entity and all
16   - other entities that control, are controlled by, or are under common
17   - control with that entity. For the purposes of this definition,
18   - "control" means (i) the power, direct or indirect, to cause the
19   - direction or management of such entity, whether by contract or
20   - otherwise, or (ii) ownership of fifty percent (50%) or more of the
21   - outstanding shares, or (iii) beneficial ownership of such entity.
22   -
23   - "You" (or "Your") shall mean an individual or Legal Entity
24   - exercising permissions granted by this License.
25   -
26   - "Source" form shall mean the preferred form for making modifications,
27   - including but not limited to software source code, documentation
28   - source, and configuration files.
29   -
30   - "Object" form shall mean any form resulting from mechanical
31   - transformation or translation of a Source form, including but
32   - not limited to compiled object code, generated documentation,
33   - and conversions to other media types.
34   -
35   - "Work" shall mean the work of authorship, whether in Source or
36   - Object form, made available under the License, as indicated by a
37   - copyright notice that is included in or attached to the work
38   - (an example is provided in the Appendix below).
39   -
40   - "Derivative Works" shall mean any work, whether in Source or Object
41   - form, that is based on (or derived from) the Work and for which the
42   - editorial revisions, annotations, elaborations, or other modifications
43   - represent, as a whole, an original work of authorship. For the purposes
44   - of this License, Derivative Works shall not include works that remain
45   - separable from, or merely link (or bind by name) to the interfaces of,
46   - the Work and Derivative Works thereof.
47   -
48   - "Contribution" shall mean any work of authorship, including
49   - the original version of the Work and any modifications or additions
50   - to that Work or Derivative Works thereof, that is intentionally
51   - submitted to Licensor for inclusion in the Work by the copyright owner
52   - or by an individual or Legal Entity authorized to submit on behalf of
53   - the copyright owner. For the purposes of this definition, "submitted"
54   - means any form of electronic, verbal, or written communication sent
55   - to the Licensor or its representatives, including but not limited to
56   - communication on electronic mailing lists, source code control systems,
57   - and issue tracking systems that are managed by, or on behalf of, the
58   - Licensor for the purpose of discussing and improving the Work, but
59   - excluding communication that is conspicuously marked or otherwise
60   - designated in writing by the copyright owner as "Not a Contribution."
61   -
62   - "Contributor" shall mean Licensor and any individual or Legal Entity
63   - on behalf of whom a Contribution has been received by Licensor and
64   - subsequently incorporated within the Work.
65   -
66   - 2. Grant of Copyright License. Subject to the terms and conditions of
67   - this License, each Contributor hereby grants to You a perpetual,
68   - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69   - copyright license to reproduce, prepare Derivative Works of,
70   - publicly display, publicly perform, sublicense, and distribute the
71   - Work and such Derivative Works in Source or Object form.
72   -
73   - 3. Grant of Patent License. Subject to the terms and conditions of
74   - this License, each Contributor hereby grants to You a perpetual,
75   - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76   - (except as stated in this section) patent license to make, have made,
77   - use, offer to sell, sell, import, and otherwise transfer the Work,
78   - where such license applies only to those patent claims licensable
79   - by such Contributor that are necessarily infringed by their
80   - Contribution(s) alone or by combination of their Contribution(s)
81   - with the Work to which such Contribution(s) was submitted. If You
82   - institute patent litigation against any entity (including a
83   - cross-claim or counterclaim in a lawsuit) alleging that the Work
84   - or a Contribution incorporated within the Work constitutes direct
85   - or contributory patent infringement, then any patent licenses
86   - granted to You under this License for that Work shall terminate
87   - as of the date such litigation is filed.
88   -
89   - 4. Redistribution. You may reproduce and distribute copies of the
90   - Work or Derivative Works thereof in any medium, with or without
91   - modifications, and in Source or Object form, provided that You
92   - meet the following conditions:
93   -
94   - (a) You must give any other recipients of the Work or
95   - Derivative Works a copy of this License; and
96   -
97   - (b) You must cause any modified files to carry prominent notices
98   - stating that You changed the files; and
99   -
100   - (c) You must retain, in the Source form of any Derivative Works
101   - that You distribute, all copyright, patent, trademark, and
102   - attribution notices from the Source form of the Work,
103   - excluding those notices that do not pertain to any part of
104   - the Derivative Works; and
105   -
106   - (d) If the Work includes a "NOTICE" text file as part of its
107   - distribution, then any Derivative Works that You distribute must
108   - include a readable copy of the attribution notices contained
109   - within such NOTICE file, excluding those notices that do not
110   - pertain to any part of the Derivative Works, in at least one
111   - of the following places: within a NOTICE text file distributed
112   - as part of the Derivative Works; within the Source form or
113   - documentation, if provided along with the Derivative Works; or,
114   - within a display generated by the Derivative Works, if and
115   - wherever such third-party notices normally appear. The contents
116   - of the NOTICE file are for informational purposes only and
117   - do not modify the License. You may add Your own attribution
118   - notices within Derivative Works that You distribute, alongside
119   - or as an addendum to the NOTICE text from the Work, provided
120   - that such additional attribution notices cannot be construed
121   - as modifying the License.
122   -
123   - You may add Your own copyright statement to Your modifications and
124   - may provide additional or different license terms and conditions
125   - for use, reproduction, or distribution of Your modifications, or
126   - for any such Derivative Works as a whole, provided Your use,
127   - reproduction, and distribution of the Work otherwise complies with
128   - the conditions stated in this License.
129   -
130   - 5. Submission of Contributions. Unless You explicitly state otherwise,
131   - any Contribution intentionally submitted for inclusion in the Work
132   - by You to the Licensor shall be under the terms and conditions of
133   - this License, without any additional terms or conditions.
134   - Notwithstanding the above, nothing herein shall supersede or modify
135   - the terms of any separate license agreement you may have executed
136   - with Licensor regarding such Contributions.
137   -
138   - 6. Trademarks. This License does not grant permission to use the trade
139   - names, trademarks, service marks, or product names of the Licensor,
140   - except as required for reasonable and customary use in describing the
141   - origin of the Work and reproducing the content of the NOTICE file.
142   -
143   - 7. Disclaimer of Warranty. Unless required by applicable law or
144   - agreed to in writing, Licensor provides the Work (and each
145   - Contributor provides its Contributions) on an "AS IS" BASIS,
146   - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147   - implied, including, without limitation, any warranties or conditions
148   - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149   - PARTICULAR PURPOSE. You are solely responsible for determining the
150   - appropriateness of using or redistributing the Work and assume any
151   - risks associated with Your exercise of permissions under this License.
152   -
153   - 8. Limitation of Liability. In no event and under no legal theory,
154   - whether in tort (including negligence), contract, or otherwise,
155   - unless required by applicable law (such as deliberate and grossly
156   - negligent acts) or agreed to in writing, shall any Contributor be
157   - liable to You for damages, including any direct, indirect, special,
158   - incidental, or consequential damages of any character arising as a
159   - result of this License or out of the use or inability to use the
160   - Work (including but not limited to damages for loss of goodwill,
161   - work stoppage, computer failure or malfunction, or any and all
162   - other commercial damages or losses), even if such Contributor
163   - has been advised of the possibility of such damages.
164   -
165   - 9. Accepting Warranty or Additional Liability. While redistributing
166   - the Work or Derivative Works thereof, You may choose to offer,
167   - and charge a fee for, acceptance of support, warranty, indemnity,
168   - or other liability obligations and/or rights consistent with this
169   - License. However, in accepting such obligations, You may act only
170   - on Your own behalf and on Your sole responsibility, not on behalf
171   - of any other Contributor, and only if You agree to indemnify,
172   - defend, and hold each Contributor harmless for any liability
173   - incurred by, or claims asserted against, such Contributor by reason
174   - of your accepting any such warranty or additional liability.
175   -
176   - END OF TERMS AND CONDITIONS
177   -
178   - APPENDIX: How to apply the Apache License to your work.
179   -
180   - To apply the Apache License to your work, attach the following
181   - boilerplate notice, with the fields enclosed by brackets "[]"
182   - replaced with your own identifying information. (Don't include
183   - the brackets!) The text should be enclosed in the appropriate
184   - comment syntax for the file format. We also recommend that a
185   - file or class name and description of purpose be included on the
186   - same "printed page" as the copyright notice for easier
187   - identification within third-party archives.
188   -
189   - Copyright [yyyy] [name of copyright owner]
190   -
191   - Licensed under the Apache License, Version 2.0 (the "License");
192   - you may not use this file except in compliance with the License.
193   - You may obtain a copy of the License at
194   -
195   - http://www.apache.org/licenses/LICENSE-2.0
196   -
197   - Unless required by applicable law or agreed to in writing, software
198   - distributed under the License is distributed on an "AS IS" BASIS,
199   - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200   - See the License for the specific language governing permissions and
201   - limitations under the License.
sentinel/README.md deleted 100644 → 0
1   -<img src="https://user-images.githubusercontent.com/9434884/43697219-3cb4ef3a-9975-11e8-9a9c-73f4f537442d.png" alt="Sentinel Logo" width="50%">
2   -
3   -# Sentinel: The Sentinel of Your Microservices
4   -
5   -[![Sentinel CI](https://github.com/alibaba/Sentinel/actions/workflows/ci.yml/badge.svg)](https://github.com/alibaba/Sentinel/actions/workflows/ci.yml)
6   -[![Codecov](https://codecov.io/gh/alibaba/Sentinel/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/Sentinel)
7   -[![Maven Central](https://img.shields.io/maven-central/v/com.alibaba.csp/sentinel-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:com.alibaba.csp%20AND%20a:sentinel-core)
8   -[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
9   -[![Gitter](https://badges.gitter.im/alibaba/Sentinel.svg)](https://gitter.im/alibaba/Sentinel)
10   -
11   -## Introduction
12   -
13   -As distributed systems become increasingly popular, the reliability between services is becoming more important than ever before.
14   -Sentinel takes "flow" as breakthrough point, and works on multiple fields including **flow control**,
15   -**traffic shaping**, **circuit breaking** and **system adaptive protection**, to guarantee reliability and resilience for microservices.
16   -
17   -Sentinel has the following features:
18   -
19   -- **Rich applicable scenarios**: Sentinel has been wildly used in Alibaba, and has covered almost all the core-scenarios in Double-11 (11.11) Shopping Festivals in the past 10 years, such as “Second Kill” which needs to limit burst flow traffic to meet the system capacity, message peak clipping and valley fills, circuit breaking for unreliable downstream services, cluster flow control, etc.
20   -- **Real-time monitoring**: Sentinel also provides real-time monitoring ability. You can see the runtime information of a single machine in real-time, and the aggregated runtime info of a cluster with less than 500 nodes.
21   -- **Widespread open-source ecosystem**: Sentinel provides out-of-box integrations with commonly-used frameworks and libraries such as Spring Cloud, Dubbo and gRPC. You can easily use Sentinel by simply add the adapter dependency to your services.
22   -- **Polyglot support**: Sentinel has provided native support for Java, [Go](https://github.com/alibaba/sentinel-golang) and [C++](https://github.com/alibaba/sentinel-cpp).
23   -- **Various SPI extensions**: Sentinel provides easy-to-use SPI extension interfaces that allow you to quickly customize your logic, for example, custom rule management, adapting data sources, and so on.
24   -
25   -Features overview:
26   -
27   -![features-of-sentinel](./doc/image/sentinel-features-overview-en.png)
28   -
29   -## Documentation
30   -
31   -See the [Sentinel](https://sentinelguard.io/) for the document website.
32   -
33   -See the [中文文档](https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D) for document in Chinese.
34   -
35   -See the [Wiki](https://github.com/alibaba/Sentinel/wiki) for full documentation, examples, blog posts, operational details and other information.
36   -
37   -Sentinel provides integration modules for various open-source frameworks
38   -(e.g. Spring Cloud, Apache Dubbo, gRPC, Spring WebFlux, Reactor) and service mesh.
39   -You can refer to [the document](https://github.com/alibaba/Sentinel/wiki/Adapters-to-Popular-Framework) for more information.
40   -
41   -If you are using Sentinel, please [**leave a comment here**](https://github.com/alibaba/Sentinel/issues/18) to tell us your scenario to make Sentinel better.
42   -It's also encouraged to add the link of your blog post, tutorial, demo or customized components to [**Awesome Sentinel**](./doc/awesome-sentinel.md).
43   -
44   -## Ecosystem Landscape
45   -
46   -![ecosystem-landscape](./doc/image/sentinel-opensource-eco-landscape-en.png)
47   -
48   -## Quick Start
49   -
50   -Below is a simple demo that guides new users to use Sentinel in just 3 steps. It also shows how to monitor this demo using the dashboard.
51   -
52   -### 1. Add Dependency
53   -
54   -**Note:** Sentinel requires JDK 1.8 or later.
55   -
56   -If you're using Maven, just add the following dependency in `pom.xml`.
57   -
58   -```xml
59   -<!-- replace here with the latest version -->
60   -<dependency>
61   - <groupId>com.alibaba.csp</groupId>
62   - <artifactId>sentinel-core</artifactId>
63   - <version>1.8.3</version>
64   -</dependency>
65   -```
66   -
67   -If not, you can download JAR in [Maven Center Repository](https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-core).
68   -
69   -### 2. Define Resource
70   -
71   -Wrap your code snippet via Sentinel API: `SphU.entry(resourceName)`.
72   -In below example, it is `System.out.println("hello world");`:
73   -
74   -```java
75   -try (Entry entry = SphU.entry("HelloWorld")) {
76   - // Your business logic here.
77   - System.out.println("hello world");
78   -} catch (BlockException e) {
79   - // Handle rejected request.
80   - e.printStackTrace();
81   -}
82   -// try-with-resources auto exit
83   -```
84   -
85   -So far the code modification is done. We've also provided [annotation support module](https://github.com/alibaba/Sentinel/blob/master/sentinel-extension/sentinel-annotation-aspectj/README.md) to define resource easier.
86   -
87   -### 3. Define Rules
88   -
89   -If we want to limit the access times of the resource, we can **set rules to the resource**.
90   -The following code defines a rule that limits access to the resource to 20 times per second at the maximum.
91   -
92   -```java
93   -List<FlowRule> rules = new ArrayList<>();
94   -FlowRule rule = new FlowRule();
95   -rule.setResource("HelloWorld");
96   -// set limit qps to 20
97   -rule.setCount(20);
98   -rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
99   -rules.add(rule);
100   -FlowRuleManager.loadRules(rules);
101   -```
102   -
103   -For more information, please refer to [How To Use](https://github.com/alibaba/Sentinel/wiki/How-to-Use).
104   -
105   -### 4. Check the Result
106   -
107   -After running the demo for a while, you can see the following records in `~/logs/csp/${appName}-metrics.log.{date}` (When using the default `DateFileLogHandler`).
108   -
109   -```
110   -|--timestamp-|------date time----|-resource-|p |block|s |e|rt |occupied
111   -1529998904000|2018-06-26 15:41:44|HelloWorld|20|0 |20|0|0 |0
112   -1529998905000|2018-06-26 15:41:45|HelloWorld|20|5579 |20|0|728 |0
113   -1529998906000|2018-06-26 15:41:46|HelloWorld|20|15698|20|0|0 |0
114   -1529998907000|2018-06-26 15:41:47|HelloWorld|20|19262|20|0|0 |0
115   -1529998908000|2018-06-26 15:41:48|HelloWorld|20|19502|20|0|0 |0
116   -1529998909000|2018-06-26 15:41:49|HelloWorld|20|18386|20|0|0 |0
117   -
118   -p stands for incoming request, block for blocked by rules, s for success handled by Sentinel, e for exception count, rt for average response time (ms), occupied stands for occupiedPassQps since 1.5.0 which enable us booking more than 1 shot when entering.
119   -```
120   -
121   -This shows that the demo can print "hello world" 20 times per second.
122   -
123   -More examples and information can be found in the [How To Use](https://github.com/alibaba/Sentinel/wiki/How-to-Use) section.
124   -
125   -The working principles of Sentinel can be found in [How it works](https://github.com/alibaba/Sentinel/wiki/How-it-works) section.
126   -
127   -Samples can be found in the [sentinel-demo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo) module.
128   -
129   -### 5. Start Dashboard
130   -
131   -> Note: Java 8 is required for building or running the dashboard.
132   -
133   -Sentinel also provides a simple dashboard application, on which you can monitor the clients and configure the rules in real time.
134   -
135   -![dashboard](https://user-images.githubusercontent.com/9434884/55449295-84866d80-55fd-11e9-94e5-d3441f4a2b63.png)
136   -
137   -For details please refer to [Dashboard](https://github.com/alibaba/Sentinel/wiki/Dashboard).
138   -
139   -## Trouble Shooting and Logs
140   -
141   -Sentinel will generate logs for troubleshooting and real-time monitoring.
142   -All the information can be found in [logs](https://github.com/alibaba/Sentinel/wiki/Logs).
143   -
144   -## Bugs and Feedback
145   -
146   -For bug report, questions and discussions please submit [GitHub Issues](https://github.com/alibaba/sentinel/issues).
147   -
148   -Contact us via [Gitter](https://gitter.im/alibaba/Sentinel) or [Email](mailto:sentinel@linux.alibaba.com).
149   -
150   -## Contributing
151   -
152   -Contributions are always welcomed! Please refer to [CONTRIBUTING](./CONTRIBUTING.md) for detailed guidelines.
153   -
154   -You can start with the issues labeled with [`good first issue`](https://github.com/alibaba/Sentinel/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
155   -
156   -## Credits
157   -
158   -Thanks [Guava](https://github.com/google/guava), which provides some inspiration on rate limiting.
159   -
160   -And thanks for all [contributors](https://github.com/alibaba/Sentinel/graphs/contributors) of Sentinel!
161   -
162   -## Who is using
163   -
164   -These are only part of the companies using Sentinel, for reference only.
165   -If you are using Sentinel, please [add your company here](https://github.com/alibaba/Sentinel/issues/18) to tell us your scenario to make Sentinel better :)
166   -
167   -![Alibaba Group](https://docs.alibabagroup.com/assets2/images/en/global/logo_header.png)
168   -![AntFin](https://user-images.githubusercontent.com/9434884/90598732-30961c00-e226-11ea-8c86-0b1d7f7875c7.png)
169   -![Taiping Renshou](http://www.cntaiping.com/tplresource/cms/www/taiping/img/home_new/tp_logo_img.png)
170   -![拼多多](http://cdn.pinduoduo.com/assets/img/pdd_logo_v3.png)
171   -![爱奇艺](https://user-images.githubusercontent.com/9434884/90598445-a51c8b00-e225-11ea-9327-3543525f3f2a.png)
172   -![Shunfeng Technology](https://user-images.githubusercontent.com/9434884/48463502-2f48eb80-e817-11e8-984f-2f9b1b789e2d.png)
173   -![二维火](https://user-images.githubusercontent.com/9434884/49358468-bc43de00-f70d-11e8-97fe-0bf05865f29f.png)
174   -![Mandao](https://user-images.githubusercontent.com/9434884/48463559-6cad7900-e817-11e8-87e4-42952b074837.png)
175   -![文轩在线](http://static.winxuancdn.com/css/v2/images/logo.png)
176   -![客如云](https://www.keruyun.com/static/krynew/images/logo.png)
177   -![亲宝宝](https://stlib.qbb6.com/wclt/img/home_hd/version1/title_logo.png)
178   -![金汇金融](https://res.jinhui365.com/r/images/logo2.png?v=1.527)
179   -![闪电购](http://cdn.52shangou.com/shandianbang/official-source/3.1.1/build/images/logo.png)
sentinel/doc/README.md deleted 100644 → 0
1   -# Sentinel related documents
2   -
3   -- [Awesome Sentinel](./awesome-sentinel.md)
sentinel/doc/awesome-sentinel.md deleted 100644 → 0
1   -# Awesome Sentinel
2   -
3   -[![Awesome](https://awesome.re/badge-flat.svg)](https://awesome.re)
4   -
5   -A curated list of awesome things (e.g. samples, third-party extensions, blog posts) for [Sentinel](https://github.com/alibaba/Sentinel).
6   -
7   -If you want your component to appear here, feel free to submit a pull request to this repository to add it.
8   -You can refer to the [awesome contribution guidelines](https://github.com/sentinel-group/sentinel-awesome/blob/master/CONTRIBUTING.md).
9   -
10   -You can also add to [sentinel-group/sentinel-awesome](https://github.com/sentinel-group/sentinel-awesome).
11   -
12   -## Contents
13   -
14   -- [Presentations](#presentations)
15   -- [Tutorials](#tutorials)
16   -- [Demos](#demos)
17   -- [Extensions / Integrations](#extensions--integrations)
18   -- [Blog Posts](#blog-posts)
19   -
20   -## Presentations
21   -
22   -- Sentinel 1.6.0 网关流控新特性介绍-Eric Zhao (Dubbo Tech Day-201905-Beijing): [PDF](https://github.com/sentinel-group/sentinel-awesome/blob/master/slides/Sentinel%201.6.0%20网关流控新特性介绍-Eric%20Zhao-DTED-201905.pdf)
23   -- Sentinel 微服务流控降级实践-Eric Zhao (Dubbo Tech Day-201907-Shenzhen): [PDF](https://github.com/sentinel-group/sentinel-awesome/blob/master/slides/Sentinel%20微服务流控降级实践-Eric%20Zhao-DTED-201907.pdf)
24   -- Sentinel 1.7.0 新特性展望-Eric Zhao (Dubbo Tech Day-201910-Chengdu): [PDF](https://github.com/sentinel-group/sentinel-awesome/blob/master/slides/Sentinel%201.7.0%20新特性展望-Eric%20Zhao-DTED-201910.pdf)
25   -
26   -## Tutorials
27   -
28   -- [Sentinel Guides](https://github.com/sentinel-group/sentinel-guides)
29   -
30   -## Demos
31   -
32   -- [sentinel-zuul-example](https://github.com/tigerMoon/sentinel-zuul-sample): A simple project integration Sentinel to Spring Cloud Zuul which provides Service and API Path level flow control management by [tiger](https://github.com/tigerMoon)
33   -
34   -## Extensions / Integrations
35   -
36   -- [sentinel-support](https://github.com/cdfive/sentinel-support): A support project for convenient Sentinel integration including properties file configuration, ActiveMQ integration and a JdbcDataSource implementation by [cdfive](https://github.com/cdfive)
37   -- [Sentinel dashboard multi-data-source adapter](https://github.com/finefuture/sentinel-dashboard-X): Sentinel dashboard multi-data-source adapter has integrated Apollo and Nacos configuration center for bidirectional modification persistence. Implemented by [finefuture](https://github.com/finefuture)
38   -- [Sentinel Rule Annotation Support](https://github.com/code1986/sentinel-lib): A third-party library that supports configuring flow rule and degrade rule using annotation. Implemented by [code1986](https://github.com/code1986)
39   -- [sentinel-pigeon-adapter](https://github.com/wchswchs/sentinel-pigeon): A RPC framework Pigeon adapter for Sentinel including provider and invoker rate limiting implementation by [wchswchs](https://github.com/wchswchs)
40   -
41   -## Blog Posts
42   -
43   -- [Sentinel 为 Dubbo 服务保驾护航](https://dubbo.apache.org/zh/blog/2018/07/27/sentinel-为-dubbo-服务保驾护航) by [Eric Zhao](https://github.com/sczyh30)
44   -- [在生产环境中使用 Sentinel 控制台](https://github.com/alibaba/Sentinel/wiki/在生产环境中使用-Sentinel) by [Eric Zhao](https://github.com/sczyh30)
45   -- [Sentinel 与 Hystrix 的对比](https://sentinelguard.io/zh-cn/blog/sentinel-vs-hystrix.html) by [Eric Zhao](https://github.com/sczyh30)
46   -- [Guideline: 从 Hystrix 迁移到 Sentinel](https://sentinelguard.io/zh-cn/blog/guideline-migrate-from-hystrix-to-sentinel.html) by [Eric Zhao](https://github.com/sczyh30)
47   -- [Sentinel 控制台监控数据持久化【MySQL】](https://www.cnblogs.com/cdfive2018/p/9838577.html) by [cdfive](https://github.com/cdfive)
48   -- [Sentinel 控制台监控数据持久化【InfluxDB】](https://www.cnblogs.com/cdfive2018/p/9914838.html) by [cdfive](https://github.com/cdfive)
49   -- [Sentinel 控制台监控数据持久化【Apollo】](https://blog.csdn.net/caodegao/article/details/100009618) by [cookiejoo](https://github.com/cookiejoo)
50   -- [Sentinel一体化监控解决方案 CrateDB + Grafana](https://blog.csdn.net/huyong1990/article/details/82392386) by [Young Hu](https://github.com/YoungHu)
51   -- Sentinel 源码解析系列 by [houyi](https://github.com/all4you)
52   - - [Sentinel 原理-全解析](https://mp.weixin.qq.com/s/7_pCkamNv0269e5l9_Wz7w)
53   - - [Sentinel 原理-调用链](https://mp.weixin.qq.com/s/UEzwD22YC6jpp02foNSXnw)
54   - - [Sentinel 原理-滑动窗口](https://mp.weixin.qq.com/s/B1_7Kb_CxeKEAv43kdCWOA)
55   - - [Sentinel 实战-限流](https://mp.weixin.qq.com/s/rjyU37Dm-sxNln7GUD8tOw)
56   - - [Sentinel 实战-控制台](https://mp.weixin.qq.com/s/23EDFHMXLwsDqw-4O5dR5A)
57   - - [Sentinel 实战-规则持久化](https://mp.weixin.qq.com/s/twMFiBfRawKLR-1-N-f1yw)
58   -- Sentinel 学习笔记 by [ro9er](https://github.com/ro9er)
59   - - [Sentinel 学习笔记(1)-- 流量统计代码解析](https://www.jianshu.com/p/7936d7a57924)
60   - - [Sentinel 学习笔记(2)-- 流量控制代码分析](https://www.jianshu.com/p/938709e94e43)
61   - - [Sentinel 学习笔记(3)-- 上下文统计Node建立分析](https://www.jianshu.com/p/cfdf525248c1)
62   -- [大流量下的服务质量治理 Dubbo Sentinel 初涉](https://mp.weixin.qq.com/s/ergr_siI07VwwSRPFgsLvQ) by [RyuGrade](https://github.com/RyuGrade)
63   -- Sentinel 深入浅出系列 by [shxz130](https://github.com/shxz130)
64   - - [Sentinel 深入浅出之原理篇 SlotChain](https://www.jianshu.com/p/a7a405de3a12)
65   - - [Sentinel 深入浅出之原理篇 Context初始化 & Entry初始化](https://www.jianshu.com/p/e39ac47cd893)
66   - - [Sentinel 深入浅出之原理篇 NodeSelectorSlot](https://www.jianshu.com/p/9a380ba188ab)
67   - - [Sentinel 深入浅出之原理篇 ClusterBuilderSlot](https://www.jianshu.com/p/0b0b5d8888a2)
68   - - [Sentinel 深入浅出之原理篇 StatisticSlot&滑动窗口](https://www.jianshu.com/p/9620298fd15a)
69   - - [Sentinel 深入浅出之原理篇 SystemSlot](https://www.jianshu.com/p/bfad1b7d0cde)
70   - - [Sentinel 深入浅出之原理篇 AuthoritySlot](https://www.jianshu.com/p/c5312c2242b3)
71   - - [Sentinel 深入浅出之原理篇 FlowSlot](https://www.jianshu.com/p/53218d0d273e)
72   - - [Sentinel 深入浅出之原理篇 DegradeSlot](https://www.jianshu.com/p/e910d4840e4a)
73   -- [Alibaba Sentinel RESTful 接口流控处理优化](https://www.jianshu.com/p/96f5980d9798) by [luanlouis](https://github.com/luanlouis)
74   -- [Sentinel 控制台前端开发环境搭建](https://www.cnblogs.com/cdfive2018/p/11084001.html) by [cdfive](https://github.com/cdfive)
75   -- [阿里 Sentinel 源码解析](https://www.javadoop.com/post/sentinel) by [Javadoop](https://www.javadoop.com)
76   -- [Introduction to Alibaba Sentinel](https://www.baeldung.com/java-sentinel-intro) by [Amit Bhave](https://github.com/Amitbhave)
sentinel/doc/image/sentinel-features-overview-en.png deleted 100644 → 0

134 KB

sentinel/doc/image/sentinel-opensource-eco-landscape-en.png deleted 100644 → 0

902 KB

sentinel/doc/image/slots.gif deleted 100644 → 0

154 KB

sentinel/pom.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4   - <modelVersion>4.0.0</modelVersion>
5   -
6   - <groupId>com.alibaba.csp</groupId>
7   - <artifactId>sentinel-parent</artifactId>
8   - <version>1.8.3</version>
9   - <packaging>pom</packaging>
10   -
11   - <name>${project.artifactId}</name>
12   - <description>The parent project of Sentinel</description>
13   - <url>https://github.com/alibaba/Sentinel</url>
14   - <licenses>
15   - <license>
16   - <name>Apache License, Version 2.0</name>
17   - <url>http://www.apache.org/licenses/LICENSE-2.0</url>
18   - <distribution>repo</distribution>
19   - </license>
20   - </licenses>
21   - <scm>
22   - <url>https://github.com/alibaba/Sentinel</url>
23   - <connection>scm:git:https://github.com/alibaba/Sentinel.git</connection>
24   - <developerConnection>scm:git:https://github.com/alibaba/Sentinel.git</developerConnection>
25   - </scm>
26   - <developers>
27   - <developer>
28   - <name>The Sentinel Project Contributors</name>
29   - <email>sentinel-dev@linux.alibaba.com</email>
30   - <url>https://github.com/alibaba/Sentinel</url>
31   - </developer>
32   - </developers>
33   - <organization>
34   - <name>Alibaba Group</name>
35   - <url>https://github.com/alibaba</url>
36   - </organization>
37   - <issueManagement>
38   - <system>github</system>
39   - <url>https://github.com/alibaba/Sentinel/issues</url>
40   - </issueManagement>
41   -
42   - <properties>
43   - <!-- Compile libs -->
44   - <fastjson.version>1.2.75</fastjson.version>
45   - <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
46   -
47   - <!-- Test libs -->
48   - <junit.version>4.12</junit.version>
49   - <mockito.version>2.28.2</mockito.version>
50   - <assertj.version>3.12.1</assertj.version>
51   - <awaitility.version>3.1.5</awaitility.version>
52   - <powermock.version>2.0.0</powermock.version>
53   -
54   - <!-- Build -->
55   - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
56   - <java.source.version>1.8</java.source.version>
57   - <java.target.version>1.8</java.target.version>
58   - <java.encoding>UTF-8</java.encoding>
59   - <maven.compiler.version>3.8.0</maven.compiler.version>
60   - <maven.surefire.version>2.22.1</maven.surefire.version>
61   - <maven.source.version>3.0.1</maven.source.version>
62   - <maven.javadoc.version>3.0.1</maven.javadoc.version>
63   - <maven.deploy.version>2.8.2</maven.deploy.version>
64   - <maven.gpg.version>1.6</maven.gpg.version>
65   - <maven.jacoco.version>0.8.3</maven.jacoco.version>
66   - <maven.jar.version>3.1.0</maven.jar.version>
67   - <maven.pmd.version>3.8</maven.pmd.version>
68   - </properties>
69   -
70   - <modules>
71   - <module>sentinel-core</module>
72   - <module>sentinel-extension</module>
73   - <module>sentinel-transport</module>
74   - <module>sentinel-adapter</module>
75   - <module>sentinel-cluster</module>
76   - <module>sentinel-logging</module>
77   -
78   - <module>sentinel-dashboard</module>
79   -
80   - <module>sentinel-demo</module>
81   - <module>sentinel-benchmark</module>
82   -
83   - </modules>
84   -
85   - <dependencyManagement>
86   - <dependencies>
87   - <dependency>
88   - <groupId>com.alibaba.csp</groupId>
89   - <artifactId>sentinel-core</artifactId>
90   - <version>${project.version}</version>
91   - </dependency>
92   - <dependency>
93   - <groupId>com.alibaba.csp</groupId>
94   - <artifactId>sentinel-extension</artifactId>
95   - <version>${project.version}</version>
96   - </dependency>
97   - <dependency>
98   - <groupId>com.alibaba.csp</groupId>
99   - <artifactId>sentinel-annotation-aspectj</artifactId>
100   - <version>${project.version}</version>
101   - </dependency>
102   - <dependency>
103   - <groupId>com.alibaba.csp</groupId>
104   - <artifactId>sentinel-annotation-cdi-interceptor</artifactId>
105   - <version>${project.version}</version>
106   - </dependency>
107   - <dependency>
108   - <groupId>com.alibaba.csp</groupId>
109   - <artifactId>sentinel-parameter-flow-control</artifactId>
110   - <version>${project.version}</version>
111   - </dependency>
112   - <dependency>
113   - <groupId>com.alibaba.csp</groupId>
114   - <artifactId>sentinel-datasource-extension</artifactId>
115   - <version>${project.version}</version>
116   - </dependency>
117   - <dependency>
118   - <groupId>com.alibaba.csp</groupId>
119   - <artifactId>sentinel-datasource-nacos</artifactId>
120   - <version>${project.version}</version>
121   - </dependency>
122   - <dependency>
123   - <groupId>com.alibaba.csp</groupId>
124   - <artifactId>sentinel-datasource-zookeeper</artifactId>
125   - <version>${project.version}</version>
126   - </dependency>
127   - <dependency>
128   - <groupId>com.alibaba.csp</groupId>
129   - <artifactId>sentinel-datasource-apollo</artifactId>
130   - <version>${project.version}</version>
131   - </dependency>
132   - <dependency>
133   - <groupId>com.alibaba.csp</groupId>
134   - <artifactId>sentinel-datasource-etcd</artifactId>
135   - <version>${project.version}</version>
136   - </dependency>
137   - <dependency>
138   - <groupId>com.alibaba.csp</groupId>
139   - <artifactId>sentinel-transport-simple-http</artifactId>
140   - <version>${project.version}</version>
141   - </dependency>
142   - <dependency>
143   - <groupId>com.alibaba.csp</groupId>
144   - <artifactId>sentinel-transport-netty-http</artifactId>
145   - <version>${project.version}</version>
146   - </dependency>
147   - <dependency>
148   - <groupId>com.alibaba.csp</groupId>
149   - <artifactId>sentinel-transport-spring-mvc</artifactId>
150   - <version>${project.version}</version>
151   - </dependency>
152   - <dependency>
153   - <groupId>com.alibaba.csp</groupId>
154   - <artifactId>sentinel-transport-common</artifactId>
155   - <version>${project.version}</version>
156   - </dependency>
157   - <dependency>
158   - <groupId>com.alibaba.csp</groupId>
159   - <artifactId>sentinel-cluster-common-default</artifactId>
160   - <version>${project.version}</version>
161   - </dependency>
162   - <dependency>
163   - <groupId>com.alibaba.csp</groupId>
164   - <artifactId>sentinel-adapter</artifactId>
165   - <version>${project.version}</version>
166   - </dependency>
167   -
168   - <dependency>
169   - <groupId>com.alibaba.csp</groupId>
170   - <artifactId>sentinel-metric-exporter</artifactId>
171   - <version>${project.version}</version>
172   - </dependency>
173   -
174   - <dependency>
175   - <groupId>com.alibaba</groupId>
176   - <artifactId>fastjson</artifactId>
177   - <version>${fastjson.version}</version>
178   - </dependency>
179   -
180   - <dependency>
181   - <groupId>junit</groupId>
182   - <artifactId>junit</artifactId>
183   - <version>${junit.version}</version>
184   - <scope>test</scope>
185   - </dependency>
186   - <dependency>
187   - <groupId>org.mockito</groupId>
188   - <artifactId>mockito-core</artifactId>
189   - <version>${mockito.version}</version>
190   - <scope>test</scope>
191   - </dependency>
192   - <dependency>
193   - <groupId>org.assertj</groupId>
194   - <artifactId>assertj-core</artifactId>
195   - <version>${assertj.version}</version>
196   - <scope>test</scope>
197   - </dependency>
198   - <dependency>
199   - <groupId>org.awaitility</groupId>
200   - <artifactId>awaitility</artifactId>
201   - <version>${awaitility.version}</version>
202   - <scope>test</scope>
203   - </dependency>
204   - <dependency>
205   - <groupId>org.hamcrest</groupId>
206   - <artifactId>java-hamcrest</artifactId>
207   - <version>2.0.0.0</version>
208   - <scope>test</scope>
209   - </dependency>
210   - <dependency>
211   - <groupId>org.powermock</groupId>
212   - <artifactId>powermock-module-junit4</artifactId>
213   - <version>${powermock.version}</version>
214   - <scope>test</scope>
215   - </dependency>
216   - <dependency>
217   - <groupId>org.powermock</groupId>
218   - <artifactId>powermock-api-mockito2</artifactId>
219   - <version>${powermock.version}</version>
220   - <scope>test</scope>
221   - </dependency>
222   - </dependencies>
223   - </dependencyManagement>
224   -
225   - <build>
226   - <plugins>
227   - <plugin>
228   - <groupId>org.apache.maven.plugins</groupId>
229   - <artifactId>maven-pmd-plugin</artifactId>
230   - <version>${maven.pmd.version}</version>
231   - <configuration>
232   - <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
233   - <minimumPriority>1</minimumPriority>
234   - <excludeRoots>
235   - <excludeRoot>com/alibaba/csp/sentinel/benchmark</excludeRoot>
236   - </excludeRoots>
237   - <excludes>
238   - <exclude>**/*_jmhTest.java</exclude>
239   - </excludes>
240   - <printFailingErrors>true</printFailingErrors>
241   - <rulesets>
242   - <ruleset>rulesets/java/ali-comment.xml</ruleset>
243   - <ruleset>rulesets/java/ali-concurrent.xml</ruleset>
244   - <ruleset>rulesets/java/ali-constant.xml</ruleset>
245   - <ruleset>rulesets/java/ali-exception.xml</ruleset>
246   - <ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
247   - <ruleset>rulesets/java/ali-naming.xml</ruleset>
248   - <ruleset>rulesets/java/ali-oop.xml</ruleset>
249   - <ruleset>rulesets/java/ali-orm.xml</ruleset>
250   - <ruleset>rulesets/java/ali-other.xml</ruleset>
251   - <ruleset>rulesets/java/ali-set.xml</ruleset>
252   - </rulesets>
253   - </configuration>
254   - <executions>
255   - <execution>
256   - <phase>verify</phase>
257   - <goals>
258   - <goal>check</goal>
259   - </goals>
260   - </execution>
261   - </executions>
262   - <dependencies>
263   - <dependency>
264   - <groupId>com.alibaba.p3c</groupId>
265   - <artifactId>p3c-pmd</artifactId>
266   - <version>1.3.6</version>
267   - </dependency>
268   - </dependencies>
269   - </plugin>
270   - <plugin>
271   - <groupId>org.apache.maven.plugins</groupId>
272   - <artifactId>maven-compiler-plugin</artifactId>
273   - <version>${maven.compiler.version}</version>
274   - <configuration>
275   - <source>${java.source.version}</source>
276   - <target>${java.target.version}</target>
277   - <encoding>${java.encoding}</encoding>
278   - </configuration>
279   - </plugin>
280   - <plugin>
281   - <groupId>org.apache.maven.plugins</groupId>
282   - <artifactId>maven-surefire-plugin</artifactId>
283   - <configuration>
284   - <!-- CircleCI build workaround -->
285   - <argLine>@{argLine} -Xms1024m -Xmx2048m</argLine>
286   - <argLine>-Dfile.encoding=UTF-8</argLine>
287   - <useSystemClassLoader>false</useSystemClassLoader>
288   - </configuration>
289   - </plugin>
290   - <plugin>
291   - <groupId>org.jacoco</groupId>
292   - <artifactId>jacoco-maven-plugin</artifactId>
293   - <version>${maven.jacoco.version}</version>
294   - <executions>
295   - <execution>
296   - <goals>
297   - <goal>prepare-agent</goal>
298   - </goals>
299   - </execution>
300   - <execution>
301   - <id>report</id>
302   - <phase>test</phase>
303   - <goals>
304   - <goal>report</goal>
305   - </goals>
306   - </execution>
307   - </executions>
308   - </plugin>
309   - </plugins>
310   - <pluginManagement>
311   - <plugins>
312   - <plugin>
313   - <groupId>org.apache.maven.plugins</groupId>
314   - <artifactId>maven-surefire-plugin</artifactId>
315   - <version>${maven.surefire.version}</version>
316   - </plugin>
317   - <plugin>
318   - <groupId>org.apache.maven.plugins</groupId>
319   - <artifactId>maven-jar-plugin</artifactId>
320   - <version>${maven.jar.version}</version>
321   - </plugin>
322   - <plugin>
323   - <groupId>org.apache.maven.plugins</groupId>
324   - <artifactId>maven-gpg-plugin</artifactId>
325   - <version>${maven.gpg.version}</version>
326   - </plugin>
327   - </plugins>
328   - </pluginManagement>
329   - </build>
330   -
331   - <profiles>
332   - <profile>
333   - <id>oss</id>
334   - <build>
335   - <plugins>
336   - <!-- Source -->
337   - <plugin>
338   - <groupId>org.apache.maven.plugins</groupId>
339   - <artifactId>maven-source-plugin</artifactId>
340   - <version>${maven.source.version}</version>
341   - <executions>
342   - <execution>
343   - <phase>package</phase>
344   - <goals>
345   - <goal>jar-no-fork</goal>
346   - </goals>
347   - </execution>
348   - </executions>
349   - </plugin>
350   - <!-- Javadoc -->
351   - <plugin>
352   - <groupId>org.apache.maven.plugins</groupId>
353   - <artifactId>maven-javadoc-plugin</artifactId>
354   - <version>${maven.javadoc.version}</version>
355   - <executions>
356   - <execution>
357   - <phase>package</phase>
358   - <goals>
359   - <goal>jar</goal>
360   - </goals>
361   - <configuration>
362   - <locale>en_US</locale>
363   - <encoding>UTF-8</encoding>
364   - <charset>UTF-8</charset>
365   - <doclint>none</doclint>
366   - </configuration>
367   - </execution>
368   - </executions>
369   - </plugin>
370   - <!-- GPG -->
371   - <plugin>
372   - <groupId>org.apache.maven.plugins</groupId>
373   - <artifactId>maven-gpg-plugin</artifactId>
374   - <version>${maven.gpg.version}</version>
375   - <executions>
376   - <execution>
377   - <phase>verify</phase>
378   - <goals>
379   - <goal>sign</goal>
380   - </goals>
381   - </execution>
382   - </executions>
383   - </plugin>
384   - </plugins>
385   - </build>
386   - <distributionManagement>
387   - <snapshotRepository>
388   - <id>oss</id>
389   - <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
390   - </snapshotRepository>
391   - <repository>
392   - <id>oss</id>
393   - <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
394   - </repository>
395   - </distributionManagement>
396   - </profile>
397   - </profiles>
398   -
399   -</project>
sentinel/sentinel-adapter/pom.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="utf-8"?>
2   -
3   -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <modelVersion>4.0.0</modelVersion>
6   -
7   - <parent>
8   - <groupId>com.alibaba.csp</groupId>
9   - <artifactId>sentinel-parent</artifactId>
10   - <version>1.8.3</version>
11   - </parent>
12   - <artifactId>sentinel-adapter</artifactId>
13   - <packaging>pom</packaging>
14   - <name>sentinel-adapter</name>
15   - <description>The adapters of Sentinel</description>
16   -
17   - <modules>
18   - <module>sentinel-web-servlet</module>
19   - <module>sentinel-dubbo-adapter</module>
20   - <module>sentinel-apache-dubbo-adapter</module>
21   - <module>sentinel-apache-httpclient-adapter</module>
22   - <module>sentinel-sofa-rpc-adapter</module>
23   - <module>sentinel-grpc-adapter</module>
24   - <module>sentinel-zuul-adapter</module>
25   - <module>sentinel-reactor-adapter</module>
26   - <module>sentinel-spring-webflux-adapter</module>
27   - <module>sentinel-api-gateway-adapter-common</module>
28   - <module>sentinel-spring-cloud-gateway-adapter</module>
29   - <module>sentinel-spring-webmvc-adapter</module>
30   - <module>sentinel-zuul2-adapter</module>
31   - <module>sentinel-okhttp-adapter</module>
32   - <module>sentinel-jax-rs-adapter</module>
33   - <module>sentinel-quarkus-adapter</module>
34   - <module>sentinel-motan-adapter</module>
35   - </modules>
36   -
37   - <dependencyManagement>
38   - <dependencies>
39   - <dependency>
40   - <groupId>com.alibaba.csp</groupId>
41   - <artifactId>sentinel-core</artifactId>
42   - <version>${project.version}</version>
43   - </dependency>
44   - <dependency>
45   - <groupId>com.alibaba.csp</groupId>
46   - <artifactId>sentinel-extension</artifactId>
47   - <version>${project.version}</version>
48   - </dependency>
49   - <dependency>
50   - <groupId>com.alibaba.csp</groupId>
51   - <artifactId>sentinel-web-servlet</artifactId>
52   - <version>${project.version}</version>
53   - </dependency>
54   - <dependency>
55   - <groupId>com.alibaba.csp</groupId>
56   - <artifactId>sentinel-reactor-adapter</artifactId>
57   - <version>${project.version}</version>
58   - </dependency>
59   - <dependency>
60   - <groupId>com.alibaba.csp</groupId>
61   - <artifactId>sentinel-api-gateway-adapter-common</artifactId>
62   - <version>${project.version}</version>
63   - </dependency>
64   -
65   - <dependency>
66   - <groupId>junit</groupId>
67   - <artifactId>junit</artifactId>
68   - <version>${junit.version}</version>
69   - <scope>test</scope>
70   - </dependency>
71   - <dependency>
72   - <groupId>org.mockito</groupId>
73   - <artifactId>mockito-core</artifactId>
74   - <version>${mockito.version}</version>
75   - <scope>test</scope>
76   - </dependency>
77   - </dependencies>
78   - </dependencyManagement>
79   -</project>
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/README.md deleted 100644 → 0
1   -# Sentinel Apache Dubbo Adapter (for 2.7.x+)
2   -
3   -> Note: 中文文档请见[此处](https://github.com/alibaba/Sentinel/wiki/主流框架的适配#dubbo)。
4   -
5   -Sentinel Dubbo Adapter provides service consumer filter and provider filter
6   -for [Apache Dubbo](https://dubbo.apache.org/en-us/) services.
7   -
8   -**Note: This adapter only supports Apache Dubbo 2.7.x and above.** For legacy `com.alibaba:dubbo` 2.6.x,
9   -please use `sentinel-dubbo-adapter` module instead.
10   -
11   -To use Sentinel Dubbo Adapter, you can simply add the following dependency to your `pom.xml`:
12   -
13   -```xml
14   -<dependency>
15   - <groupId>com.alibaba.csp</groupId>
16   - <artifactId>sentinel-apache-dubbo-adapter</artifactId>
17   - <version>x.y.z</version>
18   -</dependency>
19   -```
20   -
21   -The Sentinel filters are **enabled by default**. Once you add the dependency,
22   -the Dubbo services and methods will become protected resources in Sentinel,
23   -which can leverage Sentinel's flow control and guard ability when rules are configured.
24   -Demos can be found in [sentinel-demo-apache-dubbo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-apache-dubbo).
25   -
26   -If you don't want the filters enabled, you can manually disable them. For example:
27   -
28   -```xml
29   -<dubbo:consumer filter="-sentinel.dubbo.consumer.filter"/>
30   -
31   -<dubbo:provider filter="-sentinel.dubbo.provider.filter"/>
32   -```
33   -
34   -For more details of Dubbo filter, see [here](http://dubbo.apache.org/en-us/docs/dev/impls/filter.html).
35   -
36   -## Dubbo resources
37   -
38   -The resource for Dubbo services has two granularities: service interface and service method.
39   -
40   -- Service interface: resourceName format is `interfaceName`, e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService`
41   -- Service method: resourceName format is `interfaceName:methodSignature`, e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)`
42   -
43   -## Flow control based on caller
44   -
45   -In many circumstances, it's also significant to control traffic flow based on the **caller**.
46   -For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider.
47   -If we want to limit the calls from service B only, we can set the `limitApp` of flow rule as the identifier of service B (e.g. service name).
48   -
49   -Sentinel Dubbo Adapter will automatically resolve the Dubbo consumer's *application name* as the caller's name (`origin`),
50   -and will bring the caller's name when doing resource protection.
51   -If `limitApp` of flow rules is not configured (`default`), flow control will take effects on all callers.
52   -If `limitApp` of a flow rule is configured with a caller, then the corresponding flow rule will only take effect on the specific caller.
53   -
54   -> Note: Dubbo consumer does not provide its Dubbo application name when doing RPC,
55   -> so developers should manually put the application name into *attachment* at consumer side,
56   -> then extract it at provider side. Sentinel Dubbo Adapter has implemented a filter (`DubboAppContextFilter`)
57   -> where consumer can carry application name information to provider automatically.
58   -> If the consumer does not use Sentinel Dubbo Adapter but requires flow control based on caller,
59   -> developers can manually put the application name into attachment with the key `dubboApplication`.
60   ->
61   -> Since 1.8.0, the adapter provides support for customizing origin parsing logic. You may register your own `DubboOriginParser`
62   -> implementation to `DubboAdapterGlobalConfig`.
63   -
64   -## Global fallback
65   -
66   -Sentinel Dubbo Adapter supports global fallback configuration.
67   -The global fallback will handle exceptions and give replacement result when blocked by
68   -flow control, degrade or system load protection. You can implement your own `DubboFallback` interface
69   -and then register to `DubboAdapterGlobalConfig`.
70   -If no fallback is configured, Sentinel will wrap the `BlockException` as the fallback result.
71   -
72   -Besides, we can also leverage [Dubbo mock mechanism](http://dubbo.apache.org/en-us/docs/user/demos/local-mock.html) to provide fallback implementation of degraded Dubbo services.
73 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <parent>
6   - <artifactId>sentinel-adapter</artifactId>
7   - <groupId>com.alibaba.csp</groupId>
8   - <version>1.8.3</version>
9   - </parent>
10   - <modelVersion>4.0.0</modelVersion>
11   -
12   - <artifactId>sentinel-apache-dubbo-adapter</artifactId>
13   - <packaging>jar</packaging>
14   -
15   - <properties>
16   - <java.source.version>1.8</java.source.version>
17   - <java.target.version>1.8</java.target.version>
18   - <apache.dubbo.version>2.7.13</apache.dubbo.version>
19   - </properties>
20   -
21   - <dependencies>
22   - <dependency>
23   - <groupId>com.alibaba.csp</groupId>
24   - <artifactId>sentinel-core</artifactId>
25   - </dependency>
26   - <dependency>
27   - <groupId>org.apache.dubbo</groupId>
28   - <artifactId>dubbo</artifactId>
29   - <version>${apache.dubbo.version}</version>
30   - <scope>provided</scope>
31   - </dependency>
32   -
33   - <dependency>
34   - <groupId>junit</groupId>
35   - <artifactId>junit</artifactId>
36   - <scope>test</scope>
37   - </dependency>
38   -
39   - <dependency>
40   - <groupId>org.mockito</groupId>
41   - <artifactId>mockito-core</artifactId>
42   - <scope>test</scope>
43   - </dependency>
44   - <dependency>
45   - <groupId>com.alibaba</groupId>
46   - <artifactId>fastjson</artifactId>
47   - <scope>test</scope>
48   - </dependency>
49   - </dependencies>
50   -</project>
51 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -
19   -import org.apache.dubbo.rpc.Filter;
20   -import org.apache.dubbo.rpc.Invocation;
21   -import org.apache.dubbo.rpc.Invoker;
22   -
23   -/**
24   - * Base class of the {@link SentinelDubboProviderFilter} and {@link SentinelDubboConsumerFilter}.
25   - *
26   - * @author Zechao Zheng
27   - */
28   -public abstract class BaseSentinelDubboFilter implements Filter {
29   -
30   -
31   - /**
32   - * Get method name of dubbo rpc
33   - *
34   - * @param invoker
35   - * @param invocation
36   - * @return
37   - */
38   - abstract String getMethodName(Invoker invoker, Invocation invocation, String prefix);
39   -
40   - /**
41   - * Get interface name of dubbo rpc
42   - *
43   - * @param invoker
44   - * @return
45   - */
46   - abstract String getInterfaceName(Invoker invoker, String prefix);
47   -
48   -
49   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import org.apache.dubbo.common.constants.CommonConstants;
19   -import org.apache.dubbo.common.extension.Activate;
20   -import org.apache.dubbo.rpc.Filter;
21   -import org.apache.dubbo.rpc.Invocation;
22   -import org.apache.dubbo.rpc.Invoker;
23   -import org.apache.dubbo.rpc.Result;
24   -import org.apache.dubbo.rpc.RpcContext;
25   -import org.apache.dubbo.rpc.RpcException;
26   -
27   -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
28   -
29   -/**
30   - * Puts current consumer's application name in the attachment of each invocation.
31   - *
32   - * @author Eric Zhao
33   - */
34   -@Activate(group = CONSUMER)
35   -public class DubboAppContextFilter implements Filter {
36   -
37   - @Override
38   - public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
39   - String application = invoker.getUrl().getParameter(CommonConstants.APPLICATION_KEY);
40   - if (application != null) {
41   - RpcContext.getContext().setAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, application);
42   - }
43   - return invoker.invoke(invocation);
44   - }
45   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboUtils.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
19   -import com.alibaba.csp.sentinel.util.StringUtil;
20   -import org.apache.dubbo.rpc.Invocation;
21   -import org.apache.dubbo.rpc.Invoker;
22   -
23   -/**
24   - * @author Eric Zhao
25   - */
26   -public final class DubboUtils {
27   -
28   - public static final String SENTINEL_DUBBO_APPLICATION_KEY = "dubboApplication";
29   -
30   - public static String getApplication(Invocation invocation, String defaultValue) {
31   - if (invocation == null || invocation.getAttachments() == null) {
32   - throw new IllegalArgumentException("Bad invocation instance");
33   - }
34   - return invocation.getAttachment(SENTINEL_DUBBO_APPLICATION_KEY, defaultValue);
35   - }
36   -
37   - public static String getMethodResourceName(Invoker<?> invoker, Invocation invocation){
38   - return getMethodResourceName(invoker, invocation, false);
39   - }
40   -
41   - public static String getMethodResourceName(Invoker<?> invoker, Invocation invocation, Boolean useGroupAndVersion) {
42   - StringBuilder buf = new StringBuilder(64);
43   - String interfaceResource = useGroupAndVersion ? invoker.getUrl().getColonSeparatedKey() : invoker.getInterface().getName();
44   - buf.append(interfaceResource)
45   - .append(":")
46   - .append(invocation.getMethodName())
47   - .append("(");
48   - boolean isFirst = true;
49   - for (Class<?> clazz : invocation.getParameterTypes()) {
50   - if (!isFirst) {
51   - buf.append(",");
52   - }
53   - buf.append(clazz.getName());
54   - isFirst = false;
55   - }
56   - buf.append(")");
57   - return buf.toString();
58   - }
59   -
60   - public static String getMethodResourceName(Invoker<?> invoker, Invocation invocation, String prefix) {
61   - if (StringUtil.isNotBlank(prefix)) {
62   - return new StringBuilder(64)
63   - .append(prefix)
64   - .append(getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboInterfaceGroupAndVersionEnabled()))
65   - .toString();
66   - } else {
67   - return getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboInterfaceGroupAndVersionEnabled());
68   - }
69   - }
70   -
71   -
72   - public static String getInterfaceName(Invoker invoker) {
73   - return getInterfaceName(invoker, false);
74   - }
75   -
76   - public static String getInterfaceName(Invoker<?> invoker, Boolean useGroupAndVersion) {
77   - StringBuilder buf = new StringBuilder(64);
78   - return useGroupAndVersion ? invoker.getUrl().getColonSeparatedKey() : invoker.getInterface().getName();
79   - }
80   -
81   - public static String getInterfaceName(Invoker<?> invoker, String prefix) {
82   - if (StringUtil.isNotBlank(prefix)) {
83   - return new StringBuilder(64)
84   - .append(prefix)
85   - .append(getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboInterfaceGroupAndVersionEnabled()))
86   - .toString();
87   - } else {
88   - return getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboInterfaceGroupAndVersionEnabled());
89   - }
90   - }
91   -
92   -
93   - private DubboUtils() {
94   - }
95   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.*;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
20   -import com.alibaba.csp.sentinel.log.RecordLog;
21   -import com.alibaba.csp.sentinel.slots.block.BlockException;
22   -
23   -import org.apache.dubbo.common.extension.Activate;
24   -import org.apache.dubbo.rpc.*;
25   -import org.apache.dubbo.rpc.support.RpcUtils;
26   -
27   -import java.util.LinkedList;
28   -import java.util.Optional;
29   -import java.util.function.BiConsumer;
30   -
31   -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
32   -
33   -/**
34   - * <p>Dubbo service consumer filter for Sentinel. Auto activated by default.</p>
35   - * <p>
36   - * If you want to disable the consumer filter, you can configure:
37   - * <pre>
38   - * &lt;dubbo:consumer filter="-sentinel.dubbo.consumer.filter"/&gt;
39   - * </pre>
40   - *
41   - * @author Carpenter Lee
42   - * @author Eric Zhao
43   - * @author Lin Liang
44   - */
45   -@Activate(group = CONSUMER)
46   -public class SentinelDubboConsumerFilter extends BaseSentinelDubboFilter {
47   -
48   - public SentinelDubboConsumerFilter() {
49   - RecordLog.info("Sentinel Apache Dubbo consumer filter initialized");
50   - }
51   -
52   - @Override
53   - String getMethodName(Invoker invoker, Invocation invocation, String prefix) {
54   - return DubboUtils.getMethodResourceName(invoker, invocation, prefix);
55   - }
56   -
57   - @Override
58   - String getInterfaceName(Invoker invoker, String prefix) {
59   - return DubboUtils.getInterfaceName(invoker, prefix);
60   - }
61   -
62   - @Override
63   - public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
64   - InvokeMode invokeMode = RpcUtils.getInvokeMode(invoker.getUrl(), invocation);
65   - if (InvokeMode.SYNC == invokeMode) {
66   - return syncInvoke(invoker, invocation);
67   - } else {
68   - return asyncInvoke(invoker, invocation);
69   - }
70   - }
71   -
72   - private Result syncInvoke(Invoker<?> invoker, Invocation invocation) {
73   - Entry interfaceEntry = null;
74   - Entry methodEntry = null;
75   - String prefix = DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey();
76   - String interfaceResourceName = getInterfaceName(invoker, prefix);
77   - String methodResourceName = getMethodName(invoker, invocation, prefix);
78   - try {
79   - interfaceEntry = SphU.entry(interfaceResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.OUT);
80   - methodEntry = SphU.entry(methodResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.OUT,
81   - invocation.getArguments());
82   - Result result = invoker.invoke(invocation);
83   - if (result.hasException()) {
84   - Tracer.traceEntry(result.getException(), interfaceEntry);
85   - Tracer.traceEntry(result.getException(), methodEntry);
86   - }
87   - return result;
88   - } catch (BlockException e) {
89   - return DubboAdapterGlobalConfig.getConsumerFallback().handle(invoker, invocation, e);
90   - } catch (RpcException e) {
91   - Tracer.traceEntry(e, interfaceEntry);
92   - Tracer.traceEntry(e, methodEntry);
93   - throw e;
94   - } finally {
95   - if (methodEntry != null) {
96   - methodEntry.exit(1, invocation.getArguments());
97   - }
98   - if (interfaceEntry != null) {
99   - interfaceEntry.exit();
100   - }
101   - }
102   - }
103   -
104   - private Result asyncInvoke(Invoker<?> invoker, Invocation invocation) {
105   - LinkedList<EntryHolder> queue = new LinkedList<>();
106   - String prefix = DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey();
107   - String interfaceResourceName = getInterfaceName(invoker, prefix);
108   - String methodResourceName = getMethodName(invoker, invocation, prefix);
109   - try {
110   - queue.push(new EntryHolder(
111   - SphU.asyncEntry(interfaceResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.OUT), null));
112   - queue.push(new EntryHolder(
113   - SphU.asyncEntry(methodResourceName, ResourceTypeConstants.COMMON_RPC,
114   - EntryType.OUT, 1, invocation.getArguments()), invocation.getArguments()));
115   - Result result = invoker.invoke(invocation);
116   - result.whenCompleteWithContext((r, throwable) -> {
117   - Throwable error = throwable;
118   - if (error == null) {
119   - error = Optional.ofNullable(r).map(Result::getException).orElse(null);
120   - }
121   - while (!queue.isEmpty()) {
122   - EntryHolder holder = queue.pop();
123   - Tracer.traceEntry(error, holder.entry);
124   - exitEntry(holder);
125   - }
126   - });
127   - return result;
128   - } catch (BlockException e) {
129   - while (!queue.isEmpty()) {
130   - exitEntry(queue.pop());
131   - }
132   - return DubboAdapterGlobalConfig.getConsumerFallback().handle(invoker, invocation, e);
133   - }
134   - }
135   -
136   - static class EntryHolder {
137   -
138   - final private Entry entry;
139   - final private Object[] params;
140   -
141   - public EntryHolder(Entry entry, Object[] params) {
142   - this.entry = entry;
143   - this.params = params;
144   - }
145   - }
146   -
147   - private void exitEntry(EntryHolder holder) {
148   - if (holder.params != null) {
149   - holder.entry.exit(1, holder.params);
150   - } else {
151   - holder.entry.exit();
152   - }
153   - }
154   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.*;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
20   -import com.alibaba.csp.sentinel.context.ContextUtil;
21   -import com.alibaba.csp.sentinel.log.RecordLog;
22   -import com.alibaba.csp.sentinel.slots.block.BlockException;
23   -
24   -import org.apache.dubbo.common.extension.Activate;
25   -import org.apache.dubbo.rpc.Invocation;
26   -import org.apache.dubbo.rpc.Invoker;
27   -import org.apache.dubbo.rpc.Result;
28   -import org.apache.dubbo.rpc.RpcException;
29   -
30   -import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
31   -
32   -/**
33   - * <p>Apache Dubbo service provider filter that enables integration with Sentinel. Auto activated by default.</p>
34   - * <p>Note: this only works for Apache Dubbo 2.7.x or above version.</p>
35   - * <p>
36   - * If you want to disable the provider filter, you can configure:
37   - * <pre>
38   - * &lt;dubbo:provider filter="-sentinel.dubbo.provider.filter"/&gt;
39   - * </pre>
40   - *
41   - * @author Carpenter Lee
42   - * @author Eric Zhao
43   - */
44   -@Activate(group = PROVIDER)
45   -public class SentinelDubboProviderFilter extends BaseSentinelDubboFilter {
46   -
47   - public SentinelDubboProviderFilter() {
48   - RecordLog.info("Sentinel Apache Dubbo provider filter initialized");
49   - }
50   -
51   - @Override
52   - String getMethodName(Invoker invoker, Invocation invocation, String prefix) {
53   - return DubboUtils.getMethodResourceName(invoker, invocation, prefix);
54   - }
55   -
56   - @Override
57   - String getInterfaceName(Invoker invoker, String prefix) {
58   - return DubboUtils.getInterfaceName(invoker, prefix);
59   - }
60   -
61   - @Override
62   - public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
63   - // Get origin caller.
64   - String origin = DubboAdapterGlobalConfig.getOriginParser().parse(invoker, invocation);
65   - if (null == origin) {
66   - origin = "";
67   - }
68   - Entry interfaceEntry = null;
69   - Entry methodEntry = null;
70   - String prefix = DubboAdapterGlobalConfig.getDubboProviderResNamePrefixKey();
71   - String interfaceResourceName = getInterfaceName(invoker, prefix);
72   - String methodResourceName = getMethodName(invoker, invocation, prefix);
73   - try {
74   - // Only need to create entrance context at provider side, as context will take effect
75   - // at entrance of invocation chain only (for inbound traffic).
76   - ContextUtil.enter(methodResourceName, origin);
77   - interfaceEntry = SphU.entry(interfaceResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN);
78   - methodEntry = SphU.entry(methodResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN,
79   - invocation.getArguments());
80   - Result result = invoker.invoke(invocation);
81   - if (result.hasException()) {
82   - Tracer.traceEntry(result.getException(), interfaceEntry);
83   - Tracer.traceEntry(result.getException(), methodEntry);
84   - }
85   - return result;
86   - } catch (BlockException e) {
87   - return DubboAdapterGlobalConfig.getProviderFallback().handle(invoker, invocation, e);
88   - } catch (RpcException e) {
89   - Tracer.traceEntry(e, interfaceEntry);
90   - Tracer.traceEntry(e, methodEntry);
91   - throw e;
92   - } finally {
93   - if (methodEntry != null) {
94   - methodEntry.exit(1, invocation.getArguments());
95   - }
96   - if (interfaceEntry != null) {
97   - interfaceEntry.exit();
98   - }
99   - ContextUtil.exit();
100   - }
101   - }
102   -
103   -}
104   -
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/config/DubboAdapterGlobalConfig.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.config;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DefaultDubboFallback;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallback;
20   -import com.alibaba.csp.sentinel.adapter.dubbo.origin.DefaultDubboOriginParser;
21   -import com.alibaba.csp.sentinel.adapter.dubbo.origin.DubboOriginParser;
22   -import com.alibaba.csp.sentinel.config.SentinelConfig;
23   -import com.alibaba.csp.sentinel.util.AssertUtil;
24   -import com.alibaba.csp.sentinel.util.StringUtil;
25   -
26   -/**
27   - * <p>
28   - * Responsible for dubbo service provider, consumer attribute configuration
29   - * </p>
30   - *
31   - * @author lianglin
32   - * @since 1.7.0
33   - */
34   -public final class DubboAdapterGlobalConfig {
35   -
36   - private static final String TRUE_STR = "true";
37   -
38   - public static final String DUBBO_RES_NAME_WITH_PREFIX_KEY = "csp.sentinel.dubbo.resource.use.prefix";
39   - public static final String DUBBO_PROVIDER_RES_NAME_PREFIX_KEY = "csp.sentinel.dubbo.resource.provider.prefix";
40   - public static final String DUBBO_CONSUMER_RES_NAME_PREFIX_KEY = "csp.sentinel.dubbo.resource.consumer.prefix";
41   -
42   - private static final String DEFAULT_DUBBO_PROVIDER_PREFIX = "dubbo:provider:";
43   - private static final String DEFAULT_DUBBO_CONSUMER_PREFIX = "dubbo:consumer:";
44   -
45   - public static final String DUBBO_INTERFACE_GROUP_VERSION_ENABLED = "csp.sentinel.dubbo.interface.group.version.enabled";
46   -
47   - private static volatile DubboFallback consumerFallback = new DefaultDubboFallback();
48   - private static volatile DubboFallback providerFallback = new DefaultDubboFallback();
49   - private static volatile DubboOriginParser originParser = new DefaultDubboOriginParser();
50   -
51   - public static boolean isUsePrefix() {
52   - return TRUE_STR.equalsIgnoreCase(SentinelConfig.getConfig(DUBBO_RES_NAME_WITH_PREFIX_KEY));
53   - }
54   -
55   - public static String getDubboProviderResNamePrefixKey() {
56   - if (isUsePrefix()) {
57   - String config = SentinelConfig.getConfig(DUBBO_PROVIDER_RES_NAME_PREFIX_KEY);
58   - return StringUtil.isNotBlank(config) ? config : DEFAULT_DUBBO_PROVIDER_PREFIX;
59   - }
60   - return null;
61   - }
62   -
63   - public static String getDubboConsumerResNamePrefixKey() {
64   - if (isUsePrefix()) {
65   - String config = SentinelConfig.getConfig(DUBBO_CONSUMER_RES_NAME_PREFIX_KEY);
66   - return StringUtil.isNotBlank(config) ? config : DEFAULT_DUBBO_CONSUMER_PREFIX;
67   - }
68   - return null;
69   - }
70   -
71   - public static Boolean getDubboInterfaceGroupAndVersionEnabled() {
72   - return TRUE_STR.equalsIgnoreCase(SentinelConfig.getConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED));
73   - }
74   -
75   - public static DubboFallback getConsumerFallback() {
76   - return consumerFallback;
77   - }
78   -
79   - public static void setConsumerFallback(DubboFallback consumerFallback) {
80   - AssertUtil.notNull(consumerFallback, "consumerFallback cannot be null");
81   - DubboAdapterGlobalConfig.consumerFallback = consumerFallback;
82   - }
83   -
84   - public static DubboFallback getProviderFallback() {
85   - return providerFallback;
86   - }
87   -
88   - public static void setProviderFallback(DubboFallback providerFallback) {
89   - AssertUtil.notNull(providerFallback, "providerFallback cannot be null");
90   - DubboAdapterGlobalConfig.providerFallback = providerFallback;
91   - }
92   -
93   - /**
94   - * Get the origin parser of Dubbo adapter.
95   - *
96   - * @return the origin parser
97   - * @since 1.8.0
98   - */
99   - public static DubboOriginParser getOriginParser() {
100   - return originParser;
101   - }
102   -
103   - /**
104   - * Set the origin parser of Dubbo adapter.
105   - *
106   - * @param originParser the origin parser
107   - * @since 1.8.0
108   - */
109   - public static void setOriginParser(DubboOriginParser originParser) {
110   - AssertUtil.notNull(originParser, "originParser cannot be null");
111   - DubboAdapterGlobalConfig.originParser = originParser;
112   - }
113   -
114   - private DubboAdapterGlobalConfig() {}
115   -
116   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DefaultDubboFallback.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.fallback;
17   -
18   -import com.alibaba.csp.sentinel.slots.block.BlockException;
19   -
20   -import org.apache.dubbo.rpc.AsyncRpcResult;
21   -import org.apache.dubbo.rpc.Invocation;
22   -import org.apache.dubbo.rpc.Invoker;
23   -import org.apache.dubbo.rpc.Result;
24   -
25   -/**
26   - * @author Eric Zhao
27   - */
28   -public class DefaultDubboFallback implements DubboFallback {
29   -
30   - @Override
31   - public Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex) {
32   - // Just wrap the exception.
33   - return AsyncRpcResult.newDefaultAsyncResult(ex.toRuntimeException(), invocation);
34   - }
35   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallback.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.fallback;
17   -
18   -import com.alibaba.csp.sentinel.slots.block.BlockException;
19   -
20   -import org.apache.dubbo.rpc.Invocation;
21   -import org.apache.dubbo.rpc.Invoker;
22   -import org.apache.dubbo.rpc.Result;
23   -
24   -/**
25   - * Fallback handler for Dubbo services.
26   - *
27   - * @author Eric Zhao
28   - */
29   -@FunctionalInterface
30   -public interface DubboFallback {
31   -
32   - /**
33   - * Handle the block exception and provide fallback result.
34   - *
35   - * @param invoker Dubbo invoker
36   - * @param invocation Dubbo invocation
37   - * @param ex block exception
38   - * @return fallback result
39   - */
40   - Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex);
41   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistry.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.fallback;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
19   -
20   -/**
21   - * <p>Global fallback registry for Dubbo.</p>
22   - *
23   - * @author Eric Zhao
24   - * @deprecated use {@link DubboAdapterGlobalConfig} instead since 1.8.0.
25   - */
26   -@Deprecated
27   -public final class DubboFallbackRegistry {
28   -
29   - public static DubboFallback getConsumerFallback() {
30   - return DubboAdapterGlobalConfig.getConsumerFallback();
31   - }
32   -
33   - public static void setConsumerFallback(DubboFallback consumerFallback) {
34   - DubboAdapterGlobalConfig.setConsumerFallback(consumerFallback);
35   - }
36   -
37   - public static DubboFallback getProviderFallback() {
38   - return DubboAdapterGlobalConfig.getProviderFallback();
39   - }
40   -
41   - public static void setProviderFallback(DubboFallback providerFallback) {
42   - DubboAdapterGlobalConfig.setProviderFallback(providerFallback);
43   - }
44   -
45   - private DubboFallbackRegistry() {}
46   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/origin/DefaultDubboOriginParser.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * https://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.origin;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.DubboUtils;
19   -import org.apache.dubbo.rpc.Invocation;
20   -import org.apache.dubbo.rpc.Invoker;
21   -
22   -/**
23   - * Default Dubbo origin parser.
24   - *
25   - * @author jingzian
26   - */
27   -public class DefaultDubboOriginParser implements DubboOriginParser {
28   -
29   - @Override
30   - public String parse(Invoker<?> invoker, Invocation invocation) {
31   - return DubboUtils.getApplication(invocation, "");
32   - }
33   -
34   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/origin/DubboOriginParser.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * https://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.origin;
17   -
18   -import com.alibaba.csp.sentinel.context.Context;
19   -import org.apache.dubbo.rpc.Invocation;
20   -import org.apache.dubbo.rpc.Invoker;
21   -
22   -/**
23   - * Customized origin parser for Dubbo provider filter.{@link Context#getOrigin()}
24   - *
25   - * @author jingzian
26   - */
27   -public interface DubboOriginParser {
28   -
29   - /**
30   - * Parses the origin (caller) from Dubbo invocation.
31   - *
32   - * @param invoker Dubbo invoker
33   - * @param invocation Dubbo invocation
34   - * @return the parsed origin
35   - */
36   - String parse(Invoker<?> invoker, Invocation invocation);
37   -
38   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter deleted 100644 → 0
1   -sentinel.dubbo.provider.filter=com.alibaba.csp.sentinel.adapter.dubbo.SentinelDubboProviderFilter
2   -sentinel.dubbo.consumer.filter=com.alibaba.csp.sentinel.adapter.dubbo.SentinelDubboConsumerFilter
3   -dubbo.application.context.name.filter=com.alibaba.csp.sentinel.adapter.dubbo.DubboAppContextFilter
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/BaseTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DefaultDubboFallback;
20   -import com.alibaba.csp.sentinel.config.SentinelConfig;
21   -import com.alibaba.csp.sentinel.context.ContextUtil;
22   -import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
23   -import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
24   -import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot;
25   -import org.apache.dubbo.rpc.RpcContext;
26   -
27   -import java.lang.reflect.InvocationTargetException;
28   -import java.lang.reflect.Method;
29   -import java.util.ArrayList;
30   -
31   -/**
32   - * Base test class, provide common methods for subClass
33   - * The package is same as CtSph, to call CtSph.resetChainMap() method for test
34   - * <p>
35   - * Note: Only for test. DO NOT USE IN PRODUCTION!
36   - *
37   - * @author cdfive
38   - * @author lianglin
39   - */
40   -public class BaseTest {
41   -
42   -
43   - /**
44   - * Clean up resources for context, clusterNodeMap, processorSlotChainMap
45   - */
46   - public void cleanUpAll() {
47   - try {
48   - clearDubboContext();
49   - cleanUpCstContext();
50   - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
51   - e.printStackTrace();
52   - }
53   - }
54   -
55   - private void cleanUpCstContext() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
56   - ClusterBuilderSlot.getClusterNodeMap().clear();
57   - CtSph.resetChainMap();
58   - Method method = ContextUtil.class.getDeclaredMethod("resetContextMap");
59   - method.setAccessible(true);
60   - method.invoke(null, null);
61   - ContextUtil.exit();
62   - FlowRuleManager.loadRules(new ArrayList<>());
63   - DegradeRuleManager.loadRules(new ArrayList<>());
64   - }
65   -
66   - private void clearDubboContext() {
67   - SentinelConfig.setConfig("csp.sentinel.dubbo.resource.use.prefix", "false");
68   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_PROVIDER_RES_NAME_PREFIX_KEY, "");
69   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_CONSUMER_RES_NAME_PREFIX_KEY, "");
70   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
71   - DubboAdapterGlobalConfig.setConsumerFallback(new DefaultDubboFallback());
72   - RpcContext.removeContext();
73   -
74   - }
75   -}
76 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/DubboTestUtil.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService;
19   -import org.apache.dubbo.common.URL;
20   -import org.apache.dubbo.common.constants.CommonConstants;
21   -import org.apache.dubbo.rpc.Invocation;
22   -import org.apache.dubbo.rpc.Invoker;
23   -
24   -import java.lang.reflect.Method;
25   -
26   -import static org.mockito.Mockito.mock;
27   -import static org.mockito.Mockito.when;
28   -
29   -/**
30   - * @author lianglin
31   - */
32   -public class DubboTestUtil {
33   -
34   -
35   - public static Class<?> DEFAULT_TEST_SERVICE = DemoService.class;
36   - public static Method DEFAULT_TEST_METHOD_ONE = DEFAULT_TEST_SERVICE.getMethods()[0];
37   - public static Method DEFAULT_TEST_METHOD_TWO = DEFAULT_TEST_SERVICE.getMethods()[1];
38   -
39   - public static Invoker getMockInvoker(URL url, Class<?> cls) {
40   - Invoker invoker = mock(Invoker.class);
41   - when(invoker.getUrl()).thenReturn(url);
42   - when(invoker.getInterface()).thenReturn(cls);
43   - return invoker;
44   - }
45   -
46   - public static Invoker getDefaultMockInvoker() {
47   - return getMockInvoker(getDefaultTestURL(), DEFAULT_TEST_SERVICE);
48   - }
49   -
50   - public static Invocation getMockInvocation(Method method) {
51   - Invocation invocation = mock(Invocation.class);
52   - when(invocation.getMethodName()).thenReturn(method.getName());
53   - when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes());
54   - return invocation;
55   - }
56   -
57   - public static Invocation getDefaultMockInvocationOne() {
58   - Invocation invocation = mock(Invocation.class);
59   - when(invocation.getMethodName()).thenReturn(DEFAULT_TEST_METHOD_ONE.getName());
60   - when(invocation.getParameterTypes()).thenReturn(DEFAULT_TEST_METHOD_ONE.getParameterTypes());
61   - return invocation;
62   - }
63   -
64   - public static Invocation getDefaultMockInvocationTwo() {
65   - Invocation invocation = mock(Invocation.class);
66   - when(invocation.getMethodName()).thenReturn(DEFAULT_TEST_METHOD_TWO.getName());
67   - when(invocation.getParameterTypes()).thenReturn(DEFAULT_TEST_METHOD_TWO.getParameterTypes());
68   - return invocation;
69   - }
70   -
71   - public static URL getDefaultTestURL() {
72   - URL url = URL.valueOf("dubbo://127.0.0.1:2181")
73   - .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
74   - .addParameter(CommonConstants.GROUP_KEY, "grp1")
75   - .addParameter(CommonConstants.INTERFACE_KEY, DEFAULT_TEST_SERVICE.getName());
76   - return url;
77   - }
78   -
79   -
80   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.BaseTest;
19   -
20   -import org.apache.dubbo.common.URL;
21   -import org.apache.dubbo.rpc.Invocation;
22   -import org.apache.dubbo.rpc.Invoker;
23   -import org.apache.dubbo.rpc.RpcContext;
24   -import org.junit.After;
25   -import org.junit.Before;
26   -import org.junit.Test;
27   -
28   -import static org.junit.Assert.*;
29   -import static org.mockito.Mockito.*;
30   -
31   -/**
32   - * @author cdfive
33   - */
34   -public class DubboAppContextFilterTest extends BaseTest {
35   -
36   - private DubboAppContextFilter filter = new DubboAppContextFilter();
37   -
38   - @Before
39   - public void setUp() {
40   - cleanUpAll();
41   - }
42   -
43   - @After
44   - public void cleanUp() {
45   - cleanUpAll();
46   - }
47   -
48   - @Test
49   - public void testInvokeApplicationKey() {
50   - Invoker invoker = mock(Invoker.class);
51   - Invocation invocation = mock(Invocation.class);
52   - URL url = URL.valueOf("test://test:111/test?application=serviceA");
53   - when(invoker.getUrl()).thenReturn(url);
54   -
55   - filter.invoke(invoker, invocation);
56   - verify(invoker).invoke(invocation);
57   -
58   - String application = RpcContext.getContext().getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY);
59   - assertEquals("serviceA", application);
60   - }
61   -
62   - @Test
63   - public void testInvokeNullApplicationKey() {
64   - Invoker invoker = mock(Invoker.class);
65   - Invocation invocation = mock(Invocation.class);
66   - URL url = URL.valueOf("test://test:111/test?application=");
67   - when(invoker.getUrl()).thenReturn(url);
68   -
69   - filter.invoke(invoker, invocation);
70   - verify(invoker).invoke(invocation);
71   -
72   - String application = RpcContext.getContext().getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY);
73   - assertEquals(application, "");
74   - }
75   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboUtilsTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService;
20   -import com.alibaba.csp.sentinel.config.SentinelConfig;
21   -import org.apache.dubbo.common.URL;
22   -import org.apache.dubbo.common.constants.CommonConstants;
23   -import org.apache.dubbo.rpc.Invocation;
24   -import org.apache.dubbo.rpc.Invoker;
25   -import org.junit.After;
26   -import org.junit.Before;
27   -import org.junit.Test;
28   -
29   -import java.lang.reflect.Method;
30   -import java.util.HashMap;
31   -
32   -import static com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig.DUBBO_INTERFACE_GROUP_VERSION_ENABLED;
33   -import static org.junit.Assert.assertEquals;
34   -import static org.junit.Assert.fail;
35   -import static org.mockito.Mockito.*;
36   -
37   -/**
38   - * @author cdfive
39   - */
40   -public class DubboUtilsTest {
41   -
42   - @Before
43   - public void setUp() {
44   - SentinelConfig.setConfig("csp.sentinel.dubbo.resource.use.prefix", "true");
45   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_PROVIDER_RES_NAME_PREFIX_KEY, "");
46   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_CONSUMER_RES_NAME_PREFIX_KEY, "");
47   - SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
48   - }
49   -
50   -
51   - @After
52   - public void tearDown() {
53   - SentinelConfig.setConfig("csp.sentinel.dubbo.resource.use.prefix", "false");
54   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_PROVIDER_RES_NAME_PREFIX_KEY, "");
55   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_CONSUMER_RES_NAME_PREFIX_KEY, "");
56   - SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
57   - }
58   -
59   -
60   - @Test
61   - public void testGetApplication() {
62   - Invocation invocation = mock(Invocation.class);
63   - when(invocation.getAttachments()).thenReturn(new HashMap<>());
64   - when(invocation.getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, ""))
65   - .thenReturn("consumerA");
66   -
67   - String application = DubboUtils.getApplication(invocation, "");
68   - verify(invocation).getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, "");
69   -
70   - assertEquals("consumerA", application);
71   - }
72   -
73   - @Test(expected = IllegalArgumentException.class)
74   - public void testGetApplicationNoAttachments() {
75   - Invocation invocation = mock(Invocation.class);
76   - when(invocation.getAttachments()).thenReturn(null);
77   - when(invocation.getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, ""))
78   - .thenReturn("consumerA");
79   -
80   - DubboUtils.getApplication(invocation, "");
81   -
82   - fail("No attachments in invocation, IllegalArgumentException should be thrown!");
83   - }
84   -
85   - @Test
86   - public void testGetResourceName() throws NoSuchMethodException {
87   - Invoker invoker = mock(Invoker.class);
88   - when(invoker.getInterface()).thenReturn(DemoService.class);
89   -
90   - Invocation invocation = mock(Invocation.class);
91   - Method method = DemoService.class.getDeclaredMethod("sayHello", String.class, int.class);
92   - when(invocation.getMethodName()).thenReturn(method.getName());
93   - when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes());
94   -
95   - String resourceName = DubboUtils.getMethodResourceName(invoker, invocation);
96   -
97   - assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
98   -
99   - }
100   -
101   - @Test
102   - public void testGetResourceNameWithGroupAndVersion() throws NoSuchMethodException {
103   - Invoker invoker = mock(Invoker.class);
104   - URL url = URL.valueOf("dubbo://127.0.0.1:2181")
105   - .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
106   - .addParameter(CommonConstants.GROUP_KEY, "grp1")
107   - .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName());
108   - when(invoker.getUrl()).thenReturn(url);
109   - when(invoker.getInterface()).thenReturn(DemoService.class);
110   -
111   - Invocation invocation = mock(Invocation.class);
112   - Method method = DemoService.class.getDeclaredMethod("sayHello", String.class, int.class);
113   - when(invocation.getMethodName()).thenReturn(method.getName());
114   - when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes());
115   -
116   - String resourceNameUseGroupAndVersion = DubboUtils.getMethodResourceName(invoker, invocation, true);
117   -
118   - assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:1.0.0:grp1:sayHello(java.lang.String,int)", resourceNameUseGroupAndVersion);
119   - }
120   -
121   -
122   - @Test
123   - public void testGetResourceNameWithPrefix() throws NoSuchMethodException {
124   - Invoker invoker = mock(Invoker.class);
125   - when(invoker.getInterface()).thenReturn(DemoService.class);
126   -
127   - Invocation invocation = mock(Invocation.class);
128   - Method method = DemoService.class.getDeclaredMethod("sayHello", String.class, int.class);
129   - when(invocation.getMethodName()).thenReturn(method.getName());
130   - when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes());
131   -
132   - //test with default prefix
133   - String resourceName = DubboUtils.getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboProviderResNamePrefixKey());
134   - assertEquals("dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
135   - resourceName = DubboUtils.getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey());
136   - assertEquals("dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
137   -
138   -
139   - //test with custom prefix
140   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_PROVIDER_RES_NAME_PREFIX_KEY, "my:dubbo:provider:");
141   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_CONSUMER_RES_NAME_PREFIX_KEY, "my:dubbo:consumer:");
142   - resourceName = DubboUtils.getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboProviderResNamePrefixKey());
143   - assertEquals("my:dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
144   - resourceName = DubboUtils.getMethodResourceName(invoker, invocation, DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey());
145   - assertEquals("my:dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
146   -
147   - }
148   -
149   - @Test
150   - public void testGetInterfaceName() {
151   -
152   - URL url = URL.valueOf("dubbo://127.0.0.1:2181")
153   - .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
154   - .addParameter(CommonConstants.GROUP_KEY, "grp1")
155   - .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName());
156   - Invoker invoker = mock(Invoker.class);
157   - when(invoker.getUrl()).thenReturn(url);
158   - when(invoker.getInterface()).thenReturn(DemoService.class);
159   -
160   - SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
161   - assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", DubboUtils.getInterfaceName(invoker));
162   -
163   - }
164   -
165   - @Test
166   - public void testGetInterfaceNameWithGroupAndVersion() throws NoSuchMethodException {
167   -
168   - URL url = URL.valueOf("dubbo://127.0.0.1:2181")
169   - .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
170   - .addParameter(CommonConstants.GROUP_KEY, "grp1")
171   - .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName());
172   - Invoker invoker = mock(Invoker.class);
173   - when(invoker.getUrl()).thenReturn(url);
174   - when(invoker.getInterface()).thenReturn(DemoService.class);
175   -
176   - SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "true");
177   - assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:1.0.0:grp1", DubboUtils.getInterfaceName(invoker, true));
178   - }
179   -
180   - @Test
181   - public void testGetInterfaceNameWithPrefix() throws NoSuchMethodException {
182   - URL url = URL.valueOf("dubbo://127.0.0.1:2181")
183   - .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
184   - .addParameter(CommonConstants.GROUP_KEY, "grp1")
185   - .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName());
186   - Invoker invoker = mock(Invoker.class);
187   - when(invoker.getUrl()).thenReturn(url);
188   - when(invoker.getInterface()).thenReturn(DemoService.class);
189   -
190   -
191   - //test with default prefix
192   - String resourceName = DubboUtils.getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboProviderResNamePrefixKey());
193   - assertEquals("dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", resourceName);
194   - resourceName = DubboUtils.getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey());
195   - assertEquals("dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", resourceName);
196   -
197   -
198   - //test with custom prefix
199   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_PROVIDER_RES_NAME_PREFIX_KEY, "my:dubbo:provider:");
200   - SentinelConfig.setConfig(DubboAdapterGlobalConfig.DUBBO_CONSUMER_RES_NAME_PREFIX_KEY, "my:dubbo:consumer:");
201   - resourceName = DubboUtils.getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboProviderResNamePrefixKey());
202   - assertEquals("my:dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", resourceName);
203   - resourceName = DubboUtils.getInterfaceName(invoker, DubboAdapterGlobalConfig.getDubboConsumerResNamePrefixKey());
204   - assertEquals("my:dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", resourceName);
205   -
206   - }
207   -}
208 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilterTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.BaseTest;
19   -import com.alibaba.csp.sentinel.DubboTestUtil;
20   -import com.alibaba.csp.sentinel.Entry;
21   -import com.alibaba.csp.sentinel.EntryType;
22   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
23   -import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallback;
24   -import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallbackRegistry;
25   -import com.alibaba.csp.sentinel.context.Context;
26   -import com.alibaba.csp.sentinel.context.ContextUtil;
27   -import com.alibaba.csp.sentinel.node.ClusterNode;
28   -import com.alibaba.csp.sentinel.node.DefaultNode;
29   -import com.alibaba.csp.sentinel.node.Node;
30   -import com.alibaba.csp.sentinel.node.StatisticNode;
31   -import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;
32   -import com.alibaba.csp.sentinel.slots.block.BlockException;
33   -import com.alibaba.csp.sentinel.slots.block.RuleConstant;
34   -import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
35   -import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
36   -import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
37   -import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
38   -
39   -import org.apache.dubbo.rpc.*;
40   -import org.apache.dubbo.rpc.support.RpcUtils;
41   -import org.junit.After;
42   -import org.junit.Before;
43   -import org.junit.Test;
44   -
45   -import java.util.*;
46   -
47   -import static com.alibaba.csp.sentinel.slots.block.RuleConstant.DEGRADE_GRADE_EXCEPTION_RATIO;
48   -import static org.apache.dubbo.rpc.Constants.ASYNC_KEY;
49   -import static org.junit.Assert.*;
50   -import static org.mockito.Mockito.*;
51   -
52   -/**
53   - * @author cdfive
54   - * @author lianglin
55   - */
56   -public class SentinelDubboConsumerFilterTest extends BaseTest {
57   -
58   - private final SentinelDubboConsumerFilter consumerFilter = new SentinelDubboConsumerFilter();
59   -
60   - @Before
61   - public void setUp() {
62   - cleanUpAll();
63   - initFallback();
64   - }
65   -
66   - @After
67   - public void destroy() {
68   - cleanUpAll();
69   - }
70   -
71   - @Test
72   - public void testInterfaceLevelFollowControlAsync() throws InterruptedException {
73   -
74   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
75   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
76   -
77   - when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString());
78   - initFlowRule(DubboUtils.getInterfaceName(invoker));
79   -
80   - Result result1 = invokeDubboRpc(false, invoker, invocation);
81   - assertEquals("normal", result1.getValue());
82   -
83   - // should fallback because the qps > 1
84   - Result result2 = invokeDubboRpc(false, invoker, invocation);
85   - assertEquals("fallback", result2.getValue());
86   -
87   - // sleeping 1000 ms to reset qps
88   - Thread.sleep(1000);
89   - Result result3 = invokeDubboRpc(false, invoker, invocation);
90   - assertEquals("normal", result3.getValue());
91   -
92   - verifyInvocationStructureForCallFinish(invoker, invocation);
93   - }
94   -
95   - @Test
96   - public void testDegradeAsync() throws InterruptedException {
97   -
98   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
99   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
100   -
101   - when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString());
102   - initDegradeRule(DubboUtils.getInterfaceName(invoker));
103   -
104   - Result result = invokeDubboRpc(false, invoker, invocation);
105   - verifyInvocationStructureForCallFinish(invoker, invocation);
106   - assertEquals("normal", result.getValue());
107   -
108   - // inc the clusterNode's exception to trigger the fallback
109   - for (int i = 0; i < 5; i++) {
110   - invokeDubboRpc(true, invoker, invocation);
111   - verifyInvocationStructureForCallFinish(invoker, invocation);
112   - }
113   -
114   - Result result2 = invokeDubboRpc(false, invoker, invocation);
115   - assertEquals("fallback", result2.getValue());
116   -
117   - // sleeping 1000 ms to reset exception
118   - Thread.sleep(1000);
119   - Result result3 = invokeDubboRpc(false, invoker, invocation);
120   - assertEquals("normal", result3.getValue());
121   -
122   - Context context = ContextUtil.getContext();
123   - assertNull(context);
124   - }
125   -
126   - @Test
127   - public void testDegradeSync() throws InterruptedException {
128   -
129   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
130   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
131   - initDegradeRule(DubboUtils.getInterfaceName(invoker));
132   -
133   - Result result = invokeDubboRpc(false, invoker, invocation);
134   - verifyInvocationStructureForCallFinish(invoker, invocation);
135   - assertEquals("normal", result.getValue());
136   -
137   - // inc the clusterNode's exception to trigger the fallback
138   - for (int i = 0; i < 5; i++) {
139   - invokeDubboRpc(true, invoker, invocation);
140   - verifyInvocationStructureForCallFinish(invoker, invocation);
141   - }
142   -
143   - Result result2 = invokeDubboRpc(false, invoker, invocation);
144   - assertEquals("fallback", result2.getValue());
145   -
146   - // sleeping 1000 ms to reset exception
147   - Thread.sleep(1000);
148   - Result result3 = invokeDubboRpc(false, invoker, invocation);
149   - assertEquals("normal", result3.getValue());
150   -
151   - Context context = ContextUtil.getContext();
152   - assertNull(context);
153   - }
154   -
155   - @Test
156   - public void testMethodFlowControlAsync() {
157   -
158   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
159   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
160   -
161   - when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString());
162   - initFlowRule(consumerFilter.getMethodName(invoker, invocation, null));
163   - invokeDubboRpc(false, invoker, invocation);
164   - invokeDubboRpc(false, invoker, invocation);
165   -
166   - Invocation invocation2 = DubboTestUtil.getDefaultMockInvocationTwo();
167   - Result result2 = invokeDubboRpc(false, invoker, invocation2);
168   - verifyInvocationStructureForCallFinish(invoker, invocation2);
169   - assertEquals("normal", result2.getValue());
170   -
171   - // the method of invocation should be blocked
172   - Result fallback = invokeDubboRpc(false, invoker, invocation);
173   - assertEquals("fallback", fallback.getValue());
174   - verifyInvocationStructureForCallFinish(invoker, invocation);
175   -
176   - }
177   -
178   - @Test
179   - public void testInvokeAsync() {
180   -
181   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
182   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
183   -
184   - when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString());
185   - final Result result = mock(Result.class);
186   - when(result.hasException()).thenReturn(false);
187   - when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> {
188   - verifyInvocationStructureForAsyncCall(invoker, invocation);
189   - return result;
190   - });
191   - consumerFilter.invoke(invoker, invocation);
192   - verify(invoker).invoke(invocation);
193   -
194   - Context context = ContextUtil.getContext();
195   - assertNotNull(context);
196   - }
197   -
198   - @Test
199   - public void testInvokeSync() {
200   -
201   - Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne();
202   - Invoker invoker = DubboTestUtil.getDefaultMockInvoker();
203   -
204   - final Result result = mock(Result.class);
205   - when(result.hasException()).thenReturn(false);
206   - when(result.getException()).thenReturn(new Exception());
207   - when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> {
208   - verifyInvocationStructure(invoker, invocation);
209   - return result;
210   - });
211   -
212   - consumerFilter.invoke(invoker, invocation);
213   - verify(invoker).invoke(invocation);
214   -
215   - Context context = ContextUtil.getContext();
216   - assertNull(context);
217   - }
218   -
219   - /**
220   - * Simply verify invocation structure in memory:
221   - * EntranceNode(defaultContextName)
222   - * --InterfaceNode(interfaceName)
223   - * ----MethodNode(resourceName)
224   - */
225   - private void verifyInvocationStructure(Invoker invoker, Invocation invocation) {
226   - Context context = ContextUtil.getContext();
227   - assertNotNull(context);
228   - // As not call ContextUtil.enter(resourceName, application) in SentinelDubboConsumerFilter, use default context
229   - // In actual project, a consumer is usually also a provider, the context will be created by
230   - //SentinelDubboProviderFilter
231   - // If consumer is on the top of Dubbo RPC invocation chain, use default context
232   - String resourceName = consumerFilter.getMethodName(invoker, invocation, null);
233   - assertEquals(com.alibaba.csp.sentinel.Constants.CONTEXT_DEFAULT_NAME, context.getName());
234   - assertEquals("", context.getOrigin());
235   -
236   - DefaultNode entranceNode = context.getEntranceNode();
237   - ResourceWrapper entranceResource = entranceNode.getId();
238   -
239   - assertEquals(com.alibaba.csp.sentinel.Constants.CONTEXT_DEFAULT_NAME, entranceResource.getName());
240   - assertSame(EntryType.IN, entranceResource.getEntryType());
241   -
242   - // As SphU.entry(interfaceName, EntryType.OUT);
243   - Set<Node> childList = entranceNode.getChildList();
244   - assertEquals(1, childList.size());
245   - DefaultNode interfaceNode = getNode(DubboUtils.getInterfaceName(invoker), entranceNode);
246   - ResourceWrapper interfaceResource = interfaceNode.getId();
247   -
248   - assertEquals(DubboUtils.getInterfaceName(invoker), interfaceResource.getName());
249   - assertSame(EntryType.OUT, interfaceResource.getEntryType());
250   -
251   - // As SphU.entry(resourceName, EntryType.OUT);
252   - childList = interfaceNode.getChildList();
253   - assertEquals(1, childList.size());
254   - DefaultNode methodNode = getNode(resourceName, entranceNode);
255   - ResourceWrapper methodResource = methodNode.getId();
256   - assertEquals(resourceName, methodResource.getName());
257   - assertSame(EntryType.OUT, methodResource.getEntryType());
258   -
259   - // Verify curEntry
260   - Entry curEntry = context.getCurEntry();
261   - assertSame(methodNode, curEntry.getCurNode());
262   - assertSame(interfaceNode, curEntry.getLastNode());
263   - assertNull(curEntry.getOriginNode());// As context origin is not "", no originNode should be created in curEntry
264   -
265   - // Verify clusterNode
266   - ClusterNode methodClusterNode = methodNode.getClusterNode();
267   - ClusterNode interfaceClusterNode = interfaceNode.getClusterNode();
268   - assertNotSame(methodClusterNode,
269   - interfaceClusterNode);// Different resource->Different ProcessorSlot->Different ClusterNode
270   -
271   - // As context origin is "", the StatisticNode should not be created in originCountMap of ClusterNode
272   - Map<String, StatisticNode> methodOriginCountMap = methodClusterNode.getOriginCountMap();
273   - assertEquals(0, methodOriginCountMap.size());
274   -
275   - Map<String, StatisticNode> interfaceOriginCountMap = interfaceClusterNode.getOriginCountMap();
276   - assertEquals(0, interfaceOriginCountMap.size());
277   - }
278   -
279   - private void verifyInvocationStructureForAsyncCall(Invoker invoker, Invocation invocation) {
280   - Context context = ContextUtil.getContext();
281   - assertNotNull(context);
282   -
283   - // As not call ContextUtil.enter(resourceName, application) in SentinelDubboConsumerFilter, use default context
284   - // In actual project, a consumer is usually also a provider, the context will be created by
285   - //SentinelDubboProviderFilter
286   - // If consumer is on the top of Dubbo RPC invocation chain, use default context
287   - String resourceName = consumerFilter.getMethodName(invoker, invocation, null);
288   - assertEquals(com.alibaba.csp.sentinel.Constants.CONTEXT_DEFAULT_NAME, context.getName());
289   - assertEquals("", context.getOrigin());
290   -
291   - DefaultNode entranceNode = context.getEntranceNode();
292   - ResourceWrapper entranceResource = entranceNode.getId();
293   - assertEquals(com.alibaba.csp.sentinel.Constants.CONTEXT_DEFAULT_NAME, entranceResource.getName());
294   - assertSame(EntryType.IN, entranceResource.getEntryType());
295   -
296   - // As SphU.entry(interfaceName, EntryType.OUT);
297   - Set<Node> childList = entranceNode.getChildList();
298   - assertEquals(2, childList.size());
299   - DefaultNode interfaceNode = getNode(DubboUtils.getInterfaceName(invoker), entranceNode);
300   - ResourceWrapper interfaceResource = interfaceNode.getId();
301   - assertEquals(DubboUtils.getInterfaceName(invoker), interfaceResource.getName());
302   - assertSame(EntryType.OUT, interfaceResource.getEntryType());
303   -
304   - // As SphU.entry(resourceName, EntryType.OUT);
305   - childList = interfaceNode.getChildList();
306   - assertEquals(0, childList.size());
307   - DefaultNode methodNode = getNode(resourceName, entranceNode);
308   - ResourceWrapper methodResource = methodNode.getId();
309   - assertEquals(resourceName, methodResource.getName());
310   - assertSame(EntryType.OUT, methodResource.getEntryType());
311   -
312   - // Verify curEntry
313   - // nothing will bind to local context when use the AsyncEntry
314   - Entry curEntry = context.getCurEntry();
315   - assertNull(curEntry);
316   -
317   - // Verify clusterNode
318   - ClusterNode methodClusterNode = methodNode.getClusterNode();
319   - ClusterNode interfaceClusterNode = interfaceNode.getClusterNode();
320   - assertNotSame(methodClusterNode,
321   - interfaceClusterNode);// Different resource->Different ProcessorSlot->Different ClusterNode
322   -
323   - // As context origin is "", the StatisticNode should not be created in originCountMap of ClusterNode
324   - Map<String, StatisticNode> methodOriginCountMap = methodClusterNode.getOriginCountMap();
325   - assertEquals(0, methodOriginCountMap.size());
326   -
327   - Map<String, StatisticNode> interfaceOriginCountMap = interfaceClusterNode.getOriginCountMap();
328   - assertEquals(0, interfaceOriginCountMap.size());
329   - }
330   -
331   - private void verifyInvocationStructureForCallFinish(Invoker invoker, Invocation invocation) {
332   - Context context = ContextUtil.getContext();
333   - assertNull(context);
334   - String methodResourceName = consumerFilter.getMethodName(invoker, invocation, null);
335   - Entry[] entries = (Entry[]) RpcContext.getContext().get(methodResourceName);
336   - assertNull(entries);
337   - }
338   -
339   - private DefaultNode getNode(String resourceName, DefaultNode root) {
340   -
341   - Queue<DefaultNode> queue = new LinkedList<>();
342   - queue.offer(root);
343   - while (!queue.isEmpty()) {
344   - DefaultNode temp = queue.poll();
345   - if (temp.getId().getName().equals(resourceName)) {
346   - return temp;
347   - }
348   - for (Node node : temp.getChildList()) {
349   - queue.offer((DefaultNode) node);
350   - }
351   - }
352   - return null;
353   - }
354   -
355   - private void initFlowRule(String resource) {
356   - FlowRule flowRule = new FlowRule(resource);
357   - flowRule.setCount(1);
358   - flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
359   - List<FlowRule> flowRules = new ArrayList<>();
360   - flowRules.add(flowRule);
361   - FlowRuleManager.loadRules(flowRules);
362   - }
363   -
364   - private void initDegradeRule(String resource) {
365   - DegradeRule degradeRule = new DegradeRule(resource)
366   - .setCount(0.5)
367   - .setGrade(DEGRADE_GRADE_EXCEPTION_RATIO);
368   - List<DegradeRule> degradeRules = new ArrayList<>();
369   - degradeRules.add(degradeRule);
370   - degradeRule.setTimeWindow(1);
371   - DegradeRuleManager.loadRules(degradeRules);
372   - }
373   -
374   - private void initFallback() {
375   - DubboAdapterGlobalConfig.setConsumerFallback((invoker, invocation, ex) -> {
376   - // boolean async = RpcUtils.isAsync(invoker.getUrl(), invocation);
377   - return AsyncRpcResult.newDefaultAsyncResult("fallback", invocation);
378   - });
379   - }
380   -
381   - private Result invokeDubboRpc(boolean exception, Invoker invoker, Invocation invocation) {
382   - Result result = null;
383   - InvokeMode invokeMode = RpcUtils.getInvokeMode(invoker.getUrl(), invocation);
384   - if (InvokeMode.SYNC == invokeMode) {
385   - result = exception ? new AppResponse(new Exception("error")) : new AppResponse("normal");
386   - } else {
387   - result = exception ? AsyncRpcResult.newDefaultAsyncResult(new Exception("error"), invocation)
388   - : AsyncRpcResult.newDefaultAsyncResult("normal", invocation);
389   - }
390   - when(invoker.invoke(invocation)).thenReturn(result);
391   - return consumerFilter.invoke(invoker, invocation);
392   - }
393   -
394   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilterTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo;
17   -
18   -import com.alibaba.csp.sentinel.BaseTest;
19   -import com.alibaba.csp.sentinel.DubboTestUtil;
20   -import com.alibaba.csp.sentinel.Entry;
21   -import com.alibaba.csp.sentinel.EntryType;
22   -import com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService;
23   -import com.alibaba.csp.sentinel.context.Context;
24   -import com.alibaba.csp.sentinel.context.ContextUtil;
25   -import com.alibaba.csp.sentinel.node.ClusterNode;
26   -import com.alibaba.csp.sentinel.node.DefaultNode;
27   -import com.alibaba.csp.sentinel.node.Node;
28   -import com.alibaba.csp.sentinel.node.StatisticNode;
29   -import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;
30   -import org.apache.dubbo.common.URL;
31   -import org.apache.dubbo.common.constants.CommonConstants;
32   -import org.apache.dubbo.rpc.Invocation;
33   -import org.apache.dubbo.rpc.Invoker;
34   -import org.apache.dubbo.rpc.Result;
35   -import org.junit.After;
36   -import org.junit.Before;
37   -import org.junit.Test;
38   -
39   -import java.util.Map;
40   -import java.util.Set;
41   -
42   -import static org.junit.Assert.*;
43   -import static org.mockito.Mockito.*;
44   -
45   -/**
46   - * @author cdfive
47   - * @author lianglin
48   - */
49   -public class SentinelDubboProviderFilterTest extends BaseTest {
50   -
51   -
52   - private SentinelDubboProviderFilter filter = new SentinelDubboProviderFilter();
53   -
54   -
55   - @Before
56   - public void setUp() {
57   - cleanUpAll();
58   - }
59   -
60   - @After
61   - public void destroy() {
62   - cleanUpAll();
63   - }
64   -
65   - @Test
66   - public void testInvoke() {
67   -
68   - final String originApplication = "consumerA";
69   -
70   - URL url = DubboTestUtil.getDefaultTestURL();
71   - url = url.addParameter(CommonConstants.SIDE_KEY, CommonConstants.PROVIDER_SIDE);
72   - Invoker invoker = DubboTestUtil.getMockInvoker(url, DemoService.class);
73   -
74   - Invocation invocation = DubboTestUtil.getMockInvocation(DemoService.class.getMethods()[0]);
75   - when(invocation.getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, ""))
76   - .thenReturn(originApplication);
77   -
78   - final Result result = mock(Result.class);
79   - when(result.hasException()).thenReturn(false);
80   - when(result.getException()).thenReturn(new Exception());
81   -
82   - when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> {
83   - verifyInvocationStructure(originApplication, invoker, invocation);
84   - return result;
85   - });
86   -
87   - filter.invoke(invoker, invocation);
88   - verify(invoker).invoke(invocation);
89   -
90   - Context context = ContextUtil.getContext();
91   - assertNull(context);
92   - }
93   -
94   - /**
95   - * Simply verify invocation structure in memory:
96   - * EntranceNode(methodResourceName)
97   - * --InterfaceNode(interfaceName)
98   - * ----MethodNode(methodResourceName)
99   - */
100   - private void verifyInvocationStructure(String originApplication, Invoker invoker, Invocation invocation) {
101   - Context context = ContextUtil.getContext();
102   - assertNotNull(context);
103   -
104   - // As ContextUtil.enter(resourceName, application) in SentinelDubboProviderFilter
105   - String methodResourceName = filter.getMethodName(invoker, invocation, null);
106   - assertEquals(methodResourceName, context.getName());
107   - assertEquals(originApplication, context.getOrigin());
108   -
109   - DefaultNode entranceNode = context.getEntranceNode();
110   - ResourceWrapper entranceResource = entranceNode.getId();
111   - assertEquals(methodResourceName, entranceResource.getName());
112   - assertSame(EntryType.IN, entranceResource.getEntryType());
113   -
114   - // As SphU.entry(interfaceName, EntryType.IN);
115   - Set<Node> childList = entranceNode.getChildList();
116   - assertEquals(1, childList.size());
117   - DefaultNode interfaceNode = (DefaultNode) childList.iterator().next();
118   - ResourceWrapper interfaceResource = interfaceNode.getId();
119   -
120   - assertEquals(filter.getInterfaceName(invoker, null), interfaceResource.getName());
121   - assertSame(EntryType.IN, interfaceResource.getEntryType());
122   -
123   - // As SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments());
124   - childList = interfaceNode.getChildList();
125   - assertEquals(1, childList.size());
126   - DefaultNode methodNode = (DefaultNode) childList.iterator().next();
127   - ResourceWrapper methodResource = methodNode.getId();
128   - assertEquals(methodResourceName, methodResource.getName());
129   - assertSame(EntryType.IN, methodResource.getEntryType());
130   -
131   - // Verify curEntry
132   - Entry curEntry = context.getCurEntry();
133   - assertSame(methodNode, curEntry.getCurNode());
134   - assertSame(interfaceNode, curEntry.getLastNode());
135   - assertNotNull(curEntry.getOriginNode());// As context origin is not "", originNode should be created
136   -
137   - // Verify clusterNode
138   - ClusterNode methodClusterNode = methodNode.getClusterNode();
139   - ClusterNode interfaceClusterNode = interfaceNode.getClusterNode();
140   - assertNotSame(methodClusterNode, interfaceClusterNode);// Different resource->Different ProcessorSlot->Different ClusterNode
141   -
142   - // As context origin is not "", the StatisticNode should be created in originCountMap of ClusterNode
143   - Map<String, StatisticNode> methodOriginCountMap = methodClusterNode.getOriginCountMap();
144   - assertEquals(1, methodOriginCountMap.size());
145   - assertTrue(methodOriginCountMap.containsKey(originApplication));
146   -
147   - Map<String, StatisticNode> interfaceOriginCountMap = interfaceClusterNode.getOriginCountMap();
148   - assertEquals(1, interfaceOriginCountMap.size());
149   - assertTrue(interfaceOriginCountMap.containsKey(originApplication));
150   - }
151   -
152   -
153   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistryTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.fallback;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
19   -import com.alibaba.csp.sentinel.slots.block.BlockException;
20   -import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
21   -
22   -import org.apache.dubbo.rpc.AsyncRpcResult;
23   -import org.apache.dubbo.rpc.Result;
24   -import org.junit.After;
25   -import org.junit.Assert;
26   -import org.junit.Before;
27   -import org.junit.Test;
28   -
29   -/**
30   - * @author Eric Zhao
31   - */
32   -public class DubboFallbackRegistryTest {
33   -
34   - @Before
35   - public void setUp() {
36   - DubboAdapterGlobalConfig.setConsumerFallback(new DefaultDubboFallback());
37   - }
38   -
39   - @After
40   - public void tearDown() {
41   - DubboAdapterGlobalConfig.setConsumerFallback(new DefaultDubboFallback());
42   - }
43   -
44   - @Test
45   - public void testDefaultFallback() {
46   - // Test for default fallback.
47   - BlockException ex = new FlowException("xxx");
48   - Result result = new DefaultDubboFallback().handle(null, null, ex);
49   - Assert.assertTrue("The result should carry exception", result.hasException());
50   - Assert.assertTrue(BlockException.isBlockException(result.getException()));
51   - Assert.assertTrue(result.getException().getMessage().contains(ex.getClass().getSimpleName()));
52   - }
53   -
54   - @Test
55   - public void testCustomFallback() {
56   - BlockException ex = new FlowException("xxx");
57   - DubboAdapterGlobalConfig.setConsumerFallback(
58   - (invoker, invocation, e) -> AsyncRpcResult
59   - .newDefaultAsyncResult("Error: " + e.getClass().getName(), invocation));
60   - Result result = DubboAdapterGlobalConfig.getConsumerFallback()
61   - .handle(null, null, ex);
62   - Assert.assertFalse("The invocation should not fail", result.hasException());
63   - Assert.assertEquals("Error: " + ex.getClass().getName(), result.getValue());
64   - }
65   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/origin/DubboOriginRegistryTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * https://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.origin;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.DubboUtils;
19   -import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboAdapterGlobalConfig;
20   -import com.alibaba.dubbo.rpc.RpcInvocation;
21   -import org.apache.dubbo.rpc.Invocation;
22   -import org.apache.dubbo.rpc.Invoker;
23   -import org.junit.After;
24   -import org.junit.Assert;
25   -import org.junit.Test;
26   -
27   -/**
28   - * @author tiecheng
29   - */
30   -public class DubboOriginRegistryTest {
31   -
32   - @After
33   - public void cleanUp() {
34   - DubboAdapterGlobalConfig.setOriginParser(new DefaultDubboOriginParser());
35   - }
36   -
37   - @Test(expected = IllegalArgumentException.class)
38   - public void testDefaultOriginParserFail() {
39   - DubboAdapterGlobalConfig.getOriginParser().parse(null, null);
40   - }
41   -
42   - @Test
43   - public void testDefaultOriginParserSuccess() {
44   - RpcInvocation invocation = new RpcInvocation();
45   - String dubboName = "sentinel";
46   - invocation.setAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, dubboName);
47   - String origin = DubboAdapterGlobalConfig.getOriginParser().parse(null, invocation);
48   - Assert.assertEquals(dubboName, origin);
49   - }
50   -
51   - @Test
52   - public void testCustomOriginParser() {
53   - DubboAdapterGlobalConfig.setOriginParser(new DubboOriginParser() {
54   - @Override
55   - public String parse(Invoker<?> invoker, Invocation invocation) {
56   - return invocation.getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, "default") + "_" + invocation
57   - .getMethodName();
58   - }
59   - });
60   -
61   - RpcInvocation invocation = new RpcInvocation();
62   - String origin = DubboAdapterGlobalConfig.getOriginParser().parse(null, invocation);
63   - Assert.assertEquals("default_null", origin);
64   -
65   - String dubboName = "sentinel";
66   - invocation.setAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, dubboName);
67   - origin = DubboAdapterGlobalConfig.getOriginParser().parse(null, invocation);
68   - Assert.assertEquals(dubboName + "_null", origin);
69   -
70   - invocation.setMethodName("hello");
71   - origin = DubboAdapterGlobalConfig.getOriginParser().parse(null, invocation);
72   - Assert.assertEquals(dubboName + "_hello", origin);
73   - }
74   -
75   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/provider/DemoService.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.provider;
17   -
18   -/**
19   - * @author leyou
20   - */
21   -public interface DemoService {
22   - String sayHello(String name, int n);
23   - String sayHi(String name,int n);
24   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/provider/impl/DemoServiceImpl.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2018 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.dubbo.provider.impl;
17   -
18   -import com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService;
19   -
20   -/**
21   - * @author leyou
22   - */
23   -public class DemoServiceImpl implements DemoService {
24   - public String sayHello(String name, int n) {
25   - return "Hello " + name + ", " + n;
26   - }
27   -
28   - @Override
29   - public String sayHi(String name, int n) {
30   - return "Hi " + name + ", " + n;
31   - }
32   -}
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/resources/spring-dubbo-consumer-filter.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<beans xmlns="http://www.springframework.org/schema/beans"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
5   - xsi:schemaLocation="http://www.springframework.org/schema/beans
6   - http://www.springframework.org/schema/beans/spring-beans.xsd
7   - http://code.alibabatech.com/schema/dubbo
8   - http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
9   -
10   - <dubbo:application name="demo-consumer"/>
11   - <dubbo:registry address="multicast://224.5.6.7:1234"/>
12   - <dubbo:protocol name="dubbo" port="20880"/>
13   - <dubbo:service interface="com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService" ref="demoServiceImp" />
14   - <bean id="demoServiceImp" class="com.alibaba.csp.sentinel.adapter.dubbo.provider.impl.DemoServiceImpl"/>
15   -
16   - <dubbo:reference id="demoService" interface="com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService"/>
17   -
18   -</beans>
19 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/resources/spring-dubbo-provider-filter.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<beans xmlns="http://www.springframework.org/schema/beans"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
5   - xsi:schemaLocation="http://www.springframework.org/schema/beans
6   - http://www.springframework.org/schema/beans/spring-beans.xsd
7   - http://code.alibabatech.com/schema/dubbo
8   - http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
9   -
10   - <dubbo:application name="demo-provider"/>
11   - <dubbo:registry address="multicast://224.5.6.7:1234"/>
12   - <dubbo:protocol name="dubbo" port="20880"/>
13   - <dubbo:service interface="com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService" ref="demoServiceImp" />
14   - <bean id="demoServiceImp" class="com.alibaba.csp.sentinel.adapter.dubbo.provider.impl.DemoServiceImpl"/>
15   -
16   - <dubbo:reference id="demoService" interface="com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService"/>
17   -
18   -</beans>
19 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/README.md deleted 100644 → 0
1   -# Sentinel Apache Httpclient Adapter
2   -
3   -## Introduction
4   -
5   -Sentinel provides integration for OkHttp client to enable flow control for web requests.
6   -
7   -Add the following dependency in `pom.xml` (if you are using Maven):
8   -
9   -```xml
10   -<dependency>
11   - <groupId>com.alibaba.csp</groupId>
12   - <artifactId>sentinel-apache-httpclient-adapter</artifactId>
13   - <version>x.y.z</version>
14   -</dependency>
15   -```
16   -
17   -We can use the `SentinelApacheHttpClientBuilder` when `CloseableHttpClient` at initialization, for example:
18   -
19   -```java
20   -CloseableHttpClient httpclient = new SentinelApacheHttpClientBuilder().build();
21   -```
22   -
23   -If we want to add some additional configurations, we can refer to the following code
24   -
25   -```java
26   -HttpClientBuilder builder = new SentinelApacheHttpClientBuilder();
27   -//builder Other Definitions
28   -CloseableHttpClient httpclient = builder.build();
29   -```
30   -
31   -## Configuration
32   -
33   -- `SentinelApacheHttpClientConfig` configuration:
34   -
35   -| name | description | type | default value |
36   -|------|------------|------|-------|
37   -| prefix | customize resource prefix | `String` | `httpclient:` |
38   -| extractor | customize resource extractor | `ApacheHttpClientResourceExtractor` | `DefaultApacheHttpClientResourceExtractor` |
39   -| fallback | handle request when it is blocked | `ApacheHttpClientFallback` | `DefaultApacheHttpClientFallback` |
40   -
41   -### extractor (resource extractor)
42   -
43   -We can define `ApacheHttpClientResourceExtractor` to customize resource extractor replace `DefaultApacheHttpClientResourceExtractor` at `SentinelApacheHttpClientBuilder` default config, for example: httpclient:GET:/httpclient/back/1 ==> httpclient:GET:/httpclient/back/{id}
44   -
45   -```java
46   -SentinelApacheHttpClientConfig config = new SentinelApacheHttpClientConfig();
47   -config.setExtractor(new ApacheHttpClientResourceExtractor() {
48   -
49   - @Override
50   - public String extractor(HttpRequestWrapper request) {
51   - String contains = "/httpclient/back/";
52   - String uri = request.getRequestLine().getUri();
53   - if (uri.startsWith(contains)) {
54   - uri = uri.substring(0, uri.indexOf(contains) + contains.length()) + "{id}";
55   - }
56   - return request.getMethod() + ":" + uri;
57   - }
58   -});
59   -CloseableHttpClient httpclient = new SentinelApacheHttpClientBuilder(config).build();
60   -```
61   -
62   -### fallback (Block handling)
63   -
64   -We can define `ApacheHttpClientFallback` at `SentinelApacheHttpClientBuilder` default config, to handle request is blocked according to the actual scenario, for example:
65   -
66   -```java
67   -public class DefaultApacheHttpClientFallback implements ApacheHttpClientFallback {
68   -
69   - @Override
70   - public CloseableHttpResponse handle(HttpRequestWrapper request, BlockException e) {
71   - // Just wrap and throw the exception.
72   - throw new SentinelRpcException(e);
73   - }
74   -}
75   -```
76 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/pom.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <parent>
6   - <artifactId>sentinel-adapter</artifactId>
7   - <groupId>com.alibaba.csp</groupId>
8   - <version>1.8.3</version>
9   - </parent>
10   - <modelVersion>4.0.0</modelVersion>
11   -
12   - <artifactId>sentinel-apache-httpclient-adapter</artifactId>
13   - <packaging>jar</packaging>
14   -
15   - <properties>
16   - <apache.httpclient.version>4.5.6</apache.httpclient.version>
17   - <spring.boot.version>2.1.3.RELEASE</spring.boot.version>
18   - <spring-test.version>5.1.5.RELEASE</spring-test.version>
19   - </properties>
20   -
21   - <dependencies>
22   - <dependency>
23   - <groupId>com.alibaba.csp</groupId>
24   - <artifactId>sentinel-core</artifactId>
25   - </dependency>
26   - <dependency>
27   - <groupId>org.apache.httpcomponents</groupId>
28   - <artifactId>httpclient</artifactId>
29   - <version>${apache.httpclient.version}</version>
30   - <scope>provided</scope>
31   - </dependency>
32   -
33   - <dependency>
34   - <groupId>junit</groupId>
35   - <artifactId>junit</artifactId>
36   - <scope>test</scope>
37   - </dependency>
38   -
39   - <dependency>
40   - <groupId>org.mockito</groupId>
41   - <artifactId>mockito-core</artifactId>
42   - <scope>test</scope>
43   - </dependency>
44   - <dependency>
45   - <groupId>com.alibaba</groupId>
46   - <artifactId>fastjson</artifactId>
47   - <scope>test</scope>
48   - </dependency>
49   -
50   - <dependency>
51   - <groupId>org.springframework.boot</groupId>
52   - <artifactId>spring-boot-starter-web</artifactId>
53   - <version>${spring.boot.version}</version>
54   - <scope>test</scope>
55   - </dependency>
56   - <dependency>
57   - <groupId>org.springframework.boot</groupId>
58   - <artifactId>spring-boot-test</artifactId>
59   - <version>${spring.boot.version}</version>
60   - <scope>test</scope>
61   - </dependency>
62   - <dependency>
63   - <groupId>org.springframework</groupId>
64   - <artifactId>spring-test</artifactId>
65   - <version>${spring-test.version}</version>
66   - <scope>test</scope>
67   - </dependency>
68   - </dependencies>
69   -</project>
70 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/SentinelApacheHttpClientBuilder.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient;
17   -
18   -import com.alibaba.csp.sentinel.*;
19   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.config.SentinelApacheHttpClientConfig;
20   -import com.alibaba.csp.sentinel.slots.block.BlockException;
21   -import com.alibaba.csp.sentinel.util.StringUtil;
22   -import org.apache.http.HttpException;
23   -import org.apache.http.client.methods.CloseableHttpResponse;
24   -import org.apache.http.client.methods.HttpExecutionAware;
25   -import org.apache.http.client.methods.HttpRequestWrapper;
26   -import org.apache.http.client.protocol.HttpClientContext;
27   -import org.apache.http.conn.routing.HttpRoute;
28   -import org.apache.http.impl.client.HttpClientBuilder;
29   -import org.apache.http.impl.execchain.ClientExecChain;
30   -
31   -import java.io.IOException;
32   -
33   -/**
34   - * @author zhaoyuguang
35   - */
36   -public class SentinelApacheHttpClientBuilder extends HttpClientBuilder {
37   -
38   - private final SentinelApacheHttpClientConfig config;
39   -
40   - public SentinelApacheHttpClientBuilder(){
41   - this.config = new SentinelApacheHttpClientConfig();
42   - }
43   -
44   - public SentinelApacheHttpClientBuilder(SentinelApacheHttpClientConfig config){
45   - this.config = config;
46   - }
47   -
48   - @Override
49   - protected ClientExecChain decorateMainExec(final ClientExecChain mainExec) {
50   - return new ClientExecChain() {
51   - @Override
52   - public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request,
53   - HttpClientContext clientContext, HttpExecutionAware execAware)
54   - throws IOException, HttpException {
55   - Entry entry = null;
56   - try {
57   - String name = config.getExtractor().extractor(request);
58   - if (!StringUtil.isEmpty(config.getPrefix())) {
59   - name = config.getPrefix() + name;
60   - }
61   - entry = SphU.entry(name, ResourceTypeConstants.COMMON_WEB, EntryType.OUT);
62   - return mainExec.execute(route, request, clientContext, execAware);
63   - } catch (BlockException e) {
64   - return config.getFallback().handle(request, e);
65   - } catch (Throwable t) {
66   - Tracer.traceEntry(t, entry);
67   - throw t;
68   - } finally {
69   - if (entry != null) {
70   - entry.exit();
71   - }
72   - }
73   - }
74   - };
75   - }
76   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/config/SentinelApacheHttpClientConfig.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.config;
17   -
18   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.extractor.ApacheHttpClientResourceExtractor;
19   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.extractor.DefaultApacheHttpClientResourceExtractor;
20   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.fallback.ApacheHttpClientFallback;
21   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.fallback.DefaultApacheHttpClientFallback;
22   -import com.alibaba.csp.sentinel.util.AssertUtil;
23   -
24   -/**
25   - * @author zhaoyuguang
26   - */
27   -public class SentinelApacheHttpClientConfig {
28   -
29   - private String prefix = "httpclient:";
30   - private ApacheHttpClientResourceExtractor extractor = new DefaultApacheHttpClientResourceExtractor();
31   - private ApacheHttpClientFallback fallback = new DefaultApacheHttpClientFallback();
32   -
33   - public String getPrefix() {
34   - return prefix;
35   - }
36   -
37   - public void setPrefix(String prefix) {
38   - AssertUtil.notNull(prefix, "prefix cannot be null");
39   - this.prefix = prefix;
40   - }
41   -
42   - public ApacheHttpClientResourceExtractor getExtractor() {
43   - return extractor;
44   - }
45   -
46   - public void setExtractor(ApacheHttpClientResourceExtractor extractor) {
47   - AssertUtil.notNull(extractor, "extractor cannot be null");
48   - this.extractor = extractor;
49   - }
50   -
51   - public ApacheHttpClientFallback getFallback() {
52   - return fallback;
53   - }
54   -
55   - public void setFallback(ApacheHttpClientFallback fallback) {
56   - AssertUtil.notNull(fallback, "fallback cannot be null");
57   - this.fallback = fallback;
58   - }
59   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/extractor/ApacheHttpClientResourceExtractor.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.extractor;
17   -
18   -import org.apache.http.client.methods.HttpRequestWrapper;
19   -
20   -/**
21   - * @author zhaoyuguang
22   - */
23   -public interface ApacheHttpClientResourceExtractor {
24   -
25   - String extractor(HttpRequestWrapper request);
26   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/extractor/DefaultApacheHttpClientResourceExtractor.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.extractor;
17   -
18   -import org.apache.http.client.methods.HttpRequestWrapper;
19   -
20   -/**
21   - * @author zhaoyuguang
22   - */
23   -public class DefaultApacheHttpClientResourceExtractor implements ApacheHttpClientResourceExtractor {
24   -
25   - @Override
26   - public String extractor(HttpRequestWrapper request) {
27   - return request.getRequestLine().getUri();
28   - }
29   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/fallback/ApacheHttpClientFallback.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.fallback;
17   -
18   -import com.alibaba.csp.sentinel.slots.block.BlockException;
19   -import org.apache.http.HttpException;
20   -import org.apache.http.HttpRequest;
21   -import org.apache.http.client.methods.CloseableHttpResponse;
22   -import org.apache.http.client.methods.HttpRequestWrapper;
23   -import org.apache.http.protocol.HttpContext;
24   -
25   -import java.io.IOException;
26   -
27   -/**
28   - * @author zhaoyuguang
29   - */
30   -public interface ApacheHttpClientFallback {
31   -
32   - CloseableHttpResponse handle(HttpRequestWrapper request, BlockException e);
33   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/fallback/DefaultApacheHttpClientFallback.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.fallback;
17   -
18   -import com.alibaba.csp.sentinel.slots.block.BlockException;
19   -import com.alibaba.csp.sentinel.slots.block.SentinelRpcException;
20   -import org.apache.http.HttpException;
21   -import org.apache.http.HttpRequest;
22   -import org.apache.http.client.methods.CloseableHttpResponse;
23   -import org.apache.http.client.methods.HttpRequestWrapper;
24   -import org.apache.http.protocol.HttpContext;
25   -
26   -import java.io.IOException;
27   -
28   -/**
29   - * @author zhaoyuguang
30   - */
31   -public class DefaultApacheHttpClientFallback implements ApacheHttpClientFallback {
32   -
33   - @Override
34   - public CloseableHttpResponse handle(HttpRequestWrapper request, BlockException e) {
35   - // Just wrap and throw the exception.
36   - throw new SentinelRpcException(e);
37   - }
38   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/SentinelApacheHttpClientTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient;
17   -
18   -import com.alibaba.csp.sentinel.Constants;
19   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.app.TestApplication;
20   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.config.SentinelApacheHttpClientConfig;
21   -import com.alibaba.csp.sentinel.adapter.apache.httpclient.extractor.ApacheHttpClientResourceExtractor;
22   -import com.alibaba.csp.sentinel.node.ClusterNode;
23   -import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot;
24   -import org.apache.http.HttpEntity;
25   -import org.apache.http.client.methods.CloseableHttpResponse;
26   -import org.apache.http.client.methods.HttpGet;
27   -import org.apache.http.client.methods.HttpRequestWrapper;
28   -import org.apache.http.impl.client.CloseableHttpClient;
29   -import org.apache.http.protocol.BasicHttpContext;
30   -import org.apache.http.protocol.HttpContext;
31   -import org.apache.http.util.EntityUtils;
32   -import org.junit.Test;
33   -import org.junit.runner.RunWith;
34   -import org.springframework.beans.factory.annotation.Value;
35   -import org.springframework.boot.test.context.SpringBootTest;
36   -import org.springframework.test.context.junit4.SpringRunner;
37   -
38   -import java.io.IOException;
39   -
40   -import static org.junit.Assert.assertNotNull;
41   -
42   -/**
43   - * @author zhaoyuguang
44   - */
45   -@RunWith(SpringRunner.class)
46   -@SpringBootTest(classes = TestApplication.class,
47   - webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
48   - properties = {
49   - "server.port=8084"
50   - })
51   -public class SentinelApacheHttpClientTest {
52   -
53   - @Value("${server.port}")
54   - private Integer port;
55   -
56   - @Test
57   - public void testSentinelOkHttpInterceptor0() throws Exception {
58   -
59   - CloseableHttpClient httpclient = new SentinelApacheHttpClientBuilder().build();
60   -
61   - HttpGet httpGet = new HttpGet("http://localhost:" + port + "/httpclient/back");
62   - System.out.println(getRemoteString(httpclient, httpGet));
63   - ClusterNode cn = ClusterBuilderSlot.getClusterNode("httpclient:/httpclient/back");
64   - assertNotNull(cn);
65   - Constants.ROOT.removeChildList();
66   - ClusterBuilderSlot.getClusterNodeMap().clear();
67   - }
68   -
69   - @Test
70   - public void testSentinelOkHttpInterceptor1() throws Exception {
71   - SentinelApacheHttpClientConfig config = new SentinelApacheHttpClientConfig();
72   - config.setExtractor(new ApacheHttpClientResourceExtractor() {
73   -
74   - @Override
75   - public String extractor(HttpRequestWrapper request) {
76   - String contains = "/httpclient/back/";
77   - String uri = request.getRequestLine().getUri();
78   - if (uri.startsWith(contains)) {
79   - uri = uri.substring(0, uri.indexOf(contains) + contains.length()) + "{id}";
80   - }
81   - return request.getMethod() + ":" + uri;
82   - }
83   - });
84   - CloseableHttpClient httpclient = new SentinelApacheHttpClientBuilder(config).build();
85   -
86   - HttpGet httpGet = new HttpGet("http://localhost:" + port + "/httpclient/back/1");
87   - System.out.println(getRemoteString(httpclient, httpGet));
88   - ClusterNode cn = ClusterBuilderSlot.getClusterNode("httpclient:GET:/httpclient/back/{id}");
89   - assertNotNull(cn);
90   - Constants.ROOT.removeChildList();
91   - ClusterBuilderSlot.getClusterNodeMap().clear();
92   - }
93   -
94   - private String getRemoteString(CloseableHttpClient httpclient, HttpGet httpGet) throws IOException {
95   - String result;
96   - HttpContext context = new BasicHttpContext();
97   - CloseableHttpResponse response;
98   - response = httpclient.execute(httpGet, context);
99   - try {
100   - HttpEntity entity = response.getEntity();
101   - result = EntityUtils.toString(entity, "utf-8");
102   - EntityUtils.consume(entity);
103   - } finally {
104   - response.close();
105   - }
106   - httpclient.close();
107   - return result;
108   - }
109   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/app/TestApplication.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.app;
17   -
18   -import org.springframework.boot.SpringApplication;
19   -import org.springframework.boot.autoconfigure.SpringBootApplication;
20   -
21   -/**
22   - * @author zhaoyuguang
23   - */
24   -@SpringBootApplication
25   -public class TestApplication {
26   -
27   - public static void main(String[] args) {
28   - SpringApplication.run(TestApplication.class);
29   - }
30   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/app/controller/TestController.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.app.controller;
17   -
18   -import org.springframework.web.bind.annotation.PathVariable;
19   -import org.springframework.web.bind.annotation.RequestMapping;
20   -import org.springframework.web.bind.annotation.RestController;
21   -
22   -/**
23   - * @author zhaoyuguang
24   - */
25   -@RestController
26   -public class TestController {
27   -
28   - @RequestMapping("/httpclient/back")
29   - public String back() {
30   - return "Welcome Back!";
31   - }
32   -
33   - @RequestMapping("/httpclient/back/{id}")
34   - public String back(@PathVariable String id) {
35   - return "Welcome Back! " + id;
36   - }
37   -}
38 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/config/SentinelApacheHttpClientConfigTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.config;
17   -
18   -import org.junit.Test;
19   -
20   -/**
21   - * @author zhaoyuguang
22   - */
23   -public class SentinelApacheHttpClientConfigTest {
24   -
25   - @Test(expected = IllegalArgumentException.class)
26   - public void testConfigSetPrefix() {
27   - SentinelApacheHttpClientConfig config = new SentinelApacheHttpClientConfig();
28   - config.setPrefix(null);
29   - }
30   -
31   - @Test(expected = IllegalArgumentException.class)
32   - public void testConfigSetCleaner() {
33   - SentinelApacheHttpClientConfig config = new SentinelApacheHttpClientConfig();
34   - config.setExtractor(null);
35   - }
36   -
37   - @Test(expected = IllegalArgumentException.class)
38   - public void testConfigSetFallback() {
39   - SentinelApacheHttpClientConfig config = new SentinelApacheHttpClientConfig();
40   - config.setFallback(null);
41   - }
42   -}
sentinel/sentinel-adapter/sentinel-apache-httpclient-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/apache/httpclient/fallback/ApacheHttpClientFallbackTest.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2020 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.apache.httpclient.fallback;
17   -
18   -import com.alibaba.csp.sentinel.slots.block.BlockException;
19   -import com.alibaba.csp.sentinel.slots.block.SentinelRpcException;
20   -import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
21   -import org.junit.Test;
22   -
23   -/**
24   - * @author zhaoyuguang
25   - */
26   -public class ApacheHttpClientFallbackTest {
27   -
28   - @Test(expected = SentinelRpcException.class)
29   - public void testDefaultOkHttpFallback() {
30   - BlockException e = new FlowException("xxx");
31   - ApacheHttpClientFallback fallback = new DefaultApacheHttpClientFallback();
32   - fallback.handle(null, e);
33   - }
34   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/README.md deleted 100644 → 0
1   -# Sentinel API Gateway Adapter Common
2   -
3   -The `sentinel-api-gateway-adapter-common` module provides common abstraction for
4   -API gateway flow control:
5   -
6   -- `GatewayFlowRule`: flow control rule specific for route or API defined in API gateway.
7   -This can be automatically converted to `FlowRule` or `ParamFlowRule`.
8   -- `ApiDefinition`: gateway API definition with a group of predicates
9 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/pom.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <parent>
6   - <artifactId>sentinel-adapter</artifactId>
7   - <groupId>com.alibaba.csp</groupId>
8   - <version>1.8.3</version>
9   - </parent>
10   - <modelVersion>4.0.0</modelVersion>
11   -
12   - <artifactId>sentinel-api-gateway-adapter-common</artifactId>
13   - <packaging>jar</packaging>
14   -
15   - <dependencies>
16   - <dependency>
17   - <groupId>com.alibaba.csp</groupId>
18   - <artifactId>sentinel-core</artifactId>
19   - </dependency>
20   - <dependency>
21   - <groupId>com.alibaba.csp</groupId>
22   - <artifactId>sentinel-parameter-flow-control</artifactId>
23   - </dependency>
24   - <dependency>
25   - <groupId>com.alibaba.csp</groupId>
26   - <artifactId>sentinel-transport-common</artifactId>
27   - <scope>provided</scope>
28   - </dependency>
29   -
30   - <dependency>
31   - <groupId>junit</groupId>
32   - <artifactId>junit</artifactId>
33   - <scope>test</scope>
34   - </dependency>
35   - <dependency>
36   - <groupId>org.assertj</groupId>
37   - <artifactId>assertj-core</artifactId>
38   - <scope>test</scope>
39   - </dependency>
40   - <dependency>
41   - <groupId>org.mockito</groupId>
42   - <artifactId>mockito-core</artifactId>
43   - <scope>test</scope>
44   - </dependency>
45   - </dependencies>
46   -</project>
47 0 \ No newline at end of file
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/SentinelGatewayConstants.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common;
17   -
18   -/**
19   - * @author Eric Zhao
20   - * @since 1.6.0
21   - */
22   -public final class SentinelGatewayConstants {
23   -
24   - public static final int APP_TYPE_GATEWAY = 1;
25   -
26   - public static final int RESOURCE_MODE_ROUTE_ID = 0;
27   - public static final int RESOURCE_MODE_CUSTOM_API_NAME = 1;
28   -
29   - public static final int PARAM_PARSE_STRATEGY_CLIENT_IP = 0;
30   - public static final int PARAM_PARSE_STRATEGY_HOST = 1;
31   - public static final int PARAM_PARSE_STRATEGY_HEADER = 2;
32   - public static final int PARAM_PARSE_STRATEGY_URL_PARAM = 3;
33   - public static final int PARAM_PARSE_STRATEGY_COOKIE = 4;
34   -
35   - public static final int URL_MATCH_STRATEGY_EXACT = 0;
36   - public static final int URL_MATCH_STRATEGY_PREFIX = 1;
37   - public static final int URL_MATCH_STRATEGY_REGEX = 2;
38   -
39   - public static final int PARAM_MATCH_STRATEGY_EXACT = 0;
40   - public static final int PARAM_MATCH_STRATEGY_PREFIX = 1;
41   - public static final int PARAM_MATCH_STRATEGY_REGEX = 2;
42   - public static final int PARAM_MATCH_STRATEGY_CONTAINS = 3;
43   -
44   - public static final String GATEWAY_CONTEXT_DEFAULT = "sentinel_gateway_context_default";
45   - public static final String GATEWAY_CONTEXT_PREFIX = "sentinel_gateway_context$$";
46   - public static final String GATEWAY_CONTEXT_ROUTE_PREFIX = "sentinel_gateway_context$$route$$";
47   -
48   - public static final String GATEWAY_NOT_MATCH_PARAM = "$NM";
49   - public static final String GATEWAY_DEFAULT_PARAM = "$D";
50   -
51   - private SentinelGatewayConstants() {}
52   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/ApiDefinition.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common.api;
17   -
18   -import java.util.Objects;
19   -import java.util.Set;
20   -
21   -/**
22   - * A group of HTTP API patterns.
23   - *
24   - * @author Eric Zhao
25   - * @since 1.6.0
26   - */
27   -public class ApiDefinition {
28   -
29   - private String apiName;
30   - private Set<ApiPredicateItem> predicateItems;
31   -
32   - public ApiDefinition() {}
33   -
34   - public ApiDefinition(String apiName) {
35   - this.apiName = apiName;
36   - }
37   -
38   - public String getApiName() {
39   - return apiName;
40   - }
41   -
42   - public ApiDefinition setApiName(String apiName) {
43   - this.apiName = apiName;
44   - return this;
45   - }
46   -
47   - public Set<ApiPredicateItem> getPredicateItems() {
48   - return predicateItems;
49   - }
50   -
51   - public ApiDefinition setPredicateItems(Set<ApiPredicateItem> predicateItems) {
52   - this.predicateItems = predicateItems;
53   - return this;
54   - }
55   -
56   - @Override
57   - public boolean equals(Object o) {
58   - if (this == o) { return true; }
59   - if (o == null || getClass() != o.getClass()) { return false; }
60   -
61   - ApiDefinition that = (ApiDefinition)o;
62   -
63   - if (!Objects.equals(apiName, that.apiName)) { return false; }
64   - return Objects.equals(predicateItems, that.predicateItems);
65   - }
66   -
67   - @Override
68   - public int hashCode() {
69   - int result = apiName != null ? apiName.hashCode() : 0;
70   - result = 31 * result + (predicateItems != null ? predicateItems.hashCode() : 0);
71   - return result;
72   - }
73   -
74   - @Override
75   - public String toString() {
76   - return "ApiDefinition{" +
77   - "apiName='" + apiName + '\'' +
78   - ", predicateItems=" + predicateItems +
79   - '}';
80   - }
81   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/ApiDefinitionChangeObserver.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * https://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common.api;
17   -
18   -import java.util.Set;
19   -
20   -/**
21   - * @author Eric Zhao
22   - * @since 1.6.0
23   - */
24   -public interface ApiDefinitionChangeObserver {
25   -
26   - /**
27   - * Notify the observer about the new gateway API definitions.
28   - *
29   - * @param apiDefinitions new set of gateway API definition
30   - */
31   - void onChange(Set<ApiDefinition> apiDefinitions);
32   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/ApiPathPredicateItem.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common.api;
17   -
18   -import java.util.Objects;
19   -
20   -import com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants;
21   -
22   -/**
23   - * @author Eric Zhao
24   - * @since 1.6.0
25   - */
26   -public class ApiPathPredicateItem implements ApiPredicateItem {
27   -
28   - private String pattern;
29   - private int matchStrategy = SentinelGatewayConstants.URL_MATCH_STRATEGY_EXACT;
30   -
31   - public ApiPathPredicateItem setPattern(String pattern) {
32   - this.pattern = pattern;
33   - return this;
34   - }
35   -
36   - public ApiPathPredicateItem setMatchStrategy(int matchStrategy) {
37   - this.matchStrategy = matchStrategy;
38   - return this;
39   - }
40   -
41   - public String getPattern() {
42   - return pattern;
43   - }
44   -
45   - public int getMatchStrategy() {
46   - return matchStrategy;
47   - }
48   -
49   - @Override
50   - public boolean equals(Object o) {
51   - if (this == o) { return true; }
52   - if (o == null || getClass() != o.getClass()) { return false; }
53   -
54   - ApiPathPredicateItem that = (ApiPathPredicateItem)o;
55   -
56   - if (matchStrategy != that.matchStrategy) { return false; }
57   - return Objects.equals(pattern, that.pattern);
58   - }
59   -
60   - @Override
61   - public int hashCode() {
62   - int result = pattern != null ? pattern.hashCode() : 0;
63   - result = 31 * result + matchStrategy;
64   - return result;
65   - }
66   -
67   - @Override
68   - public String toString() {
69   - return "ApiPathPredicateItem{" +
70   - "pattern='" + pattern + '\'' +
71   - ", matchStrategy=" + matchStrategy +
72   - '}';
73   - }
74   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/ApiPredicateGroupItem.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * https://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common.api;
17   -
18   -import java.util.HashSet;
19   -import java.util.Set;
20   -
21   -import com.alibaba.csp.sentinel.util.AssertUtil;
22   -
23   -/**
24   - * @author Eric Zhao
25   - * @since 1.6.0
26   - */
27   -public class ApiPredicateGroupItem implements ApiPredicateItem {
28   -
29   - private final Set<ApiPredicateItem> items = new HashSet<>();
30   -
31   - public ApiPredicateGroupItem addItem(ApiPredicateItem item) {
32   - AssertUtil.notNull(item, "item cannot be null");
33   - items.add(item);
34   - return this;
35   - }
36   -
37   - public Set<ApiPredicateItem> getItems() {
38   - return items;
39   - }
40   -
41   - /*@Override
42   - public ApiPredicateItem and(ApiPredicateItem item) {
43   - AssertUtil.notNull(item, "item cannot be null");
44   - return this.addItem(item);
45   - }*/
46   -}
sentinel/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/ApiPredicateItem.java deleted 100644 → 0
1   -/*
2   - * Copyright 1999-2019 Alibaba Group Holding Ltd.
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -package com.alibaba.csp.sentinel.adapter.gateway.common.api;
17   -
18   -import com.alibaba.csp.sentinel.util.AssertUtil;
19   -
20   -/**
21   - * @author Eric Zhao
22   - * @since 1.6.0
23   - */
24   -public interface ApiPredicateItem {
25   -
26   - /**
27   - * Combine two {@link ApiPredicateItem}.
28   - *
29   - * @param item another predicate item
30   - * @return combined predicate group item
31   - */
32   - /*default ApiPredicateItem and(ApiPredicateItem item) {
33   - AssertUtil.notNull(item, "item cannot be null");
34   - return new ApiPredicateGroupItem()
35   - .addItem(this).addItem(item);
36   - }*/
37   -}