Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add fury undolog parser support #7037

Merged
merged 8 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
4 changes: 3 additions & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Add changes here for all PR submitted to the 2.x branch.

### feature:

- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] support XXX
- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] support fury undolog parser

### bugfix:

Expand Down Expand Up @@ -33,7 +33,9 @@ Thanks to these contributors for their code commits. Please report an unintended
<!-- Please make sure your Github ID is in the list below -->

- [slievrly](https://github.com/slievrly)
- [GoodBoyCoder](https://github.com/GoodBoyCoder)
- [lyl2008dsg](https://github.com/lyl2008dsg)
- [remind](https://github.com/remind)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
3 changes: 2 additions & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### feature:

- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 支持XXX
- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] 支持UndoLog的fury序列化方式

### bugfix:

Expand Down Expand Up @@ -33,6 +33,7 @@
<!-- 请确保您的 GitHub ID 在以下列表中 -->

- [slievrly](https://github.com/slievrly)
- [GoodBoyCoder](https://github.com/GoodBoyCoder)
- [lyl2008dsg](https://github.com/lyl2008dsg)
- [remind](https://github.com/remind)

Expand Down
9 changes: 9 additions & 0 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<janino-version>3.1.10</janino-version>
<mockwebserver-version>4.12.0</mockwebserver-version>
<native-lib-loader.version>2.4.0</native-lib-loader.version>

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

<dependencyManagement>
Expand Down Expand Up @@ -879,6 +882,12 @@
<version>${rocketmq-version}</version>
</dependency>

<!-- Fury Serialize -->
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-core</artifactId>
<version>${fury.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
6 changes: 6 additions & 0 deletions rm-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,11 @@
<artifactId>DmJdbcDriver18</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-core</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.fury.Fury;
import org.apache.fury.ThreadLocalFury;
import org.apache.fury.ThreadSafeFury;
import org.apache.fury.config.CompatibleMode;
import org.apache.fury.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 = FuryUndoLogParser.NAME)
public class FuryUndoLogParser implements UndoLogParser, Initialize {
public static final String NAME = "fury";

private static final ThreadSafeFury FURY = new ThreadLocalFury(classLoader -> Fury.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/fury/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 FURY.serializeJavaObject(branchUndoLog);
}

@Override
public BranchUndoLog decode(byte[] bytes) {
return FURY.deserializeJavaObject(bytes, BranchUndoLog.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ org.apache.seata.rm.datasource.undo.parser.FastjsonUndoLogParser
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.Fastjson2UndoLogParser
org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
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 FuryUndoLogParserTest extends BaseUndoLogParserTest {

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

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

@Override
public void testTimestampEncodeAndDecode() {
}
}
Loading