Skip to content

Commit 400606b

Browse files
committed
feature: support fory serializer and fory undolog parser
1 parent db73418 commit 400606b

File tree

17 files changed

+387
-3
lines changed

17 files changed

+387
-3
lines changed

all/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@
267267
<artifactId>seata-serializer-fury</artifactId>
268268
<version>${project.version}</version>
269269
</dependency>
270+
<dependency>
271+
<groupId>org.apache.seata</groupId>
272+
<artifactId>seata-serializer-fory</artifactId>
273+
<version>${project.version}</version>
274+
</dependency>
270275
<dependency>
271276
<groupId>org.apache.seata</groupId>
272277
<artifactId>seata-serializer-kryo</artifactId>

changes/en-us/2.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Add changes here for all PR submitted to the 2.x branch.
6767
- [[#7478](https://github.com/apache/incubator-seata/pull/7478)] metrics add retry status
6868
- [[#7483](https://github.com/apache/incubator-seata/pull/7483)] change the value of retryDeadThreshold to 70 seconds
6969
- [[#7488](https://github.com/apache/incubator-seata/pull/7488)] upgrade tomcat to 9.0.106
70+
- [[#7503](https://github.com/apache/incubator-seata/pull/7503)] support fory serializer and fory undolog parser
7071

7172
### security:
7273

@@ -138,6 +139,7 @@ Thanks to these contributors for their code commits. Please report an unintended
138139
- [jsbxyyx](https://github.com/jsbxyyx)
139140
- [simzyoo](https://github.com/simzyoo)
140141
- [Dltmd202](https://github.com/Dltmd202)
142+
- [diguage](https://github.com/diguage)
141143

142144

143145

changes/zh-cn/2.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
- [[#7466](https://github.com/apache/incubator-seata/pull/7466)] 在 issue 模板中添加贡献意向勾选框
6565
- [[#7478](https://github.com/apache/incubator-seata/pull/7478)] 增加处于重试状态的数据采集
6666
- [[#7483](https://github.com/apache/incubator-seata/pull/7483)] 将retryDeadThreshold改为70秒
67+
- [[#7503](https://github.com/apache/incubator-seata/pull/7503)] 支持 Fory 序列化器 和 UndoLog的 Fory 序列化方式
6768

6869

6970
### security:
@@ -138,6 +139,7 @@
138139
- [YvCeung](https://github.com/YvCeung)
139140
- [jsbxyyx](https://github.com/jsbxyyx)
140141
- [simzyoo](https://github.com/simzyoo)
142+
- [diguage](https://github.com/diguage)
141143

142144

143145
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。

core/src/main/java/org/apache/seata/core/serializer/SerializerServiceLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.stream.Collectors;
3434

3535
import static org.apache.seata.core.serializer.SerializerType.FASTJSON2;
36+
import static org.apache.seata.core.serializer.SerializerType.FORY;
3637
import static org.apache.seata.core.serializer.SerializerType.FURY;
3738
import static org.apache.seata.core.serializer.SerializerType.HESSIAN;
3839
import static org.apache.seata.core.serializer.SerializerType.KRYO;
@@ -48,7 +49,7 @@ public final class SerializerServiceLoader {
4849
private static final Configuration CONFIG = ConfigurationFactory.getInstance();
4950

5051
private static final SerializerType[] DEFAULT_SERIALIZER_TYPE =
51-
new SerializerType[] {SEATA, PROTOBUF, KRYO, HESSIAN, FASTJSON2, FURY};
52+
new SerializerType[] {SEATA, PROTOBUF, KRYO, HESSIAN, FASTJSON2, FURY, FORY};
5253

5354
private static final Map<String, Serializer> SERIALIZER_MAP = new HashMap<>();
5455

core/src/main/java/org/apache/seata/core/serializer/SerializerType.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ public enum SerializerType {
8383
* <p>
8484
* Math.pow(2, 8)
8585
*/
86-
FURY((byte) 0x256);
86+
FURY((byte) 0x256),
87+
88+
/**
89+
* The fory.
90+
* <p>
91+
* Math.pow(2, 9)
92+
*/
93+
FORY((byte) 0x512);
94+
8795

8896
private final byte code;
8997

dependencies/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144

145145
<!-- for fury -->
146146
<fury.version>0.8.0</fury.version>
147+
<fory.version>0.11.1</fory.version>
147148
</properties>
148149

149150
<dependencyManagement>
@@ -899,6 +900,11 @@
899900
<artifactId>fury-core</artifactId>
900901
<version>${fury.version}</version>
901902
</dependency>
903+
<dependency>
904+
<groupId>org.apache.fory</groupId>
905+
<artifactId>fory-core</artifactId>
906+
<version>${fory.version}</version>
907+
</dependency>
902908
<dependency>
903909
<groupId>commons-io</groupId>
904910
<artifactId>commons-io</artifactId>

rm-datasource/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@
149149
<scope>provided</scope>
150150
<optional>true</optional>
151151
</dependency>
152+
<dependency>
153+
<groupId>org.apache.fory</groupId>
154+
<artifactId>fory-core</artifactId>
155+
<scope>provided</scope>
156+
<optional>true</optional>
157+
</dependency>
152158
<dependency>
153159
<groupId>cn.com.kingbase</groupId>
154160
<artifactId>kingbase8</artifactId>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.seata.rm.datasource.undo.parser;
18+
19+
import org.apache.fory.Fory;
20+
import org.apache.fory.ThreadLocalFory;
21+
import org.apache.fory.ThreadSafeFory;
22+
import org.apache.fory.config.CompatibleMode;
23+
import org.apache.fory.config.Language;
24+
import org.apache.seata.common.executor.Initialize;
25+
import org.apache.seata.common.loader.LoadLevel;
26+
import org.apache.seata.rm.datasource.undo.BranchUndoLog;
27+
import org.apache.seata.rm.datasource.undo.UndoLogParser;
28+
29+
@LoadLevel(name = ForyUndoLogParser.NAME)
30+
public class ForyUndoLogParser implements UndoLogParser, Initialize {
31+
public static final String NAME = "fory";
32+
33+
private static final ThreadSafeFory FORY = new ThreadLocalFory(classLoader -> Fory.builder()
34+
.withLanguage(Language.JAVA)
35+
// In JAVA mode, classes cannot be registered by tag, and the different registration order between the
36+
// server and the client will cause deserialization failure
37+
// In XLANG cross-language mode has problems with Java class serialization, such as enum classes
38+
// [https://github.com/apache/fory/issues/1644].
39+
.requireClassRegistration(false)
40+
// enable reference tracking for shared/circular reference.
41+
.withRefTracking(true)
42+
.withClassLoader(classLoader)
43+
.withCompatibleMode(CompatibleMode.COMPATIBLE)
44+
.build());
45+
46+
@Override
47+
public void init() {}
48+
49+
@Override
50+
public String getName() {
51+
return NAME;
52+
}
53+
54+
@Override
55+
public byte[] getDefaultContent() {
56+
return encode(new BranchUndoLog());
57+
}
58+
59+
@Override
60+
public byte[] encode(BranchUndoLog branchUndoLog) {
61+
return FORY.serializeJavaObject(branchUndoLog);
62+
}
63+
64+
@Override
65+
public BranchUndoLog decode(byte[] bytes) {
66+
return FORY.deserializeJavaObject(bytes, BranchUndoLog.class);
67+
}
68+
}

rm-datasource/src/main/resources/META-INF/services/org.apache.seata.rm.datasource.undo.UndoLogParser

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser
1919
org.apache.seata.rm.datasource.undo.parser.ProtostuffUndoLogParser
2020
org.apache.seata.rm.datasource.undo.parser.KryoUndoLogParser
2121
org.apache.seata.rm.datasource.undo.parser.Fastjson2UndoLogParser
22-
org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
22+
org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
23+
org.apache.seata.rm.datasource.undo.parser.ForyUndoLogParser
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.seata.rm.datasource.undo.parser;
18+
19+
import org.apache.seata.common.loader.EnhancedServiceLoader;
20+
import org.apache.seata.rm.datasource.undo.BaseUndoLogParserTest;
21+
import org.apache.seata.rm.datasource.undo.UndoLogParser;
22+
23+
public class ForyUndoLogParserTest extends BaseUndoLogParserTest {
24+
25+
ForyUndoLogParser parser =
26+
(ForyUndoLogParser) EnhancedServiceLoader.load(UndoLogParser.class, ForyUndoLogParser.NAME);
27+
28+
@Override
29+
public UndoLogParser getParser() {
30+
return parser;
31+
}
32+
33+
@Override
34+
public void testTimestampEncodeAndDecode() {
35+
}
36+
}

0 commit comments

Comments
 (0)