Skip to content
Snippets Groups Projects
Commit 54c7b696 authored by 项升's avatar 项升
Browse files

Add more docs and modules

parent a16c8e53
No related branches found
No related tags found
No related merge requests found
Showing
with 229 additions and 33 deletions
...@@ -44,6 +44,14 @@ TBD ...@@ -44,6 +44,14 @@ TBD
TBD TBD
### 项目结构
- bootstrap 程序启动入口,不允许修改,评测时不依赖选手编译的 jar 包;
- internal-dubbo dubbo 依赖,不允许修改,评测时不依赖选手编译的 jar 包;
- internal-gateway gateway 依赖,不允许修改,评测时不依赖选手编译的 jar 包;
- internal-service 服务的接口定义和实现,不允许修改,评测时不依赖选手编译的 jar 包;
- workspace 选手进行开发的模块
### 开发接口 ### 开发接口
TBD TBD
......
<?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>adaptive-loadbalance</artifactId>
<groupId>com.aliware.tianchi</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bootstrap</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>workspace-gateway</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>workspace-provider</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>service-provider</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.aliware.tianchi;
import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author guohaoice@gmail.com
*/
public class GatewayApp {
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"dubbo-provider.xml"});
context.start();
System.in.read(); // press any key to exit
}
}
package com.aliware.tianchi;
import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author guohaoice@gmail.com
*/
public class ProviderApp {
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:dubbo-provider.xml"});
context.start();
System.in.read(); // press any key to exit
}
}
...@@ -10,4 +10,12 @@ ...@@ -10,4 +10,12 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>internal-dubbo</artifactId> <artifactId>internal-dubbo</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
...@@ -11,5 +11,11 @@ ...@@ -11,5 +11,11 @@
<artifactId>internal-gateway</artifactId> <artifactId>internal-gateway</artifactId>
<dependencies>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>internal-dubbo</artifactId>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
File moved
File moved
<?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>service</artifactId>
<groupId>com.aliware.tianchi</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>service-consumer</artifactId>
<dependencies>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>service-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.aliware.tianchi;
import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author guohaoice@gmail.com
*/
public class MyConsumer {
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:dubbo-consumer.xml"});
context.start();
HashInterface bean = context.getBean(HashInterface.class);
for (int i = 0; i < 10; i++) {
System.out.println(bean.hash("hahaha"));
}
System.in.read(); // press any key to exit
}
}
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<!-- consumer's application name, used for tracing dependency relationship (not a matching criterion),
don't set it same as provider -->
<dubbo:application name="demo-consumer"/>
<!-- use multicast registry center to discover service -->
<!--<dubbo:registry address="zookeeper://127.0.0.1:2181"/>-->
<!-- generate proxy for the remote service, then demoService can be used in the same way as the
local regular interface -->
<dubbo:reference id="directService" check="false" interface="com.aliware.tianchi.HashInterface" url="localhost:20880"/>
</beans>
\ No newline at end of file
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<dependency> <dependency>
<groupId>com.aliware.tianchi</groupId> <groupId>com.aliware.tianchi</groupId>
<artifactId>service-api</artifactId> <artifactId>service-api</artifactId>
<version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -36,7 +36,7 @@ public class HashServiceImpl implements HashInterface { ...@@ -36,7 +36,7 @@ public class HashServiceImpl implements HashInterface {
double cdf = 0; double cdf = 0;
while (u >= cdf) { while (u >= cdf) {
x++; x++;
cdf = 1 - Math.exp(-1.0 * 1 / averageRTT * x); cdf = 1 - Math.exp(-1.0D * 1 / averageRTT * x);
} }
return x; return x;
} }
......
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<!-- provider's application name, used for tracing dependency relationship -->
<dubbo:application name="demo-provider"/>
<!-- use multicast registry center to export service -->
<dubbo:registry address="multicast://224.5.6.7:1234"/>
<!-- use dubbo protocol to export service on port 20880 -->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- service implementation, as same as regular local bean -->
<bean id="demoService" class="com.aliware.tianchi.HashServiceImpl">
<constructor-arg index="0" value="10"/>
<constructor-arg index="1" value="10000000"/>
<constructor-arg index="2" value="salt-value"/>
</bean>
<!-- declare the service interface to be exported -->
<dubbo:service interface="com.aliware.tianchi.HashInterface" ref="demoService"/>
</beans>
\ No newline at end of file
...@@ -9,6 +9,53 @@ ...@@ -9,6 +9,53 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.0.0</version> <version>1.0.0</version>
<dependencyManagement>
<dependencies>
<!--internal start-->
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>internal-dubbo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>internal-gateway</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>service-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>service-consumer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>service-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>workspace-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aliware.tianchi</groupId>
<artifactId>workspace-gateway</artifactId>
<version>${project.version}</version>
</dependency>
<!--internal end-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.20.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
...@@ -26,6 +73,8 @@ ...@@ -26,6 +73,8 @@
<modules> <modules>
<module>internal-dubbo</module> <module>internal-dubbo</module>
<module>internal-gateway</module> <module>internal-gateway</module>
<module>service</module> <module>internal-service</module>
<module>bootstrap</module>
<module>workspace</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
package com.aliware.tianchi;
/**
* @author guohaoice@gmail.com
*/
public interface HashInterface {
int hash(String input);
}
package com.aliware;
/**
* @author guohaoice@gmail.com
*/
public class GatewayApp {
public static void main(String[] args) {
//
}
}
package com.aliware;
/**
* @author guohaoice@gmail.com
*/
public class ProviderApp {
public static void main(String[] args) {
//
}
}
# Workspace
选手在这个 module 下开发,其他 module 不允许修改。
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment