Browse Source

fix bug and code style

pull/3/MERGE
CalvinKirs 4 years ago
parent
commit
967ab641dd
  1. 15
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/serialize/ProtoStuffUtils.java
  2. 1
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/client/IRpcClient.java
  3. 1
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/client/RpcRequestTable.java
  4. 9
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/codec/NettyDecoder.java
  5. 7
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/codec/NettyEncoder.java
  6. 1
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/config/ServiceBean.java
  7. 4
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/remote/NettyServer.java

15
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/serialize/ProtoStuffUtils.java

@ -17,14 +17,14 @@
package org.apache.dolphinscheduler.remote.serialize; package org.apache.dolphinscheduler.remote.serialize;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import io.protostuff.LinkedBuffer; import io.protostuff.LinkedBuffer;
import io.protostuff.ProtostuffIOUtil; import io.protostuff.ProtostuffIOUtil;
import io.protostuff.Schema; import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema; import io.protostuff.runtime.RuntimeSchema;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* ProtoStuffUtils * ProtoStuffUtils
*/ */
@ -49,14 +49,7 @@ public class ProtoStuffUtils {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <T> Schema<T> getSchema(Class<T> clazz) { private static <T> Schema<T> getSchema(Class<T> clazz) {
Schema<T> schema = (Schema<T>) schemaCache.get(clazz); return (Schema<T>) schemaCache.computeIfAbsent(clazz, RuntimeSchema::createFrom);
if (schema == null) {
schema = RuntimeSchema.getSchema(clazz);
if (schema != null) {
schemaCache.put(clazz, schema);
}
}
return schema;
} }
public static <T> T deserialize(byte[] bytes, Class<T> clazz) { public static <T> T deserialize(byte[] bytes, Class<T> clazz) {

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

@ -24,7 +24,6 @@ import org.apache.dolphinscheduler.remote.utils.Host;
*/ */
public interface IRpcClient { public interface IRpcClient {
<T> T create(Class<T> clazz, Host host) throws Exception; <T> T create(Class<T> clazz, Host host) throws Exception;
} }

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

@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class RpcRequestTable { public class RpcRequestTable {
private static ConcurrentHashMap<String, RpcRequestCache> requestMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, RpcRequestCache> requestMap = new ConcurrentHashMap<>();
public static void put(String requestId, RpcRequestCache rpcRequestCache) { public static void put(String requestId, RpcRequestCache rpcRequestCache) {

9
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/codec/NettyDecoder.java

@ -17,14 +17,14 @@
package org.apache.dolphinscheduler.rpc.codec; package org.apache.dolphinscheduler.rpc.codec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils; import org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils;
import java.util.List; import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
/** /**
* NettyDecoder * NettyDecoder
*/ */
@ -32,7 +32,6 @@ public class NettyDecoder extends ByteToMessageDecoder {
private Class<?> genericClass; private Class<?> genericClass;
public NettyDecoder(Class<?> genericClass) { public NettyDecoder(Class<?> genericClass) {
this.genericClass = genericClass; this.genericClass = genericClass;
} }

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

@ -17,15 +17,14 @@
package org.apache.dolphinscheduler.rpc.codec; package org.apache.dolphinscheduler.rpc.codec;
import org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils;
/** /**
* @author jiangli * NettyEncoder
* @date 2021-01-12 18:52
*/ */
public class NettyEncoder extends MessageToByteEncoder { public class NettyEncoder extends MessageToByteEncoder {

1
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/config/ServiceBean.java

@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.reflections.Reflections; import org.reflections.Reflections;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

4
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/rpc/remote/NettyServer.java

@ -18,10 +18,10 @@
package org.apache.dolphinscheduler.rpc.remote; package org.apache.dolphinscheduler.rpc.remote;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.rpc.codec.NettyDecoder;
import org.apache.dolphinscheduler.rpc.codec.NettyEncoder;
import org.apache.dolphinscheduler.remote.utils.Constants; import org.apache.dolphinscheduler.remote.utils.Constants;
import org.apache.dolphinscheduler.remote.utils.NettyUtils; import org.apache.dolphinscheduler.remote.utils.NettyUtils;
import org.apache.dolphinscheduler.rpc.codec.NettyDecoder;
import org.apache.dolphinscheduler.rpc.codec.NettyEncoder;
import org.apache.dolphinscheduler.rpc.common.RpcRequest; import org.apache.dolphinscheduler.rpc.common.RpcRequest;
import org.apache.dolphinscheduler.rpc.common.RpcResponse; import org.apache.dolphinscheduler.rpc.common.RpcResponse;

Loading…
Cancel
Save