Bläddra i källkod

Remove sentinel-spring-boot-starter module

- This has been replaced with Spring Cloud Alibaba

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 år sedan
förälder
incheckning
73b0979542
12 ändrade filer med 0 tillägg och 492 borttagningar
  1. +0
    -1
      sentinel-adapter/pom.xml
  2. +0
    -18
      sentinel-adapter/sentinel-spring-boot-starter/README.md
  3. +0
    -95
      sentinel-adapter/sentinel-spring-boot-starter/pom.xml
  4. +0
    -31
      sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/Constants.java
  5. +0
    -85
      sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/config/SentinelWebServletAutoConfiguration.java
  6. +0
    -68
      sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/endpoint/SentinelActuatorEndpoint.java
  7. +0
    -39
      sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/endpoint/SentinelEndpointManagementContextConfiguration.java
  8. +0
    -93
      sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/property/SentinelProperties.java
  9. +0
    -5
      sentinel-adapter/sentinel-spring-boot-starter/src/main/resources/META-INF/spring.factories
  10. +0
    -1
      sentinel-adapter/sentinel-spring-boot-starter/src/main/resources/META-INF/spring.provides
  11. +0
    -53
      sentinel-adapter/sentinel-spring-boot-starter/src/test/java/com/alibaba/boot/sentinel/SimpleWebApplication.java
  12. +0
    -3
      sentinel-adapter/sentinel-spring-boot-starter/src/test/resources/web-servlet.properties

+ 0
- 1
sentinel-adapter/pom.xml Visa fil

@@ -18,7 +18,6 @@
<module>sentinel-web-servlet</module>
<module>sentinel-dubbo-adapter</module>
<module>sentinel-grpc-adapter</module>
<module>sentinel-spring-boot-starter</module>
</modules>

<properties>


+ 0
- 18
sentinel-adapter/sentinel-spring-boot-starter/README.md Visa fil

@@ -1,18 +0,0 @@
# Sentinel Spring Boot Starter

Sentinel Spring Boot Starter provides out-of-box integration with Spring Boot applications
(e.g. web applications, Dubbo services).

## Web Servlet

Web servlet integration is enabled by default. You need to configure URL patterns in your config file (e.g. properties file):

```
spring.sentinel.servletFilter.urlPatterns=/*
```

By default the URL pattern is `/*`.

## Dubbo

Dubbo integration is enabled by default. You need to disable the filters manually if you don't want them.

+ 0
- 95
sentinel-adapter/sentinel-spring-boot-starter/pom.xml Visa fil

@@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>sentinel-adapter</artifactId>
<groupId>com.alibaba.csp</groupId>
<version>0.1.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

<artifactId>sentinel-spring-boot-starter</artifactId>

<properties>
<spring.boot.version>1.5.14.RELEASE</spring.boot.version>
</properties>

<dependencies>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-web-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-dubbo-adapter</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring.boot.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring.boot.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring.boot.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>${spring.boot.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

+ 0
- 31
sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/Constants.java Visa fil

@@ -1,31 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel;

/**
* @author Eric Zhao
*/
public final class Constants {

/**
* Property prefix in application.properties.
*/
public static final String PREFIX = "spring.sentinel";
public static final String SENTINEL_SERVLET_ENABLED = "spring.sentinel.servletFilter.enabled";
public static final String SENTINEL_ENABLED = "spring.sentinel.enabled";

private Constants() {}
}

+ 0
- 85
sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/config/SentinelWebServletAutoConfiguration.java Visa fil

@@ -1,85 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel.config;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.Filter;

import com.alibaba.boot.sentinel.Constants;
import com.alibaba.boot.sentinel.property.SentinelProperties;
import com.alibaba.boot.sentinel.property.SentinelProperties.ServletFilterConfig;
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;

/**
* Auto configuration for Sentinel web servlet filter.
*
* @author Eric Zhao
*/
@Configuration
@ConditionalOnWebApplication
@ConditionalOnProperty(name = {Constants.SENTINEL_ENABLED, Constants.SENTINEL_SERVLET_ENABLED}, matchIfMissing = true)
@EnableConfigurationProperties(SentinelProperties.class)
public class SentinelWebServletAutoConfiguration {

private final Logger logger = LoggerFactory.getLogger(SentinelWebServletAutoConfiguration.class);

@Autowired
private SentinelProperties properties;

@Bean
@ConditionalOnWebApplication
public FilterRegistrationBean sentinelFilterRegistrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
if (!properties.isEnabled()) {
return registrationBean;
}

ServletFilterConfig filterConfig = properties.getServletFilter();
if (null == filterConfig) {
filterConfig = new ServletFilterConfig();
properties.setServletFilter(filterConfig);
}

if (CollectionUtils.isEmpty(filterConfig.getUrlPatterns())) {
List<String> defaultPatterns = new ArrayList<String>();
defaultPatterns.add("/*");
filterConfig.setUrlPatterns(defaultPatterns);
logger.info("[Sentinel Starter] Using default patterns for web servlet filter: {}", defaultPatterns);
}
registrationBean.addUrlPatterns(filterConfig.getUrlPatterns().toArray(new String[0]));

Filter filter = new CommonFilter();
registrationBean.setFilter(filter);
registrationBean.setOrder(filterConfig.getOrder());

logger.info("[Sentinel Starter] Web servlet filter registered with urlPatterns: {}",
filterConfig.getUrlPatterns());
return registrationBean;
}
}

