This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git
The following commit(s) were added to refs/heads/master by this push: new fc07239 SCB-1233 Release version removes eureka dependencies fc07239 is described below commit fc07239e07407664288a95a73bf2c111b82b672a Author: 张磊 <coolbee...@gmail.com> AuthorDate: Mon Apr 1 15:07:35 2019 +0800 SCB-1233 Release version removes eureka dependencies --- alpha/alpha-server/pom.xml | 25 --- .../alpha/server/AlphaIntegrationEventTest.java | 65 -------- docs/user_guide.md | 170 +++++++++++---------- docs/user_guide_zh.md | 170 +++++++++++---------- 4 files changed, 180 insertions(+), 250 deletions(-) diff --git a/alpha/alpha-server/pom.xml b/alpha/alpha-server/pom.xml index 228fd15..a079552 100644 --- a/alpha/alpha-server/pom.xml +++ b/alpha/alpha-server/pom.xml @@ -82,29 +82,7 @@ </dependency> <dependency> <groupId>org.apache.servicecomb.pack</groupId> - <artifactId>alpha-spring-cloud-starter-eureka</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb.pack</groupId> <artifactId>alpha-spring-cloud-starter-consul</artifactId> - <exclusions> - <exclusion> - <artifactId>spring-cloud-commons</artifactId> - <groupId>org.springframework.cloud</groupId> - </exclusion> - <exclusion> - <artifactId>spring-cloud-context</artifactId> - <groupId>org.springframework.cloud</groupId> - </exclusion> - <exclusion> - <artifactId>spring-cloud-netflix-core</artifactId> - <groupId>org.springframework.cloud</groupId> - </exclusion> - <exclusion> - <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> - <groupId>org.springframework.cloud</groupId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.apache.servicecomb.pack</groupId> @@ -269,9 +247,6 @@ <profile> <id>spring-cloud-eureka</id> <!-- Specify the alpha spring boot starter with the profile--> - <activation> - <activeByDefault>true</activeByDefault> - </activation> <dependencies> <dependency> <groupId>org.apache.servicecomb.pack</groupId> diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationEventTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationEventTest.java deleted file mode 100644 index 0cb3804..0000000 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationEventTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.servicecomb.pack.alpha.server; - -import com.google.common.eventbus.EventBus; -import org.apache.servicecomb.pack.alpha.core.event.GrpcStartableStartedEvent; -import org.junit.*; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.*; - -import static org.apache.servicecomb.pack.alpha.server.discovery.eureka.GrpcStartableStartedEventListener.ALPHA_SERVER_GRPC_ADDRESS_KEY; -import static org.awaitility.Awaitility.await; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.when; - -@RunWith(SpringRunner.class) -@ActiveProfiles("test") -@SpringBootTest(classes = {AlphaApplication.class, AlphaConfig.class}, - properties = { - "alpha.server.host=0.0.0.0", - "alpha.server.port=8080", - "eureka.client.enabled=true" - }) -public class AlphaIntegrationEventTest { - - @Autowired - private EventBus eventBus; - - @MockBean - private EurekaInstanceConfigBean eurekaInstanceConfigBean; - - @Test - public void eurekaInstanceConfigBeanPortUpdater(){ - when(eurekaInstanceConfigBean.getMetadataMap()).thenReturn(new HashMap<>()); - this.eurekaInstanceConfigBean.getMetadataMap().put(ALPHA_SERVER_GRPC_ADDRESS_KEY,"0.0.0.0:0"); - eventBus.post(new GrpcStartableStartedEvent(9000)); - assertThat(eurekaInstanceConfigBean.getMetadataMap().get(ALPHA_SERVER_GRPC_ADDRESS_KEY),is("0.0.0.0:9000")); - } - -} diff --git a/docs/user_guide.md b/docs/user_guide.md index 15f7e74..051920f 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -218,86 +218,6 @@ See [Enabling SSL](enable_ssl.md) for details. Alpha instance can register to the discovery service, Omega obtains Alpha's instance list and gRPC address through discovery service -### Spring Cloud Eureka - -Uses Spring Cloud Netflix 2.x by default, if you want to use Spring Cloud Netflix 1.x, you can use `-Pspring-boot-1` to switch Spring Cloud Netflix 1.x - -1. run alpha - - run with parameter `eureka.client.enabled=true` - - ```bash - java -jar alpha-server-${saga_version}-exec.jar \ - --spring.datasource.url=jdbc:postgresql://${host_address}:5432/saga?useSSL=false \ - --spring.datasource.username=saga \ - --spring.datasource.password=saga \ - --eureka.client.enabled=true \ - --eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka \ - --spring.profiles.active=prd - ``` - **Note:** Check out [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) for more details - -2. verify registration information - - request `curl http://127.0.0.1:8761/eureka/apps/`, It responds with the following XML - - ```xml - <applications> - <versions__delta>1</versions__delta> - <apps__hashcode>UP_1_</apps__hashcode> - <application> - <name>SERVICECOMB-ALPHA-SERVER</name> - <instance> - <instanceId>0.0.0.0::servicecomb-alpha-server:8090</instanceId> - <hostName>0.0.0.0</hostName> - <app>SERVICECOMB-ALPHA-SERVER</app> - <ipAddr>0.0.0.0</ipAddr> - <status>UP</status> - ... - <metadata> - <management.port>8090</management.port> - <servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server> - </metadata> - ... - </instance> - </application> - </applications> - ``` - - **Note:** `<servicecomb-alpha-server>` property is alpha gRPC address - - **Note:** alpha instance name is `SERVICECOMB-ALPHA-SERVER` by default. You can set it by starting parameter `spring.application.name` - -3. setup omega - - edit your `pom.xml` and add the `omega-spring-cloud-eureka-starter` dependency - - ```xml - <dependency> - <groupId>org.apache.servicecomb.pack</groupId> - <artifactId>omega-spring-cloud-eureka-starter</artifactId> - <version>${pack.version}</version> - </dependency> - ``` - - edit your `application.yaml` , as shown in the following example: - - ```yaml - eureka: - client: - service-url: - defaultZone: http://127.0.0.1:8761/eureka - alpha: - cluster: - register: - type: eureka - ``` - - * `eureka.client.service-url.defaultZone` property is set to the Eureka server’s instance address, check out Spring Boot’s [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) or [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) for more details. - * `alpha.cluster.register.type=eureka` property is omega gets alpha gRPC address from Eureka - - **Note:** If you define `spring.application.name ` parameter when start alpha, You need to specify this service name in Omega via the parameter `alpha.cluster.serviceId` - ### Consul Uses Spring Cloud Consul 2.x by default, if you want to use Spring Cloud Consul 1.x, you can use `-Pspring-boot-1` to switch Spring Cloud Consul 1.x @@ -385,6 +305,96 @@ Uses Spring Cloud Consul 2.x by default, if you want to use Spring Cloud Consul **Note:** If you define `spring.application.name ` parameter when start alpha, You need to specify this service name in Omega via the parameter `alpha.cluster.serviceId` +### Spring Cloud Eureka + +Uses Spring Cloud Netflix 2.x by default, if you want to use Spring Cloud Netflix 1.x, you can use `-Pspring-boot-1` to switch Spring Cloud Netflix 1.x + +1. build version of eureka + + build the version support eureka with the `-Pspring-cloud-eureka` parameter + + ```bash + git clone https://github.com/apache/servicecomb-pack.git + cd servicecomb-pack + mvn clean install -DskipTests=true -Pspring-boot-2,spring-cloud-eureka + ``` + +2. run alpha + + run with parameter `eureka.client.enabled=true` + + ```bash + java -jar alpha-server-${saga_version}-exec.jar \ + --spring.datasource.url=jdbc:postgresql://${host_address}:5432/saga?useSSL=false \ + --spring.datasource.username=saga \ + --spring.datasource.password=saga \ + --eureka.client.enabled=true \ + --eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka \ + --spring.profiles.active=prd + ``` + **Note:** Check out [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) for more details + +3. verify registration information + + request `curl http://127.0.0.1:8761/eureka/apps/`, It responds with the following XML + + ```xml + <applications> + <versions__delta>1</versions__delta> + <apps__hashcode>UP_1_</apps__hashcode> + <application> + <name>SERVICECOMB-ALPHA-SERVER</name> + <instance> + <instanceId>0.0.0.0::servicecomb-alpha-server:8090</instanceId> + <hostName>0.0.0.0</hostName> + <app>SERVICECOMB-ALPHA-SERVER</app> + <ipAddr>0.0.0.0</ipAddr> + <status>UP</status> + ... + <metadata> + <management.port>8090</management.port> + <servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server> + </metadata> + ... + </instance> + </application> + </applications> + ``` + + **Note:** `<servicecomb-alpha-server>` property is alpha gRPC address + + **Note:** alpha instance name is `SERVICECOMB-ALPHA-SERVER` by default. You can set it by starting parameter `spring.application.name` + +4. setup omega + + edit your `pom.xml` and add the `omega-spring-cloud-eureka-starter` dependency + + ```xml + <dependency> + <groupId>org.apache.servicecomb.pack</groupId> + <artifactId>omega-spring-cloud-eureka-starter</artifactId> + <version>${pack.version}</version> + </dependency> + ``` + + edit your `application.yaml` , as shown in the following example: + + ```yaml + eureka: + client: + service-url: + defaultZone: http://127.0.0.1:8761/eureka + alpha: + cluster: + register: + type: eureka + ``` + + * `eureka.client.service-url.defaultZone` property is set to the Eureka server’s instance address, check out Spring Boot’s [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) or [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) for more details. + * `alpha.cluster.register.type=eureka` property is omega gets alpha gRPC address from Eureka + + **Note:** If you define `spring.application.name ` parameter when start alpha, You need to specify this service name in Omega via the parameter `alpha.cluster.serviceId` + ## Cluster Alpha can be highly available by deploying multiple instances, enable cluster support with the `alpha.cluster.master.enabled=true` parameter. \ No newline at end of file diff --git a/docs/user_guide_zh.md b/docs/user_guide_zh.md index a9cd248..9875b0b 100644 --- a/docs/user_guide_zh.md +++ b/docs/user_guide_zh.md @@ -222,85 +222,6 @@ Saga可通过以下任一方式进行构建: 支持Alpha启动时注册到发现服务,Omega通过发现服务获取Alpha的实例列表和gRPC地址 -### Spring Cloud Eureka支持 - -当前版本支持 Spring Cloud Netflix 2.x,你可以使用 `-Pspring-boot-1` 参数重新编译支持 Spring Cloud Netflix 1.x 版本 - -1. 运行alpha - - 运行时增加 `eureka.client.enabled=true` 参数 - - ```bash - java -jar alpha-server-${saga_version}-exec.jar \ - --spring.datasource.url=jdbc:postgresql://${host_address}:5432/saga?useSSL=false \ - --spring.datasource.username=saga \ - --spring.datasource.password=saga \ - --eureka.client.enabled=true \ - --eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka \ - --spring.profiles.active=prd - ``` - - **注意:** 更多 eureka 参数请参考 [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) - -3. 验证是否注册成功 - - 访问Eureka的注册实例查询接口`curl http://127.0.0.1:8761/eureka/apps/`可以看到如下注册信息,在你metadata中可以看到Alpha的gRPC访问地址`<servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server>`已经注册 - - ```xml - <applications> - <versions__delta>1</versions__delta> - <apps__hashcode>UP_1_</apps__hashcode> - <application> - <name>SERVICECOMB-ALPHA-SERVER</name> - <instance> - <instanceId>0.0.0.0::servicecomb-alpha-server:8090</instanceId> - <hostName>0.0.0.0</hostName> - <app>SERVICECOMB-ALPHA-SERVER</app> - <ipAddr>0.0.0.0</ipAddr> - <status>UP</status> - ... - <metadata> - <management.port>8090</management.port> - <servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server> - </metadata> - ... - </instance> - </application> - </applications> - ``` - - **注意:** 默认情况下注册的服务名是`SERVICECOMB-ALPHA-SERVER`,如果你需要自定义服务名可以在运行Alpha的时候通过命令行参数`spring.application.name`配置 - -4. 配置omega - - 在项目中引入依赖包 `omega-spring-cloud-eureka-starter` - - ```xml - <dependency> - <groupId>org.apache.servicecomb.pack</groupId> - <artifactId>omega-spring-cloud-eureka-starter</artifactId> - <version>${pack.version}</version> - </dependency> - ``` - - 在 `application.yaml` 添加下面的配置项: - - ```yaml - eureka: - client: - service-url: - defaultZone: http://127.0.0.1:8761/eureka - alpha: - cluster: - register: - type: eureka - ``` - - * `eureka.client.service-url.defaultZone` 配置Eureka注册中心的地址,更多Eureka客户端配置可以参考[Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) 或 [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) - * `alpha.cluster.register.type=eureka` 配置Omega获取Alpha的方式是通过Eureka的注册中心 - - **注意:** 如果你在启动Alpha的时候通过命令行参数`spring.application.name`自定义了服务名,那么你需要在Omega中通过参数`alpha.cluster.serviceId`指定这个服务名 - ### Consul 支持 当前版本支持 Spring Cloud Consul 2.x,你可以使用 `-Pspring-boot-1` 参数重新编译支持 Spring Cloud Consul 1.x 版本 @@ -385,7 +306,96 @@ Saga可通过以下任一方式进行构建: - `alpha.cluster.register.type=consul` 配置Omega获取Alpha的方式是通过 Consul 的注册中心 **注意:** 如果你在启动Alpha的时候通过命令行参数`spring.application.name`自定义了服务名,那么你需要在Omega中通过参数`alpha.cluster.serviceId`指定这个服务名 - + +### Spring Cloud Eureka支持 + +当前版本支持 Spring Cloud Netflix 2.x,你可以使用 `-Pspring-boot-1` 参数重新编译支持 Spring Cloud Netflix 1.x 版本 + +1. 编译 eureka 的版本 + + 使用 `-Pspring-cloud-eureka` 参数编译支持 eureka 的版本 + + ```bash + git clone https://github.com/apache/servicecomb-pack.git + cd servicecomb-pack + mvn clean install -DskipTests=true -Pspring-boot-2,spring-cloud-eureka + ``` + +2. 运行alpha + + 运行时增加 `eureka.client.enabled=true` 参数 + + ```bash + java -jar alpha-server-${saga_version}-exec.jar \ + --spring.datasource.url=jdbc:postgresql://${host_address}:5432/saga?useSSL=false \ + --spring.datasource.username=saga \ + --spring.datasource.password=saga \ + --eureka.client.enabled=true \ + --eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka \ + --spring.profiles.active=prd + ``` + + **注意:** 更多 eureka 参数请参考 [Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) + +3. 验证是否注册成功 + + 访问Eureka的注册实例查询接口`curl http://127.0.0.1:8761/eureka/apps/`可以看到如下注册信息,在你metadata中可以看到Alpha的gRPC访问地址`<servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server>`已经注册 + + ```xml + <applications> + <versions__delta>1</versions__delta> + <apps__hashcode>UP_1_</apps__hashcode> + <application> + <name>SERVICECOMB-ALPHA-SERVER</name> + <instance> + <instanceId>0.0.0.0::servicecomb-alpha-server:8090</instanceId> + <hostName>0.0.0.0</hostName> + <app>SERVICECOMB-ALPHA-SERVER</app> + <ipAddr>0.0.0.0</ipAddr> + <status>UP</status> + ... + <metadata> + <management.port>8090</management.port> + <servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server> + </metadata> + ... + </instance> + </application> + </applications> + ``` + + **注意:** 默认情况下注册的服务名是`SERVICECOMB-ALPHA-SERVER`,如果你需要自定义服务名可以在运行Alpha的时候通过命令行参数`spring.application.name`配置 + +4. 配置omega + + 在项目中引入依赖包 `omega-spring-cloud-eureka-starter` + + ```xml + <dependency> + <groupId>org.apache.servicecomb.pack</groupId> + <artifactId>omega-spring-cloud-eureka-starter</artifactId> + <version>${pack.version}</version> + </dependency> + ``` + + 在 `application.yaml` 添加下面的配置项: + + ```yaml + eureka: + client: + service-url: + defaultZone: http://127.0.0.1:8761/eureka + alpha: + cluster: + register: + type: eureka + ``` + + * `eureka.client.service-url.defaultZone` 配置Eureka注册中心的地址,更多Eureka客户端配置可以参考[Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) 或 [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) + * `alpha.cluster.register.type=eureka` 配置Omega获取Alpha的方式是通过Eureka的注册中心 + + **注意:** 如果你在启动Alpha的时候通过命令行参数`spring.application.name`自定义了服务名,那么你需要在Omega中通过参数`alpha.cluster.serviceId`指定这个服务名 + ## 集群 Alpha 可以通过部署多实例的方式保证高可用,使用 `alpha.cluster.master.enabled=true` 参数开启集群支持 \ No newline at end of file