Commit 43434383 authored by Yiming Liu's avatar Yiming Liu

Merge pull request #190 from yiming187/assembly_update

Integrate all server side components into one application
parents 2e76a342 b3ad70f3
package com.ctrip.apollo; package com.ctrip.apollo.adminservice;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter; import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter; import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
@SpringBootApplication
@EnableEurekaClient
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableEurekaClient
@Configuration
@PropertySource(value = {"classpath:adminservice.properties"})
@EnableAutoConfiguration
@ComponentScan(basePackageClasses = {com.ctrip.apollo.common.ApolloCommonConfig.class,
com.ctrip.apollo.biz.ApolloBizConfig.class,
com.ctrip.apollo.adminservice.AdminServiceApplication.class})
public class AdminServiceApplication { public class AdminServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(AdminServiceApplication.class).run(args); ConfigurableApplicationContext context =
new SpringApplicationBuilder(AdminServiceApplication.class).run(args);
context.addApplicationListener(new ApplicationPidFileWriter()); context.addApplicationListener(new ApplicationPidFileWriter());
context.addApplicationListener(new EmbeddedServerPortFileWriter()); context.addApplicationListener(new EmbeddedServerPortFileWriter());
} }
......
package com.ctrip.apollo.adminservice.controller; package com.ctrip.apollo.adminservice.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
......
spring.application.name= apollo-adminservice
ctrip.appid= 100003172
server.port= 8090
logging.file= /opt/logs/100003172/apollo-adminservice.log
\ No newline at end of file
spring:
application:
name: apollo-adminservice
profiles:
active: ctrip
server:
port: ${port:8090}
logging:
level:
org.springframework.cloud: 'DEBUG'
file: /opt/logs/${ctrip.appid}/apollo-adminservice.log
ctrip:
appid: 100003172
...@@ -8,6 +8,8 @@ import org.springframework.context.annotation.ComponentScan.Filter; ...@@ -8,6 +8,8 @@ import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import com.ctrip.apollo.adminservice.AdminServiceApplication;
@Configuration @Configuration
@ComponentScan(excludeFilters = {@Filter(type = FilterType.ASSIGNABLE_TYPE, value = { @ComponentScan(excludeFilters = {@Filter(type = FilterType.ASSIGNABLE_TYPE, value = {
SampleAdminServiceApplication.class, AdminServiceApplication.class, SampleAdminServiceApplication.class, AdminServiceApplication.class,
......
package com.ctrip.apollo.adminservice.controller; package com.ctrip.apollo.adminservice.controller;
import com.ctrip.apollo.AdminServiceTestConfiguration; import javax.annotation.PostConstruct;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate; import org.springframework.boot.test.TestRestTemplate;
import org.springframework.boot.test.WebIntegrationTest; import org.springframework.boot.test.WebIntegrationTest;
...@@ -11,18 +13,22 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -11,18 +13,22 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.DefaultResponseErrorHandler; import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct; import com.ctrip.apollo.AdminServiceTestConfiguration;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = AdminServiceTestConfiguration.class) @SpringApplicationConfiguration(classes = AdminServiceTestConfiguration.class)
@WebIntegrationTest(randomPort = true) @WebIntegrationTest(randomPort = true)
public abstract class AbstractControllerTest { public abstract class AbstractControllerTest {
@Autowired
private HttpMessageConverters httpMessageConverters;
RestTemplate restTemplate = new TestRestTemplate("apollo", ""); RestTemplate restTemplate = new TestRestTemplate("apollo", "");
@PostConstruct @PostConstruct
private void postConstruct() { private void postConstruct() {
restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
restTemplate.setMessageConverters(httpMessageConverters.getConverters());
} }
@Value("${local.server.port}") @Value("${local.server.port}")
......
...@@ -10,6 +10,7 @@ import org.springframework.http.HttpStatus; ...@@ -10,6 +10,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.web.client.RestTemplate;
import com.ctrip.apollo.biz.entity.Item; import com.ctrip.apollo.biz.entity.Item;
import com.ctrip.apollo.biz.repository.ItemRepository; import com.ctrip.apollo.biz.repository.ItemRepository;
...@@ -45,8 +46,9 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -45,8 +46,9 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName()); Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets itemSet = new ItemChangeSets(); ItemChangeSets itemSet = new ItemChangeSets();
restTemplate = new TestRestTemplate("created", ""); RestTemplate createdTemplate = new TestRestTemplate("created", "");
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3; int createdSize = 3;
for (int i = 0; i < createdSize; i++) { for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO(); ItemDTO item = new ItemDTO();
...@@ -57,7 +59,7 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -57,7 +59,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
} }
ResponseEntity<Void> response = ResponseEntity<Void> response =
restTemplate.postForEntity( createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/itemset", + cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
itemSet, Void.class); itemSet, Void.class);
...@@ -92,7 +94,8 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -92,7 +94,8 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName()); Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets(); ItemChangeSets createChangeSet = new ItemChangeSets();
restTemplate = new TestRestTemplate("created", ""); RestTemplate createdRestTemplate = new TestRestTemplate("created", "");
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3; int createdSize = 3;
for (int i = 0; i < createdSize; i++) { for (int i = 0; i < createdSize; i++) {
...@@ -103,20 +106,21 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -103,20 +106,21 @@ public class ItemSetControllerTest extends AbstractControllerTest {
createChangeSet.addCreateItem(item); createChangeSet.addCreateItem(item);
} }
ResponseEntity<Void> response = restTemplate.postForEntity( ResponseEntity<Void> response = createdRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset", + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class); createChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ItemDTO[] items = ItemDTO[] items =
restTemplate.getForObject( createdRestTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items", + cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class); ItemDTO[].class);
ItemChangeSets udpateChangeSet = new ItemChangeSets(); ItemChangeSets udpateChangeSet = new ItemChangeSets();
restTemplate = new TestRestTemplate("updated", ""); RestTemplate updatedRestTemplate = new TestRestTemplate("updated", "");
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int updatedSize = 2; int updatedSize = 2;
for (int i = 0; i < updatedSize; i++) { for (int i = 0; i < updatedSize; i++) {
...@@ -124,7 +128,7 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -124,7 +128,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
udpateChangeSet.addUpdateItem(items[i]); udpateChangeSet.addUpdateItem(items[i]);
} }
response = restTemplate.postForEntity( response = updatedRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset", + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
udpateChangeSet, Void.class); udpateChangeSet, Void.class);
...@@ -161,7 +165,8 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -161,7 +165,8 @@ public class ItemSetControllerTest extends AbstractControllerTest {
Assert.assertEquals("application", namespace.getNamespaceName()); Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets(); ItemChangeSets createChangeSet = new ItemChangeSets();
restTemplate = new TestRestTemplate("created", ""); RestTemplate createdTemplate = new TestRestTemplate("created", "");
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3; int createdSize = 3;
for (int i = 0; i < createdSize; i++) { for (int i = 0; i < createdSize; i++) {
...@@ -172,7 +177,7 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -172,7 +177,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
createChangeSet.addCreateItem(item); createChangeSet.addCreateItem(item);
} }
ResponseEntity<Void> response = restTemplate.postForEntity( ResponseEntity<Void> response = createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset", + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class); createChangeSet, Void.class);
...@@ -185,7 +190,8 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -185,7 +190,8 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemDTO[].class); ItemDTO[].class);
ItemChangeSets deleteChangeSet = new ItemChangeSets(); ItemChangeSets deleteChangeSet = new ItemChangeSets();
restTemplate = new TestRestTemplate("deleted", ""); RestTemplate deletedTemplate = new TestRestTemplate("deleted", "");
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
int deletedSize = 1; int deletedSize = 1;
for (int i = 0; i < deletedSize; i++) { for (int i = 0; i < deletedSize; i++) {
...@@ -193,7 +199,7 @@ public class ItemSetControllerTest extends AbstractControllerTest { ...@@ -193,7 +199,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
deleteChangeSet.addDeleteItem(items[i]); deleteChangeSet.addDeleteItem(items[i]);
} }
response = restTemplate.postForEntity( response = deletedTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() "http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset", + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
deleteChangeSet, Void.class); deleteChangeSet, Void.class);
......
<?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>
<properties>
<github.path>${project.artifactId}</github.path>
</properties>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-configservice</artifactId>
</dependency>
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-adminservice</artifactId>
</dependency>
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-portal</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-${package.environment}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/assembly-descriptor.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>apollo-assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!--scripts -->
<fileSet>
<directory>src/main/scripts</directory>
<outputDirectory>scripts</outputDirectory>
<includes>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
<excludes>
<exclude>apollo-assembly.conf</exclude>
</excludes>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>apollo-assembly.conf</include>
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
<!--artifact -->
<fileSet>
<directory>target</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.artifactId}-*.jar</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
</assembly>
MODE=service
PID_FOLDER=.
LOG_FOLDER=/opt/logs/100003171/
\ No newline at end of file
appId=100003171
jdkVersion=1.8
\ No newline at end of file
package com.ctrip.apollo.assembly;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import com.ctrip.apollo.adminservice.AdminServiceApplication;
import com.ctrip.apollo.configservice.ConfigServiceApplication;
import com.ctrip.apollo.portal.PortalApplication;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
public class ApolloApplication {
private static final Logger logger = LoggerFactory.getLogger(ApolloApplication.class);
public static void main(String[] args) throws Exception {
/**
* Common
*/
ConfigurableApplicationContext commonContext =
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
commonContext.addApplicationListener(new ApplicationPidFileWriter());
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
/**
* ConfigService
*/
if (commonContext.getEnvironment().containsProperty("configservice")) {
ConfigurableApplicationContext configContext =
new SpringApplicationBuilder(ConfigServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(configContext.getId() + " isActive: " + configContext.isActive());
}
/**
* AdminService
*/
if (commonContext.getEnvironment().containsProperty("adminservice")) {
ConfigurableApplicationContext adminContext =
new SpringApplicationBuilder(AdminServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(adminContext.getId() + " isActive: " + adminContext.isActive());
}
/**
* Portal
*/
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext).run(args);
logger.info(portalContext.getId() + " isActive: " + portalContext.isActive());
}
}
}
spring: spring:
application:
name: apollo-configservice
profiles: profiles:
active: ctrip active: ctrip
server:
port: ${port:8080}
logging: logging:
level: level:
org.springframework.cloud: 'DEBUG' org.springframework.cloud: 'DEBUG'
file: /opt/logs/${ctrip.appid}/apollo-configservice.log file: /opt/logs/100003171/apollo-assembly.log
\ No newline at end of file
ctrip:
appid: 100003171
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}apollo-assembly.log}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
SERVICE_NAME=apollo-assembly
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
fi
cd `dirname $0`/..
if [[ ! -f $SERVICE_NAME".jar" && -d current ]]; then
cd current
fi
if [[ -f $SERVICE_NAME".jar" ]]; then
chmod a+x $SERVICE_NAME".jar"
./$SERVICE_NAME".jar" stop
fi
#!/bin/bash
SERVICE_NAME=apollo-assembly
VERSION=0.0.1-SNAPSHOT
PATH_TO_JAR=$SERVICE_NAME"-"$VERSION".jar"
export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22 -XX:+UseParNewGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:-ReduceInitialCardMarks -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingPermOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrent -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8"
export JAVA_OPTS="$JAVA_OPTS -Xloggc:/opt/logs/100003171/heap_trace.txt -XX:HeapDumpPath=/opt/logs/100003171/HeapDumpOnOutOfMemoryError/"
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
fi
cd `dirname $0`/..
if [[ ! -f PATH_TO_JAR && -d current ]]; then
cd current
fi
if [[ -f $SERVICE_NAME".jar" ]]; then
rm -rf $SERVICE_NAME".jar"
fi
ln $PATH_TO_JAR $SERVICE_NAME".jar"
chmod a+x $SERVICE_NAME".jar"
./$SERVICE_NAME".jar" start
exit 0;
package com.ctrip.apollo.biz;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@EnableAutoConfiguration
@Configuration
@ComponentScan(basePackageClasses = com.ctrip.apollo.biz.ApolloBizConfig.class)
public class ApolloBizConfig {
}
...@@ -8,6 +8,7 @@ import com.ctrip.apollo.biz.repository.ServerConfigRepository; ...@@ -8,6 +8,7 @@ import com.ctrip.apollo.biz.repository.ServerConfigRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -15,6 +16,7 @@ import java.util.List; ...@@ -15,6 +16,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Component @Component
@Primary
public class ApolloEurekaClientConfig extends EurekaClientConfigBean { public class ApolloEurekaClientConfig extends EurekaClientConfigBean {
static final String EUREKA_URL_CONFIG = "eureka.service.url"; static final String EUREKA_URL_CONFIG = "eureka.service.url";
private static final Splitter URL_SPLITTER = Splitter.on(",").omitEmptyStrings(); private static final Splitter URL_SPLITTER = Splitter.on(",").omitEmptyStrings();
......
package com.ctrip.apollo.common;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@EnableAutoConfiguration
@Configuration
@ComponentScan(basePackageClasses = com.ctrip.apollo.common.ApolloCommonConfig.class)
public class ApolloCommonConfig {
}
package com.ctrip.apollo; package com.ctrip.apollo.configservice;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter; import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter; import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/** /**
* Spring boot application entry point * Spring boot application entry point
* *
* @author Jason Song(song_s@ctrip.com) * @author Jason Song(song_s@ctrip.com)
*/ */
@SpringBootApplication
@EnableEurekaServer @EnableEurekaServer
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableAutoConfiguration//(exclude = EurekaClientConfigBean.class)
@Configuration
@PropertySource(value = {"classpath:configservice.properties"})
@ComponentScan(basePackageClasses = {com.ctrip.apollo.common.ApolloCommonConfig.class,
com.ctrip.apollo.biz.ApolloBizConfig.class,
com.ctrip.apollo.configservice.ConfigServiceApplication.class})
public class ConfigServiceApplication { public class ConfigServiceApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
......
package com.ctrip.apollo; package com.ctrip.apollo.configservice;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
......
spring.application.name= apollo-configservice
ctrip.appid= 100003171
server.port= 8080
logging.file= /opt/logs/100003171/apollo-configservice.log
\ No newline at end of file
package com.ctrip.apollo; package com.ctrip.apollo;
import com.ctrip.apollo.common.controller.WebSecurityConfig; import com.ctrip.apollo.common.controller.WebSecurityConfig;
import com.ctrip.apollo.configservice.ConfigServiceApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
......
package com.ctrip.apollo; package com.ctrip.apollo.portal;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter; import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter; import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@SpringBootApplication @EnableAutoConfiguration
@Configuration
@PropertySource(value = {"classpath:portal.properties"})
@ComponentScan(basePackageClasses = {com.ctrip.apollo.common.ApolloCommonConfig.class,
com.ctrip.apollo.portal.PortalApplication.class})
public class PortalApplication { public class PortalApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
......
...@@ -18,16 +18,16 @@ import com.ctrip.apollo.core.exception.BadRequestException; ...@@ -18,16 +18,16 @@ import com.ctrip.apollo.core.exception.BadRequestException;
import com.ctrip.apollo.core.utils.StringUtils; import com.ctrip.apollo.core.utils.StringUtils;
import com.ctrip.apollo.portal.PortalSettings; import com.ctrip.apollo.portal.PortalSettings;
import com.ctrip.apollo.portal.entity.EnvClusterInfo; import com.ctrip.apollo.portal.entity.EnvClusterInfo;
import com.ctrip.apollo.portal.service.AppService; import com.ctrip.apollo.portal.service.PortalAppService;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/apps") @RequestMapping("/apps")
public class AppController { public class PortalAppController {
@Autowired @Autowired
private AppService appService; private PortalAppService appService;
@Autowired @Autowired
private PortalSettings portalSettings; private PortalSettings portalSettings;
......
...@@ -10,7 +10,7 @@ import com.ctrip.apollo.portal.entity.ItemDiffs; ...@@ -10,7 +10,7 @@ import com.ctrip.apollo.portal.entity.ItemDiffs;
import com.ctrip.apollo.portal.entity.form.NamespaceSyncModel; import com.ctrip.apollo.portal.entity.form.NamespaceSyncModel;
import com.ctrip.apollo.portal.entity.form.NamespaceTextModel; import com.ctrip.apollo.portal.entity.form.NamespaceTextModel;
import com.ctrip.apollo.portal.entity.form.NamespaceReleaseModel; import com.ctrip.apollo.portal.entity.form.NamespaceReleaseModel;
import com.ctrip.apollo.portal.service.ConfigService; import com.ctrip.apollo.portal.service.PortalConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -25,10 +25,10 @@ import java.util.List; ...@@ -25,10 +25,10 @@ import java.util.List;
@RestController @RestController
@RequestMapping("") @RequestMapping("")
public class ConfigController { public class PortalConfigController {
@Autowired @Autowired
private ConfigService configService; private PortalConfigService configService;
@RequestMapping(value = "/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.PUT, consumes = { @RequestMapping(value = "/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.PUT, consumes = {
"application/json"}) "application/json"})
......
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/envs") @RequestMapping("/envs")
public class EnvController { public class PortalEnvController {
@Autowired @Autowired
private PortalSettings portalSettings; private PortalSettings portalSettings;
......
...@@ -6,7 +6,7 @@ import com.ctrip.apollo.core.enums.Env; ...@@ -6,7 +6,7 @@ import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.core.exception.BadRequestException; import com.ctrip.apollo.core.exception.BadRequestException;
import com.ctrip.apollo.core.utils.StringUtils; import com.ctrip.apollo.core.utils.StringUtils;
import com.ctrip.apollo.portal.entity.NamespaceVO; import com.ctrip.apollo.portal.entity.NamespaceVO;
import com.ctrip.apollo.portal.service.NamespaceService; import com.ctrip.apollo.portal.service.PortalNamespaceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -18,10 +18,10 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,10 +18,10 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController @RestController
public class NamespaceController { public class PortalNamespaceController {
@Autowired @Autowired
private NamespaceService namespaceService; private PortalNamespaceService namespaceService;
@RequestMapping("/appnamespaces/public") @RequestMapping("/appnamespaces/public")
public List<AppNamespaceDTO> findPublicAppNamespaces(){ public List<AppNamespaceDTO> findPublicAppNamespaces(){
......
...@@ -20,9 +20,12 @@ import com.ctrip.apollo.portal.api.AdminServiceAPI; ...@@ -20,9 +20,12 @@ import com.ctrip.apollo.portal.api.AdminServiceAPI;
import com.ctrip.apollo.portal.entity.EnvClusterInfo; import com.ctrip.apollo.portal.entity.EnvClusterInfo;
@Service @Service
public class AppService { public class PortalAppService {
private Logger logger = LoggerFactory.getLogger(AppService.class); private Logger logger = LoggerFactory.getLogger(PortalAppService.class);
@Autowired
private PortalClusterService clusterService;
@Autowired @Autowired
private PortalSettings portalSettings; private PortalSettings portalSettings;
...@@ -30,8 +33,6 @@ public class AppService { ...@@ -30,8 +33,6 @@ public class AppService {
@Autowired @Autowired
private AdminServiceAPI.AppAPI appAPI; private AdminServiceAPI.AppAPI appAPI;
@Autowired ClusterService clusterService;
public List<AppDTO> findAll(Env env) { public List<AppDTO> findAll(Env env) {
return appAPI.findApps(env); return appAPI.findApps(env);
} }
......
...@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service; ...@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@Service @Service
public class ClusterService { public class PortalClusterService {
@Autowired @Autowired
private AdminServiceAPI.ClusterAPI clusterAPI; private AdminServiceAPI.ClusterAPI clusterAPI;
......
...@@ -36,9 +36,9 @@ import java.util.List; ...@@ -36,9 +36,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
public class ConfigService { public class PortalConfigService {
private Logger logger = LoggerFactory.getLogger(ConfigService.class); private Logger logger = LoggerFactory.getLogger(PortalConfigService.class);
@Autowired @Autowired
private AdminServiceAPI.NamespaceAPI namespaceAPI; private AdminServiceAPI.NamespaceAPI namespaceAPI;
......
...@@ -28,9 +28,9 @@ import java.util.List; ...@@ -28,9 +28,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
public class NamespaceService { public class PortalNamespaceService {
private Logger logger = LoggerFactory.getLogger(NamespaceService.class); private Logger logger = LoggerFactory.getLogger(PortalNamespaceService.class);
@Autowired @Autowired
private AdminServiceAPI.ItemAPI itemAPI; private AdminServiceAPI.ItemAPI itemAPI;
......
server:
port: 8070
spring:
application:
name: apollo-portal
profiles:
active: ctrip
logging:
level:
org.springframework.cloud: 'DEBUG'
file: /opt/logs/${ctrip.appid}/apollo-portal.log
ctrip:
appid: 100003173
apollo:
portal:
env: dev,fat,uat
spring.application.name= apollo-portal
apollo.portal.env= dev,fat,uat
ctrip.appid= 100003173
server.port= 8070
logging.file= /opt/logs/100003173/apollo-portal.log
\ No newline at end of file
package com.ctrip.apollo.portal; package com.ctrip.apollo.portal;
import com.ctrip.apollo.PortalApplication; import com.ctrip.apollo.portal.PortalApplication;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
......
...@@ -9,7 +9,7 @@ import com.ctrip.apollo.portal.api.AdminServiceAPI; ...@@ -9,7 +9,7 @@ import com.ctrip.apollo.portal.api.AdminServiceAPI;
import com.ctrip.apollo.portal.entity.ItemDiffs; import com.ctrip.apollo.portal.entity.ItemDiffs;
import com.ctrip.apollo.portal.entity.NamespaceIdentifer; import com.ctrip.apollo.portal.entity.NamespaceIdentifer;
import com.ctrip.apollo.portal.entity.form.NamespaceTextModel; import com.ctrip.apollo.portal.entity.form.NamespaceTextModel;
import com.ctrip.apollo.portal.service.ConfigService; import com.ctrip.apollo.portal.service.PortalConfigService;
import com.ctrip.apollo.portal.service.txtresolver.PropertyResolver; import com.ctrip.apollo.portal.service.txtresolver.PropertyResolver;
import org.junit.Assert; import org.junit.Assert;
...@@ -39,7 +39,7 @@ public class ConfigServiceTest { ...@@ -39,7 +39,7 @@ public class ConfigServiceTest {
private PropertyResolver resolver; private PropertyResolver resolver;
@InjectMocks @InjectMocks
private ConfigService configService; private PortalConfigService configService;
@Before @Before
public void setup() { public void setup() {
......
...@@ -6,7 +6,7 @@ import com.ctrip.apollo.core.dto.ReleaseDTO; ...@@ -6,7 +6,7 @@ import com.ctrip.apollo.core.dto.ReleaseDTO;
import com.ctrip.apollo.core.enums.Env; import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.portal.api.AdminServiceAPI; import com.ctrip.apollo.portal.api.AdminServiceAPI;
import com.ctrip.apollo.portal.entity.NamespaceVO; import com.ctrip.apollo.portal.entity.NamespaceVO;
import com.ctrip.apollo.portal.service.NamespaceService; import com.ctrip.apollo.portal.service.PortalNamespaceService;
import com.ctrip.apollo.portal.service.txtresolver.PropertyResolver; import com.ctrip.apollo.portal.service.txtresolver.PropertyResolver;
import org.junit.Before; import org.junit.Before;
...@@ -35,7 +35,7 @@ public class NamespaceServiceTest { ...@@ -35,7 +35,7 @@ public class NamespaceServiceTest {
private PropertyResolver resolver; private PropertyResolver resolver;
@InjectMocks @InjectMocks
private NamespaceService namespaceService; private PortalNamespaceService namespaceService;
@Before @Before
public void setup() { public void setup() {
......
...@@ -26,13 +26,13 @@ import com.ctrip.apollo.core.dto.AppDTO; ...@@ -26,13 +26,13 @@ import com.ctrip.apollo.core.dto.AppDTO;
import com.ctrip.apollo.core.enums.Env; import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.core.exception.ServiceException; import com.ctrip.apollo.core.exception.ServiceException;
import com.ctrip.apollo.portal.api.AdminServiceAPI; import com.ctrip.apollo.portal.api.AdminServiceAPI;
import com.ctrip.apollo.portal.service.AppService; import com.ctrip.apollo.portal.service.PortalAppService;
import com.google.gson.Gson; import com.google.gson.Gson;
public class ServiceExceptionTest extends AbstractPortalTest { public class ServiceExceptionTest extends AbstractPortalTest {
@Autowired @Autowired
private AppService appService; private PortalAppService appService;
@Mock @Mock
private AdminServiceAPI.AppAPI appAPI; private AdminServiceAPI.AppAPI appAPI;
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<module>apollo-configservice</module> <module>apollo-configservice</module>
<module>apollo-adminservice</module> <module>apollo-adminservice</module>
<module>apollo-portal</module> <module>apollo-portal</module>
<module>apollo-assembly</module>
<module>apollo-demo</module> <module>apollo-demo</module>
</modules> </modules>
...@@ -120,6 +121,21 @@ ...@@ -120,6 +121,21 @@
<artifactId>apollo-buildtools</artifactId> <artifactId>apollo-buildtools</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-configservice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-adminservice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-portal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.ctrip.framework</groupId> <groupId>com.ctrip.framework</groupId>
<artifactId>framework-foundation</artifactId> <artifactId>framework-foundation</artifactId>
...@@ -234,7 +250,7 @@ ...@@ -234,7 +250,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.3.RELEASE</version> <version>1.3.4.RELEASE</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
...@@ -259,7 +275,7 @@ ...@@ -259,7 +275,7 @@
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>6.17</version> <version>6.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ctrip.apollo</groupId> <groupId>com.ctrip.apollo</groupId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment