Skip to content

Commit

Permalink
protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Bughue committed Jul 19, 2023
1 parent ed03135 commit 53a98ea
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* </p>
* https://github.com/seata/seata/issues/893
*
* @author minghua.xie
* @author Bughue
* @since 2.0.0
*/
public class CompatibleProtocolDecoder extends LengthFieldBasedFrameDecoder {
Expand Down Expand Up @@ -91,6 +91,7 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception
if(version == ProtocolConstants.OLD_VERSION){
return ProtocolOldDecoder.decodeFrame(frame);
}else if(version == ProtocolConstants.VERSION){
// todo spi?
return ProtocolV1Decoder.decodeFrame(frame);
}else {
throw new IllegalArgumentException("Unknown version: " + version );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* </p>
* https://github.com/seata/seata/issues/893
*
* @author minghua.xie
* @author Bughue
* @since 2.0.0
*/
public class CompatibleProtocolEncoder extends MessageToByteEncoder {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* 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 io.seata.core.rpc.netty.v2;

import io.netty.buffer.ByteBuf;
import io.seata.core.protocol.ProtocolConstants;
import io.seata.core.protocol.RpcMessage;
import io.seata.core.rpc.netty.CompatibleProtocolDecoder;
import io.seata.core.rpc.netty.v1.HeadMapSerializer;
import io.seata.core.rpc.netty.v1.ProtocolV1Encoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
* <pre>
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
* +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
* | magic |Proto| Full length | Head | Msg |Seria|Compr| RequestId |
* | code |colVer| (head+body) | Length |Type |lizer|ess | |
* +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
* | |
* | Head Map [Optional] |
* +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
* | |
* | body |
* | |
* | ... ... |
* +-----------------------------------------------------------------------------------------------+
* </pre>
* <p>
* <li>Full Length: include all data </li>
* <li>Head Length: include head data from magic code to head map. </li>
* <li>Body Length: Full Length - Head Length</li>
* </p>
* https://github.com/seata/seata/issues/893
*
* @author Bughue
*/
public class ProtocolV2Decoder {

private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolV2Decoder.class);

public static Object decodeFrame(ByteBuf frame) {
// todo
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* 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 io.seata.core.rpc.netty.v2;

import io.netty.buffer.ByteBuf;
import io.seata.core.compressor.Compressor;
import io.seata.core.compressor.CompressorFactory;
import io.seata.core.protocol.ProtocolConstants;
import io.seata.core.protocol.RpcMessage;
import io.seata.core.rpc.netty.old.ProtocolOldEncoder;
import io.seata.core.rpc.netty.v1.HeadMapSerializer;
import io.seata.core.rpc.netty.v1.ProtocolV1Decoder;
import io.seata.core.serializer.Serializer;
import io.seata.core.serializer.SerializerServiceLoader;
import io.seata.core.serializer.SerializerType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
* <pre>
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
* +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
* | magic |Proto| Full length | Head | Msg |Seria|Compr| RequestId |
* | code |colVer| (head+body) | Length |Type |lizer|ess | |
* +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
* | |
* | Head Map [Optional] |
* +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
* | |
* | body |
* | |
* | ... ... |
* +-----------------------------------------------------------------------------------------------+
* </pre>
* <p>
* <li>Full Length: include all data </li>
* <li>Head Length: include head data from magic code to head map. </li>
* <li>Body Length: Full Length - Head Length</li>
* </p>
* https://github.com/seata/seata/issues/893
*
* @author Bughue
*/
public class ProtocolV2Encoder {

private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolOldEncoder.class);

public static void encode(RpcMessage rpcMessage, ByteBuf out) {
// todo
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package io.seata.serializer.seata.protocol.v2;

0 comments on commit 53a98ea

Please sign in to comment.