Browse Source

rpc

pull/3/MERGE
CalvinKirs 4 years ago
parent
commit
6fafcc2f0c
  1. 15
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/IUserService.java
  2. 2
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/MainTest.java
  3. 7
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/UserService.java
  4. 2
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/base/Rpc.java
  5. 10
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerConfig.java
  6. 1
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerInterceptor.java
  7. 2
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/common/ConsumerConfigConstants.java

15
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/IUserService.java

@ -1,15 +0,0 @@
package org.apache.dolphinscheduler.remote.rpc;
import org.apache.dolphinscheduler.remote.rpc.base.Rpc;
/**
* @author jiangli
* @date 2021-01-11 21:05
*/
public interface IUserService {
@Rpc(async = true,callback = UserCallback.class)
Boolean say(String sb);
String hi(int num);
}

2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/MainTest.java

@ -22,7 +22,7 @@ public class MainTest {
Host host = new Host("127.0.0.1", 12636); Host host = new Host("127.0.0.1", 12636);
IRpcClient rpcClient = new RpcClient(); IRpcClient rpcClient = new RpcClient();
IUserService userService = rpcClient.create(UserService.class, host); UserService userService = rpcClient.create(UserService.class, host);
boolean result = userService.say("calvin"); boolean result = userService.say("calvin");
System.out.println("异步回掉成功" + result); System.out.println("异步回掉成功" + result);

7
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/UserService.java

@ -6,14 +6,13 @@ import org.apache.dolphinscheduler.remote.rpc.base.Rpc;
* @author jiangli * @author jiangli
* @date 2021-01-11 21:05 * @date 2021-01-11 21:05
*/ */
public class UserService implements IUserService { public class UserService {
@Override
@Rpc(async = true, callback = UserCallback.class, retries = 9999, isOneway = false) @Rpc(async = true, callback = UserCallback.class, retries = 9999)
public Boolean say(String s) { public Boolean say(String s) {
return true; return true;
} }
@Override
public String hi(int num) { public String hi(int num) {
return "this world has " + num + "sun"; return "this world has " + num + "sun";
} }

2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/base/Rpc.java

@ -18,8 +18,6 @@ public @interface Rpc {
boolean async() default false; boolean async() default false;
boolean isOneway() default true;
Class<? extends AbstractRpcCallBack> callback() default AbstractRpcCallBack.class; Class<? extends AbstractRpcCallBack> callback() default AbstractRpcCallBack.class;
} }

10
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerConfig.java

@ -14,8 +14,6 @@ public class ConsumerConfig {
private Boolean async = ConsumerConfigConstants.DEFAULT_SYNC; private Boolean async = ConsumerConfigConstants.DEFAULT_SYNC;
private Boolean isOneway = ConsumerConfigConstants.DEFAULT_IS_ONEWAY;
private Integer retries = ConsumerConfigConstants.DEFAULT_RETRIES; private Integer retries = ConsumerConfigConstants.DEFAULT_RETRIES;
@ -43,14 +41,6 @@ public class ConsumerConfig {
this.async = async; this.async = async;
} }
public Boolean getOneway() {
return isOneway;
}
public void setOneway(Boolean oneway) {
isOneway = oneway;
}
public Integer getRetries() { public Integer getRetries() {
return retries; return retries;
} }

1
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerInterceptor.java

@ -86,7 +86,6 @@ public class ConsumerInterceptor {
consumerConfig.setAsync(rpc.async()); consumerConfig.setAsync(rpc.async());
consumerConfig.setCallBackClass(rpc.callback()); consumerConfig.setCallBackClass(rpc.callback());
consumerConfig.setRetries(rpc.retries()); consumerConfig.setRetries(rpc.retries());
consumerConfig.setOneway(rpc.isOneway());
} }
ConsumerConfigCache.putConfig(serviceName, consumerConfig); ConsumerConfigCache.putConfig(serviceName, consumerConfig);

2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/common/ConsumerConfigConstants.java

@ -8,7 +8,5 @@ public class ConsumerConfigConstants {
public static final Boolean DEFAULT_SYNC = false; public static final Boolean DEFAULT_SYNC = false;
public static final Boolean DEFAULT_IS_ONEWAY = false;
public static final Integer DEFAULT_RETRIES = 3; public static final Integer DEFAULT_RETRIES = 3;
} }

Loading…
Cancel
Save