|
|
@ -24,6 +24,8 @@ import io.netty.handler.codec.ReplayingDecoder; |
|
|
|
import org.apache.dolphinscheduler.remote.command.Command; |
|
|
|
import org.apache.dolphinscheduler.remote.command.Command; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandHeader; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandHeader; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandType; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandType; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -31,6 +33,7 @@ import java.util.List; |
|
|
|
* netty decoder |
|
|
|
* netty decoder |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> { |
|
|
|
public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> { |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(NettyDecoder.class); |
|
|
|
|
|
|
|
|
|
|
|
public NettyDecoder(){ |
|
|
|
public NettyDecoder(){ |
|
|
|
super(State.MAGIC); |
|
|
|
super(State.MAGIC); |
|
|
@ -52,15 +55,19 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> { |
|
|
|
case MAGIC: |
|
|
|
case MAGIC: |
|
|
|
checkMagic(in.readByte()); |
|
|
|
checkMagic(in.readByte()); |
|
|
|
checkpoint(State.COMMAND); |
|
|
|
checkpoint(State.COMMAND); |
|
|
|
|
|
|
|
break; |
|
|
|
case COMMAND: |
|
|
|
case COMMAND: |
|
|
|
commandHeader.setType(in.readByte()); |
|
|
|
commandHeader.setType(in.readByte()); |
|
|
|
checkpoint(State.OPAQUE); |
|
|
|
checkpoint(State.OPAQUE); |
|
|
|
|
|
|
|
break; |
|
|
|
case OPAQUE: |
|
|
|
case OPAQUE: |
|
|
|
commandHeader.setOpaque(in.readLong()); |
|
|
|
commandHeader.setOpaque(in.readLong()); |
|
|
|
checkpoint(State.BODY_LENGTH); |
|
|
|
checkpoint(State.BODY_LENGTH); |
|
|
|
|
|
|
|
break; |
|
|
|
case BODY_LENGTH: |
|
|
|
case BODY_LENGTH: |
|
|
|
commandHeader.setBodyLength(in.readInt()); |
|
|
|
commandHeader.setBodyLength(in.readInt()); |
|
|
|
checkpoint(State.BODY); |
|
|
|
checkpoint(State.BODY); |
|
|
|
|
|
|
|
break; |
|
|
|
case BODY: |
|
|
|
case BODY: |
|
|
|
byte[] body = new byte[commandHeader.getBodyLength()]; |
|
|
|
byte[] body = new byte[commandHeader.getBodyLength()]; |
|
|
|
in.readBytes(body); |
|
|
|
in.readBytes(body); |
|
|
@ -72,6 +79,9 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> { |
|
|
|
out.add(packet); |
|
|
|
out.add(packet); |
|
|
|
//
|
|
|
|
//
|
|
|
|
checkpoint(State.MAGIC); |
|
|
|
checkpoint(State.MAGIC); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
logger.warn("unknown decoder state {}", state()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|