瀏覽代碼

Merge MetaServer into ConfigServer

Yiming Liu 9 年之前
父節點
當前提交
53ed634283

+ 0 - 13
apollo-assembly/pom.xml

@@ -1,13 +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/maven-v4_0_0.xsd">
-	<parent>
-		<groupId>com.ctrip.apollo</groupId>
-		<artifactId>apollo</artifactId>
-		<version>0.0.1-SNAPSHOT</version>
-		<relativePath>../pom.xml</relativePath>
-	</parent>
-	<modelVersion>4.0.0</modelVersion>
-	<artifactId>apollo-assembly</artifactId>
-	<name>Apollo Assembly</name>
-</project>

+ 67 - 0
apollo-configadmin/pom.xml

@@ -0,0 +1,67 @@
+<?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/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>com.ctrip.apollo</groupId>
+		<artifactId>apollo</artifactId>
+		<version>0.0.1-SNAPSHOT</version>
+		<relativePath>../pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>apollo-configadmin</artifactId>
+	<name>Apollo ConfigAdmin</name>
+	<dependencies>
+        <!-- apollo -->
+		<dependency>
+			<groupId>com.ctrip.apollo</groupId>
+			<artifactId>apollo-biz</artifactId>
+		</dependency>
+        <!-- end of apollo -->
+        <!-- web -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- end of web -->
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.data</groupId>
+            <artifactId>spring-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+        </dependency>
+        <!-- end of redis -->
+        <!-- eureka -->
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-eureka</artifactId>
+		</dependency>
+        <!-- end of eureka -->
+        <!-- jsp -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!-- end of jsp -->
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+</project>

+ 14 - 0
apollo-configadmin/src/main/java/com/ctrip/apollo/configadmin/AdminServiceApplication.java

@@ -0,0 +1,14 @@
+package com.ctrip.apollo.configadmin;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+
+
+@SpringBootApplication
+@EnableEurekaClient
+public class AdminServiceApplication {
+    public static void main(String[] args) {
+      new SpringApplicationBuilder(AdminServiceApplication.class).web(true).run(args);
+    }
+}

+ 12 - 0
apollo-configadmin/src/main/resources/application.yml

@@ -0,0 +1,12 @@
+spring:
+  application:
+    name: apollo-configadmin
+    
+server:
+  port: 9080
+  
+logging:
+  level:
+    org.springframework.cloud: 'DEBUG'
+  file: /opt/logs/apollo-configadmin.log
+

+ 1 - 4
apollo-metaserver/src/main/resources/bootstrap.yml → apollo-configadmin/src/main/resources/bootstrap.yml

@@ -1,6 +1,3 @@
-server:
-  port: 8761
-  
 eureka:
   instance:
     hostname: localhost
@@ -8,4 +5,4 @@ eureka:
     serviceUrl:
       defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
     healthcheck:
-      enabled: true
+      enabled: true

+ 1 - 1
apollo-configserver/pom.xml

@@ -42,7 +42,7 @@
         <!-- eureka -->
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-eureka</artifactId>
+			<artifactId>spring-cloud-starter-eureka-server</artifactId>
 		</dependency>
         <!-- end of eureka -->
         <!-- jsp -->

+ 6 - 4
apollo-configserver/src/main/java/com/ctrip/apollo/ServerApplication.java

@@ -1,17 +1,19 @@
 package com.ctrip.apollo;
 
-import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
 
 /**
  * Spring boot application entry point
  * @author Jason Song(song_s@ctrip.com)
  */
 @SpringBootApplication
-@EnableDiscoveryClient
+@EnableEurekaServer
+@EnableEurekaClient
 public class ServerApplication {
     public static void main(String[] args) {
-        SpringApplication.run(ServerApplication.class, args);
+      new SpringApplicationBuilder(ServerApplication.class).web(true).run(args);
     }
 }

+ 0 - 0
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/controller/ServiceController.java → apollo-configserver/src/main/java/com/ctrip/apollo/metaserver/controller/ServiceController.java


+ 0 - 0
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java → apollo-configserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java


+ 5 - 1
apollo-configserver/src/main/resources/application.yml

@@ -1,5 +1,9 @@
+spring:
+  application:
+    name: apollo-configserver
+    
 server:
-  port: 8888
+  port: 80
   
 logging:
   level:

+ 3 - 4
apollo-configserver/src/main/resources/bootstrap.yml

@@ -1,9 +1,8 @@
-spring:
-  application:
-    name: apollo-configserver
 eureka:
   instance:
     hostname: localhost
   client:
     serviceUrl:
-      defaultZone: http://${eureka.instance.hostname}:8761/eureka/
+      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
+    healthcheck:
+      enabled: true

