You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/07/16 01:39:50 UTC

[servicecomb-pack] 03/05: SCB-1372 Use the Alpha metrics query API instead of the spring boot actuate endpoint

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

commit 0691354f8a7b063a029d2adbaeba864bb464dcc2
Author: Lei Zhang <co...@gmail.com>
AuthorDate: Mon Jul 15 14:10:35 2019 +0800

    SCB-1372 Use the Alpha metrics query API instead of the spring boot actuate endpoint
---
 .../org/apache/servicecomb/pack/PackStepdefs.java  |  2 +-
 .../alpha-spring-boot-1-starter/pom.xml            | 86 ----------------------
 .../server/actuate/endpoint/ActuatorEndpoint.java  | 38 ----------
 .../server/actuate/endpoint/AlphaEndpoint.java     | 59 ---------------
 .../actuate/endpoint/mvc/ActuatorMvcEndpoint.java  | 48 ------------
 .../alpha-spring-boot-2-starter/pom.xml            | 82 ---------------------
 alpha/alpha-spring-boot-compatibility/pom.xml      | 38 ----------
 alpha/pom.xml                                      |  1 -
 8 files changed, 1 insertion(+), 353 deletions(-)

diff --git a/acceptance-tests/acceptance-pack-cluster-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java b/acceptance-tests/acceptance-pack-cluster-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java
index 01808d1..33c77cd 100644
--- a/acceptance-tests/acceptance-pack-cluster-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java
+++ b/acceptance-tests/acceptance-pack-cluster-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java
@@ -267,7 +267,7 @@ public class PackStepdefs implements En {
 
     private <T> boolean matches(Supplier<T> supplier, Optional<String> value) {
       try{
-        String nodeType = given().get(supplier.get() + "/actuator/alpha").jsonPath().getString("nodeType");
+        String nodeType = given().get(supplier.get() + "/alpha/api/v1/metrics").jsonPath().getString("nodeType");
         LOG.info("Check alpha server {} nodeType is {}",supplier.get(),nodeType);
         if (value.get().equalsIgnoreCase(nodeType)) {
           return true;
diff --git a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/pom.xml b/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/pom.xml
deleted file mode 100644
index 1df663f..0000000
--- a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<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>alpha-spring-boot-compatibility</artifactId>
-    <groupId>org.apache.servicecomb.pack</groupId>
-    <version>0.5.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>alpha-spring-boot-starter-1</artifactId>
-  <name>Pack::Alpha::Spring Boot 1.X Starter</name>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-test</artifactId>
-        <version>${spring.boot1.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-          </exclusion>
-        </exclusions>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-dependencies</artifactId>
-        <version>${spring.boot1.version}</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.servicecomb.pack</groupId>
-      <artifactId>alpha-core</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter</artifactId>
-        <exclusions>
-            <exclusion>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-starter-logging</artifactId>
-            </exclusion>
-        </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-log4j2</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-web</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-actuator</artifactId>
-    </dependency>
-  </dependencies>
-
-
-</project>
diff --git a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/ActuatorEndpoint.java b/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/ActuatorEndpoint.java
deleted file mode 100644
index 85619cc..0000000
--- a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/ActuatorEndpoint.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.servicecomb.pack.alpha.server.actuate.endpoint;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.endpoint.Endpoint;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-@Component
-public class ActuatorEndpoint implements Endpoint<List<Endpoint>> {
-
-  @Autowired
-  private List<Endpoint> endpoints;
-
-  @Override
-  public String getId() {
-    return "actuator";
-  }
-
-  @Override
-  public boolean isEnabled() {
-    return true;
-  }
-
-  @Override
-  public boolean isSensitive() {
-    return false;
-  }
-
-  @Override
-  public List<Endpoint> invoke() {
-    throw new UnsupportedOperationException();
-  }
-
-  public List<Endpoint> endpoints() {
-    return endpoints;
-  }
-}
diff --git a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/AlphaEndpoint.java b/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/AlphaEndpoint.java
deleted file mode 100644
index 058f81e..0000000
--- a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/AlphaEndpoint.java
+++ /dev/null
@@ -1,59 +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.actuate.endpoint;
-
-import org.apache.servicecomb.pack.alpha.core.NodeStatus;
-import org.apache.servicecomb.pack.alpha.core.actuate.endpoint.AlphaStatus;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.endpoint.Endpoint;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-@ConfigurationProperties(prefix = "endpoints.alpha")
-@Component
-public class AlphaEndpoint implements Endpoint {
-
-  public static final String END_POINT_ID = "alpha";
-
-  @Autowired
-  NodeStatus nodeStatus;
-
-  private AlphaStatus alphaStatus = new AlphaStatus();
-
-  @Override
-  public String getId() {
-    return END_POINT_ID;
-  }
-
-  @Override
-  public boolean isEnabled() {
-    return true;
-  }
-
-  @Override
-  public boolean isSensitive() {
-    return false;
-  }
-
-  @Override
-  public AlphaStatus invoke() {
-    alphaStatus.setNodeType(nodeStatus.getTypeEnum());
-    return alphaStatus;
-  }
-
-}
diff --git a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/mvc/ActuatorMvcEndpoint.java b/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/mvc/ActuatorMvcEndpoint.java
deleted file mode 100644
index b0c117d..0000000
--- a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-1-starter/src/main/java/org/apache/servicecomb/pack/alpha/server/actuate/endpoint/mvc/ActuatorMvcEndpoint.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.servicecomb.pack.alpha.server.actuate.endpoint.mvc;
-
-import org.apache.servicecomb.pack.alpha.server.actuate.endpoint.ActuatorEndpoint;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.endpoint.Endpoint;
-import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Optional;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-import static java.util.Optional.ofNullable;
-
-@Component
-public class ActuatorMvcEndpoint extends EndpointMvcAdapter {
-
-  private final ActuatorEndpoint delegate;
-
-  @Autowired
-  public ActuatorMvcEndpoint(ActuatorEndpoint delegate) {
-    super(delegate);
-    this.delegate = delegate;
-  }
-
-  @RequestMapping(value = "/{endpoint}", method = {RequestMethod.GET, RequestMethod.POST})
-  @ResponseBody
-  public Object endpoint(@PathVariable("endpoint") String id, @RequestParam(required = false) Boolean enabled,
-                         @RequestParam(required = false) Boolean sensitive) {
-    Predicate<Endpoint> isEnabled =
-            endpoint -> matches(endpoint::isEnabled, ofNullable(enabled));
-
-    Predicate<Endpoint> isSensitive =
-            endpoint -> matches(endpoint::isSensitive, ofNullable(sensitive));
-
-    Predicate<Endpoint> matchEndPoint =
-            endpoint -> matches(endpoint::getId, ofNullable(id));
-
-    return this.delegate.endpoints().stream()
-            .filter(matchEndPoint.and(isEnabled.and(isSensitive)))
-            .findAny().get().invoke();
-  }
-
-  private <T> boolean matches(Supplier<T> supplier, Optional<T> value) {
-    return !value.isPresent() || supplier.get().equals(value.get());
-  }
-}
diff --git a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-2-starter/pom.xml b/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-2-starter/pom.xml
deleted file mode 100644
index 6edca9f..0000000
--- a/alpha/alpha-spring-boot-compatibility/alpha-spring-boot-2-starter/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<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>alpha-spring-boot-compatibility</artifactId>
-    <groupId>org.apache.servicecomb.pack</groupId>
-    <version>0.5.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>alpha-spring-boot-starter-2</artifactId>
-  <name>Pack::Alpha::Spring Boot 2.X Starter</name>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-test</artifactId>
-        <version>${spring.boot2.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-          </exclusion>
-        </exclusions>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-dependencies</artifactId>
-        <version>${spring.boot2.version}</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.servicecomb.pack</groupId>
-      <artifactId>alpha-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.springframework.boot</groupId>
-          <artifactId>spring-boot-starter-logging</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-log4j2</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-actuator</artifactId>
-    </dependency>
-  </dependencies>
-
-
-</project>
diff --git a/alpha/alpha-spring-boot-compatibility/pom.xml b/alpha/alpha-spring-boot-compatibility/pom.xml
deleted file mode 100644
index 7f0b822..0000000
--- a/alpha/alpha-spring-boot-compatibility/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<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>alpha</artifactId>
-    <groupId>org.apache.servicecomb.pack</groupId>
-    <version>0.5.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>alpha-spring-boot-compatibility</artifactId>
-  <name>Pack::Alpha Spring Boot Compatibility</name>
-
-  <packaging>pom</packaging>
-  <modules>
-    <module>alpha-spring-boot-1-starter</module>
-    <module>alpha-spring-boot-2-starter</module>
-  </modules>
-
-</project>
diff --git a/alpha/pom.xml b/alpha/pom.xml
index 0be3f85..01969a7 100644
--- a/alpha/pom.xml
+++ b/alpha/pom.xml
@@ -34,7 +34,6 @@
     <module>alpha-core</module>
     <module>alpha-fsm</module>
     <module>alpha-benchmark</module>
-    <module>alpha-spring-boot-compatibility</module>
     <module>alpha-spring-cloud-starter-eureka</module>
     <module>alpha-spring-cloud-starter-consul</module>
     <module>alpha-spring-cloud-starter-zookeeper</module>