Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@
<artifactId>seata-serializer-fury</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-serializer-fory</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-serializer-kryo</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7478](https://github.com/apache/incubator-seata/pull/7478)] metrics add retry status
- [[#7483](https://github.com/apache/incubator-seata/pull/7483)] change the value of retryDeadThreshold to 70 seconds
- [[#7488](https://github.com/apache/incubator-seata/pull/7488)] upgrade tomcat to 9.0.106
- [[#7503](https://github.com/apache/incubator-seata/pull/7503)] support Fory serializer and Fory undolog parser

### security:

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



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


### security:
Expand Down Expand Up @@ -138,6 +139,7 @@
- [YvCeung](https://github.com/YvCeung)
- [jsbxyyx](https://github.com/jsbxyyx)
- [simzyoo](https://github.com/simzyoo)
- [diguage](https://github.com/diguage)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.stream.Collectors;

import static org.apache.seata.core.serializer.SerializerType.FASTJSON2;
import static org.apache.seata.core.serializer.SerializerType.FORY;
import static org.apache.seata.core.serializer.SerializerType.FURY;
import static org.apache.seata.core.serializer.SerializerType.HESSIAN;
import static org.apache.seata.core.serializer.SerializerType.KRYO;
Expand All @@ -48,7 +49,7 @@ public final class SerializerServiceLoader {
private static final Configuration CONFIG = ConfigurationFactory.getInstance();

private static final SerializerType[] DEFAULT_SERIALIZER_TYPE =
new SerializerType[] {SEATA, PROTOBUF, KRYO, HESSIAN, FASTJSON2, FURY};
new SerializerType[] {SEATA, PROTOBUF, KRYO, HESSIAN, FASTJSON2, FURY, FORY};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ public enum SerializerType {
* <p>
* Math.pow(2, 8)
*/
FURY((byte) 0x256);
FURY((byte) 0x256),

/**
* The fory.
* <p>
* Math.pow(2, 9)
*/
FORY((byte) 0x512);


private final byte code;

Expand Down
6 changes: 6 additions & 0 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@

<!-- for fury -->
<fury.version>0.8.0</fury.version>
<fory.version>0.11.1</fory.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -899,6 +900,11 @@
<artifactId>fury-core</artifactId>
<version>${fury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
<version>${fory.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions rm-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.com.kingbase</groupId>
<artifactId>kingbase8</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seata.rm.datasource.undo.parser;

import org.apache.fory.Fory;
import org.apache.fory.ThreadLocalFory;
import org.apache.fory.ThreadSafeFory;
import org.apache.fory.config.CompatibleMode;
import org.apache.fory.config.Language;
import org.apache.seata.common.executor.Initialize;
import org.apache.seata.common.loader.LoadLevel;
import org.apache.seata.rm.datasource.undo.BranchUndoLog;
import org.apache.seata.rm.datasource.undo.UndoLogParser;

@LoadLevel(name = ForyUndoLogParser.NAME)
public class ForyUndoLogParser implements UndoLogParser, Initialize {
public static final String NAME = "fory";

private static final ThreadSafeFory FORY = new ThreadLocalFory(classLoader -> Fory.builder()
.withLanguage(Language.JAVA)
// In JAVA mode, classes cannot be registered by tag, and the different registration order between the
// server and the client will cause deserialization failure
// In XLANG cross-language mode has problems with Java class serialization, such as enum classes
// [https://github.com/apache/fory/issues/1644].
.requireClassRegistration(false)
// enable reference tracking for shared/circular reference.
.withRefTracking(true)
.withClassLoader(classLoader)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.build());

@Override
public void init() {}

@Override
public String getName() {
return NAME;
}

@Override
public byte[] getDefaultContent() {
return encode(new BranchUndoLog());
}

@Override
public byte[] encode(BranchUndoLog branchUndoLog) {
return FORY.serializeJavaObject(branchUndoLog);
}

@Override
public BranchUndoLog decode(byte[] bytes) {
return FORY.deserializeJavaObject(bytes, BranchUndoLog.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser
org.apache.seata.rm.datasource.undo.parser.ProtostuffUndoLogParser
org.apache.seata.rm.datasource.undo.parser.KryoUndoLogParser
org.apache.seata.rm.datasource.undo.parser.Fastjson2UndoLogParser
org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
org.apache.seata.rm.datasource.undo.parser.ForyUndoLogParser
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seata.rm.datasource.undo.parser;

import org.apache.seata.common.loader.EnhancedServiceLoader;
import org.apache.seata.rm.datasource.undo.BaseUndoLogParserTest;
import org.apache.seata.rm.datasource.undo.UndoLogParser;

public class ForyUndoLogParserTest extends BaseUndoLogParserTest {

ForyUndoLogParser parser =
(ForyUndoLogParser) EnhancedServiceLoader.load(UndoLogParser.class, ForyUndoLogParser.NAME);

@Override
public UndoLogParser getParser() {
return parser;
}

@Override
public void testTimestampEncodeAndDecode() {
}
}
1 change: 1 addition & 0 deletions serializer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<module>seata-serializer-hessian</module>
<module>seata-serializer-fastjson2</module>
<module>seata-serializer-fury</module>
<module>seata-serializer-fory</module>
</modules>

</project>
5 changes: 5 additions & 0 deletions serializer/seata-serializer-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,10 @@
<artifactId>seata-serializer-fury</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-serializer-fory</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
46 changes: 46 additions & 0 deletions serializer/seata-serializer-fory/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.seata</groupId>
<artifactId>seata-serializer</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-serializer-fory</artifactId>
<packaging>jar</packaging>
<name>seata-serializer-fory ${project.version}</name>
<description>serializer-fory for Seata built with Maven</description>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seata.serializer.fory;

import org.apache.fory.ThreadSafeFory;
import org.apache.seata.common.loader.LoadLevel;
import org.apache.seata.core.protocol.AbstractMessage;
import org.apache.seata.core.serializer.Serializer;

@LoadLevel(name = "FORY")
public class ForySerializer implements Serializer {
@Override
public <T> byte[] serialize(T t) {
if (!(t instanceof AbstractMessage)) {
throw new IllegalArgumentException("AbstractMessage isn't available.");
}

ThreadSafeFory threadSafeFory = ForySerializerFactory.getInstance().get();
return threadSafeFory.serialize(t);
}

@Override
public <T> T deserialize(byte[] bytes) {
if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("bytes is null");
}
ThreadSafeFory threadSafeFory = ForySerializerFactory.getInstance().get();
return (T) threadSafeFory.deserialize(bytes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seata.serializer.fory;

import org.apache.fory.Fory;
import org.apache.fory.ThreadLocalFory;
import org.apache.fory.ThreadSafeFory;
import org.apache.fory.config.CompatibleMode;
import org.apache.fory.config.Language;
import org.apache.seata.core.serializer.SerializerSecurityRegistry;

public class ForySerializerFactory {
private static final ForySerializerFactory FACTORY = new ForySerializerFactory();

private static final ThreadSafeFory FORY = new ThreadLocalFory(classLoader -> {
Fory f = Fory.builder()
.withLanguage(Language.JAVA)
// In JAVA mode, classes cannot be registered by tag, and the different registration order between the
// server and the client will cause deserialization failure
// In XLANG cross-language mode has problems with Java class serialization, such as enum classes
// [https://github.com/apache/fory/issues/1644].
.requireClassRegistration(false)
// enable reference tracking for shared/circular reference.
.withRefTracking(true)
.withClassLoader(classLoader)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.build();

// register allow class
f.getClassResolver()
.setClassChecker((classResolver, className) ->
SerializerSecurityRegistry.getAllowClassPattern().contains(className));
return f;
});

public static ForySerializerFactory getInstance() {
return FACTORY;
}

public ThreadSafeFory get() {
return FORY;
}
}
Loading