Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 5382ddbfd143639213a8b0a881400c72358de678 @rayzhang0603 rayzhang0603 committed Apr 20, 2016
Showing 506 changed files with 145,617 additions and 0 deletions.
@@ -0,0 +1,36 @@
+.target/
+.logs/
+*/logs/
+*/*/logs/
+*/target/
+
+# maven ignore
+target/
+*.war
+*.zip
+*.tar
+*.tar.gz
+
+# eclipse ignore
+.settings/
+.project
+.classpath
+
+# idea ignore
+.idea/
+*.ipr
+*.iml
+*.iws
+
+# temp ignore
+*.log
+*.cache
+*.diff
+*.patch
+*.tmp
+
+# system ignore
+.DS_Store
+Thumbs.db
+logs/
+bin/
@@ -0,0 +1 @@
+language: java
@@ -0,0 +1,13 @@
+Copyright 2009-2016 Weibo, Inc.
+
+All files licensed under the Apache License, Version 2.0 (the "License");
+you may not use these files 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.
@@ -0,0 +1,153 @@
+# Motan
+
+# Overview
+Motan is a remote procedure call(RPC) framework for rapid development of high performance distributed services.
+
+# Features
+- Create distributed services without writing extra code.
+- Provides cluster support and integrate with popular service discovery services like [Consul][consul] or [Zookeeper][zookeeper].
+- Supports advanced scheduling features like weighted load-balance, scheduling cross IDCs, etc.
+- Optimization for high load scenarios, provides high availability in production environment.
+
+# Quick Start
+
+The quick start gives very basic example of running client and server on the same machine. For the detailed information about using and developing Motan, please jump to [Documents](#documents).
+
+> The minimum requirements to run the quick start are:
+> * JDK 1.6 or above
+> * A java-based project management software like [Maven][maven] or [Gradle][gradle]
+
+1. Add dependency to pom
+
+ ```xml
+ <dependency>
+ <groupId>com.weibo</groupId>
+ <artifactId>motan-core</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.weibo</groupId>
+ <artifactId>motan-transport-netty</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <! -- only needed for spring-based features -->
+ <dependency>
+ <groupId>com.weibo</groupId>
+ <artifactId>motan-springsupport</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>4.2.4.RELEASE</version>
+ </dependency>
+ ```
+
+2. Create an interface for both service provider and consumer.
+
+ `src/main/java/quickstart/FooService.java`
+
+ ```java
+ package quickstart;
+
+ public interface FooService {
+ public String hello(String name);
+ }
+ ```
+
+3. Implement service provider.
+
+
+ `src/main/java/quickstart/FooServiceImpl.java`
+
+ ```java
+ package quickstart;
+
+ import org.springframework.context.ApplicationContext;
+ import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+ public class FooServiceImpl implements FooService {
+
+ public String hello(String name) {
+ System.out.println(name + " invoked rpc service");
+ return "hello " + name;
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
+ System.out.println("server start...");
+ Thread.sleep(Long.MAX_VALUE);
+ }
+ }
+ ```
+
+ `src/main/resources/motan_server.xml`
+
+ ```xml
+ <?xml version="1.0" encoding="UTF-8"?>
+ <beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:motan="http://api.weibo.com/schema/motan"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd">
+
+ <!-- service implemention bean -->
+ <bean id="serviceImpl" class="quickstart.FooServiceImpl" />
+ <!-- exporting service by motan -->
+ <motan:service interface="quickstart.FooService" ref="serviceImpl" export="8002" />
+ </beans>
+ ```
+
+ Execute main function in FooServiceImpl will start a motan server listening on port 8002.
+
+4. The service consumer
+
+ `src/main/resources/motan_client.xml`
+
+ ```xml
+ <?xml version="1.0" encoding="UTF-8"?>
+ <beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:motan="http://api.weibo.com/schema/motan"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd">
+
+ <!-- reference to the remote service -->
+ <motan:referer id="remoteService" interface="quickstart.FooService" directUrl="localhost:8002"/>
+ </beans>
+ ```
+
+ `src/main/java/quickstart/Client.java`
+
+ ```java
+ package quickstart;
+
+ import org.springframework.context.ApplicationContext;
+ import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+ public class Client {
+
+ public static void main(String[] args) throws InterruptedException {
+ ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:motan_client.xml");
+ FooService service = (FooService) ctx.getBean("remoteService");
+ System.out.println(service.hello("motan"));
+ }
+ }
+ ```
+
+ Execute main function in Client will invoke the remote service and print response.
+
+
+# Documents
+
+Coming soon...
+
+# License
+
+Motan is released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+[maven]:https://maven.apache.org
+[gradle]:http://gradle.org
+[consul]:http://www.consul.io
+[zookeeper]:http://zookeeper.apache.org
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2009-2016 Weibo, Inc.
+ ~
+ ~ Licensed 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>motan-benchmark</artifactId>
+ <groupId>com.weibo</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>motan-benchmark-api</artifactId>
+
+
+</project>
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2016 Weibo, Inc.
+ *
+ * Licensed 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 com.weibo.motan.benchmark;
+
+import java.util.List;
+import java.util.Map;
+
+public interface BenchmarkService {
+ Object echoService(Object request);
+
+ void emptyService();
+
+ public Map<Long, Integer> getUserTypes(List<Long> uids);
+
+ public long[] getLastStausIds(long[] uids);
+
+}
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009-2016 Weibo, Inc.
+ *
+ * Licensed 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 com.weibo.motan.benchmark;
+
+import com.alibaba.fastjson.JSON;
+
+import java.io.Serializable;
+
+public class FullName implements Serializable {
+ private String firstName;
+ private String lastName;
+
+ public FullName(String lastName, String firstName) {
+ this.lastName = lastName;
+ this.firstName = firstName;
+ }
+
+ @Override
+ public String toString() {
+ return JSON.toJSONString(this);
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
Oops, something went wrong.

0 comments on commit 5382ddb

Please sign in to comment.