+ 0
- 68
sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/endpoint/SentinelActuatorEndpoint.java Visa fil

@@ -1,68 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel.endpoint;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.boot.sentinel.property.SentinelProperties;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import com.alibaba.csp.sentinel.slots.system.SystemRule;
import com.alibaba.csp.sentinel.slots.system.SystemRuleManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.mvc.AbstractMvcEndpoint;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
* @author duanling
* @author Eric Zhao
*/
@ConfigurationProperties("endpoints.sentinel")
public class SentinelActuatorEndpoint extends AbstractMvcEndpoint {

@Autowired
private SentinelProperties sentinelProperties;

public SentinelActuatorEndpoint() {
super("/sentinel", false);
}

@RequestMapping
@ResponseBody
public Map<String, Object> invoke() {
Map<String, Object> result = new HashMap<String, Object>();

result.put("version", this.getClass().getPackage().getImplementationVersion());
result.put("properties", sentinelProperties);

List<FlowRule> flowRules = FlowRuleManager.getRules();
List<DegradeRule> degradeRules = DegradeRuleManager.getRules();
List<SystemRule> systemRules = SystemRuleManager.getRules();

result.put("flowRules", flowRules);
result.put("degradeRules", degradeRules);
result.put("systemRules", systemRules);

return result;
}
}

+ 0
- 39
sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/endpoint/SentinelEndpointManagementContextConfiguration.java Visa fil

@@ -1,39 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel.endpoint;

import com.alibaba.boot.sentinel.property.SentinelProperties;

import org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration;
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
* @author duanling
*/
@ManagementContextConfiguration
@EnableConfigurationProperties({SentinelProperties.class})
public class SentinelEndpointManagementContextConfiguration {

@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint("sentinel")
public SentinelActuatorEndpoint sentinelEndPoint() {
return new SentinelActuatorEndpoint();
}
}

+ 0
- 93
sentinel-adapter/sentinel-spring-boot-starter/src/main/java/com/alibaba/boot/sentinel/property/SentinelProperties.java Visa fil

@@ -1,93 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel.property;

import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.Ordered;

/**
* @author Eric Zhao
*/
@ConfigurationProperties(prefix = "spring.sentinel")
public class SentinelProperties {

private boolean enabled = true;

private ServletFilterConfig servletFilter;

public boolean isEnabled() {
return enabled;
}

public SentinelProperties setEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}

public ServletFilterConfig getServletFilter() {
return servletFilter;
}

public SentinelProperties setServletFilter(
ServletFilterConfig servletFilter) {
this.servletFilter = servletFilter;
return this;
}

public static class DubboFilterConfig {}

public static class ServletFilterConfig {

private boolean enabled = true;

/**
* Chain order for Sentinel servlet filter.
*/
private int order = Ordered.HIGHEST_PRECEDENCE;

/**
* URL pattern for Sentinel servlet filter.
*/
private List<String> urlPatterns;

public int getOrder() {
return this.order;
}

public void setOrder(int order) {
this.order = order;
}

public List<String> getUrlPatterns() {
return urlPatterns;
}

public void setUrlPatterns(List<String> urlPatterns) {
this.urlPatterns = urlPatterns;
}

public boolean isEnabled() {
return enabled;
}

public ServletFilterConfig setEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}
}
}

+ 0
- 5
sentinel-adapter/sentinel-spring-boot-starter/src/main/resources/META-INF/spring.factories Visa fil

@@ -1,5 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.alibaba.boot.sentinel.config.SentinelWebServletAutoConfiguration

org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration=\
com.alibaba.boot.sentinel.endpoint.SentinelEndpointManagementContextConfiguration

+ 0
- 1
sentinel-adapter/sentinel-spring-boot-starter/src/main/resources/META-INF/spring.provides Visa fil

@@ -1 +0,0 @@
provides: sentinel-core

+ 0
- 53
sentinel-adapter/sentinel-spring-boot-starter/src/test/java/com/alibaba/boot/sentinel/SimpleWebApplication.java Visa fil

@@ -1,53 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.boot.sentinel;

import com.alibaba.csp.sentinel.node.ClusterNode;
import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @author Eric Zhao
*/
@SpringBootApplication
@RestController
@PropertySource("classpath:web-servlet.properties")
public class SimpleWebApplication {

@RequestMapping("/foo")
public String foo() {
return "Hello!";
}

@RequestMapping("/baz")
public String baz() {
ClusterNode node = ClusterBuilderSlot.getClusterNode("/foo");
if (node == null) {
return "/foo has not been called!";
} else {
return "/foo total request in metrics: " + node.totalRequest();
}
}

public static void main(String[] args) {
SpringApplication.run(SimpleWebApplication.class, args);
}
}

+ 0
- 3
sentinel-adapter/sentinel-spring-boot-starter/src/test/resources/web-servlet.properties Visa fil

@@ -1,3 +0,0 @@
spring.sentinel.enabled=true
spring.sentinel.servletFilter.enabled=true
spring.sentinel.servletFilter.urlPatterns=/foo

Laddar…
Avbryt
Spara