Skip to content

Commit

Permalink
feature: add fury undolog parser support (#7037)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyCoder authored Jan 3, 2025
1 parent 6310ce3 commit 8de9730
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 2 deletions.
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,9 +4,9 @@ Add changes here for all PR submitted to the 2.x branch.

### feature:

- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] support fury undolog parser
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft cluster mode supports address translation


### bugfix:

- [[#PR_NO](https://github.com/apache/incubator-seata/pull/#PR_NO)] fix XXX
Expand Down Expand Up @@ -34,9 +34,11 @@ 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)
- [PeppaO](https://github.com/PeppaO)
- [funky-eyes](https://github.com/funky-eyes)


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

### feature:

- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] 支持UndoLog的fury序列化方式
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft集群模式支持地址转换

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

- [slievrly](https://github.com/slievrly)
- [GoodBoyCoder](https://github.com/GoodBoyCoder)
- [lyl2008dsg](https://github.com/lyl2008dsg)
- [remind](https://github.com/remind)
- [PeppaO](https://github.com/PeppaO)
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() {
}
}

0 comments on commit 8de9730

Please sign in to comment.