+ 0 - 31
apollo-metaserver/pom.xml

@@ -1,31 +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/maven-v4_0_0.xsd">
-	<parent>
-		<groupId>com.ctrip.apollo</groupId>
-		<artifactId>apollo</artifactId>
-		<version>0.0.1-SNAPSHOT</version>
-		<relativePath>../pom.xml</relativePath>
-	</parent>
-	<modelVersion>4.0.0</modelVersion>
-	<artifactId>apollo-metaserver</artifactId>
-	<name>Apollo MetaServer</name>
-	<dependencies>
-		<dependency>
-			<groupId>com.ctrip.apollo</groupId>
-			<artifactId>apollo-core</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-eureka-server</artifactId>
-		</dependency>
-	</dependencies>
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-			</plugin>
-		</plugins>
-	</build>
-</project>

+ 0 - 16
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java

@@ -1,16 +0,0 @@
-package com.ctrip.apollo.metaserver;
-
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
-
-@SpringBootApplication
-@EnableEurekaServer
-@EnableEurekaClient
-public class MetaServerApplication {
-
-  public static void main(String[] args) {
-    new SpringApplicationBuilder(MetaServerApplication.class).web(true).run(args);
-  }
-}

+ 0 - 11
apollo-metaserver/src/main/resources/application.yml

@@ -1,11 +0,0 @@
-spring:
-  application:
-    name: apollo-metaserver
-  profiles:
-    active: native
-    
-logging:
-  level:
-
-
-      

+ 0 - 11
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AbstractMetaServerTest.java

@@ -1,11 +0,0 @@
-package com.ctrip.apollo.metaserver;
-
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(classes = MetaServerApplication.class)
-public abstract class AbstractMetaServerTest {
-
-}

+ 0 - 13
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AllTests.java

@@ -1,13 +0,0 @@
-package com.ctrip.apollo.metaserver;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({
-
-})
-public class AllTests {
-
-}

+ 0 - 37
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/controller/DiscoveryControllerTest.java

@@ -1,37 +0,0 @@
-package com.ctrip.apollo.metaserver.controller;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.TestRestTemplate;
-import org.springframework.boot.test.WebIntegrationTest;
-import org.springframework.web.client.RestTemplate;
-
-import com.ctrip.apollo.core.ServiceIdConsts;
-import com.ctrip.apollo.metaserver.AbstractMetaServerTest;
-import com.netflix.appinfo.InstanceInfo;
-
-
-@WebIntegrationTest
-public class DiscoveryControllerTest extends AbstractMetaServerTest {
-
-  RestTemplate restTemplate = new TestRestTemplate();
-
-  @Value("${local.server.port}")
-  String serverPort;
-
-  @Test
-  public void testGetMetaServerServices() throws InterruptedException, URISyntaxException {
-    // Wait Eureka Client to fresh meta
-    Thread.sleep(5000);
-
-    URI uri = new URI("http://localhost:" + serverPort + "/services/meta");
-    InstanceInfo[] serviceInstances = restTemplate.getForObject(uri, InstanceInfo[].class);
-    Assert.assertEquals(1, serviceInstances.length);
-    Assert.assertEquals(ServiceIdConsts.APOLLO_METASERVER,
-        serviceInstances[0].getAppName().toLowerCase());
-  }
-}

+ 0 - 5
apollo-metaserver/src/test/resources/application.yml

@@ -1,5 +0,0 @@
-spring:
-  application:
-    name: apollo-metaserver
-  profiles:
-    active: native

+ 0 - 14
apollo-metaserver/src/test/resources/bootstrap.yml

@@ -1,14 +0,0 @@
-server:
-  port: 8761
-  
-eureka:
-  instance:
-    hostname: localhost
-    leaseRenewalIntervalInSeconds: 1
-  client:
-   # initialInstanceInfoReplicationIntervalSeconds: 1
-    registryFetchIntervalSeconds: 2
-    serviceUrl:
-      defaultZone: http://${eureka.instance.hostname}:${server.port:8761}/eureka/
-    healthcheck:
-      enabled: true

+ 2 - 3
pom.xml

@@ -65,13 +65,12 @@
 	</properties>
 	<modules>
 		<module>apollo-core</module>
-		<module>apollo-metaserver</module>
 		<module>apollo-client</module>
+		<module>apollo-biz</module>
 		<module>apollo-configserver</module>
+		<module>apollo-configadmin</module>
 		<module>apollo-portal</module>
-		<module>apollo-assembly</module>
 		<module>apollo-demo</module>
-		<module>apollo-biz</module>
 	</modules>
 	<dependencyManagement>
 		<dependencies>