Skip to content

Commit

Permalink
Refactoring Fury Serialization Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
liujianjun.ljj committed Jan 3, 2024
1 parent f2d8a83 commit 7fc8c4f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
6 changes: 0 additions & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<httpclient.version>4.5.13</httpclient.version>
<commons.fileupload.version>1.5</commons.fileupload.version>
<transmittable.version>2.12.1</transmittable.version>
<snakeyaml.version>1.28</snakeyaml.version>
<!-- Log libs -->
<slf4j.version>1.7.21</slf4j.version>
<logback.version>1.2.3</logback.version>
Expand Down Expand Up @@ -305,11 +304,6 @@
<artifactId>fury-core</artifactId>
<version>${fury.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<!-- zk client -->
<dependency>
<groupId>org.apache.curator</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
package com.alipay.sofa.rpc.codec.common;

import com.alipay.sofa.rpc.common.SofaConfigs;
import com.alipay.sofa.rpc.common.SofaOptions;
import com.alipay.sofa.common.config.SofaConfigs;
import com.alipay.sofa.rpc.common.utils.StringUtils;
import com.alipay.sofa.rpc.log.Logger;
import com.alipay.sofa.rpc.log.LoggerFactory;
Expand All @@ -30,6 +29,8 @@
import java.util.LinkedList;
import java.util.List;

import static com.alipay.sofa.rpc.common.config.RpcConfigKeys.SERIALIZE_BLACKLIST_OVERRIDE;
import static com.alipay.sofa.rpc.common.config.RpcConfigKeys.SERIALIZE_WHITELIST_OVERRIDE;
import static com.alipay.sofa.rpc.common.utils.IOUtils.closeQuietly;

/**
Expand All @@ -54,7 +55,7 @@ public static List<String> loadBlackListFile(String path) {
if (input != null) {
readToList(input, "UTF-8", blackPrefixList);
}
String overStr = SofaConfigs.getStringValue(SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE, "");
String overStr = SofaConfigs.getOrCustomDefault(SERIALIZE_BLACKLIST_OVERRIDE, "");
if (StringUtils.isNotBlank(overStr)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Serialize blacklist will override with configuration: {}", overStr);
Expand All @@ -79,7 +80,7 @@ public static List<String> loadWhiteListFile(String path) {
if (input != null) {
readToList(input, "UTF-8", whitePrefixList);
}
String overStr = SofaConfigs.getStringValue(SofaOptions.CONFIG_SERIALIZE_WHITELIST_OVERRIDE, "");
String overStr = SofaConfigs.getOrCustomDefault(SERIALIZE_WHITELIST_OVERRIDE, "");
if (StringUtils.isNotBlank(overStr)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Serialize whitelist will override with configuration: {}", overStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class FurySerializer extends AbstractSerializer {

private final ThreadLocal<MemoryBuffer> writeBufferLocal = ThreadLocal.withInitial(() -> MemoryBuffer.newHeapBuffer(32));

private final String checkerMode = SofaConfigs.getOrDefault(RpcConfigKeys.CHECKER_MODE);
private final String checkerMode = SofaConfigs.getOrDefault(RpcConfigKeys.FURY_CHECKER_MODE);

public FurySerializer() {
fury = new ThreadLocalFury(classLoader -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void testSofaRequest() throws Exception {
SofaRequest request = buildRequest();
AbstractByteBuf data = serializer.encode(request, null);

serializer.encode("123456", null);
SofaRequest decode = (SofaRequest) serializer.decode(data, SofaRequest.class, null);
assertEqualsSofaRequest(request, decode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import com.alipay.sofa.common.config.ConfigKey;

import static com.alipay.sofa.rpc.common.SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE;
import static com.alipay.sofa.rpc.common.SofaOptions.CONFIG_SERIALIZE_WHITELIST_OVERRIDE;

/**
* @author zhaowang
* @version : RpcConfigKeys.java, v 0.1 2020年12月14日 9:56 下午 zhaowang Exp $
Expand Down Expand Up @@ -103,7 +106,23 @@ public class RpcConfigKeys {
"judge the generic object exception fields.",
new String[] { "sofa_rpc_generic_exception_fields" });

public static final ConfigKey<String> CHECKER_MODE = ConfigKey
public static final ConfigKey<String> SERIALIZE_BLACKLIST_OVERRIDE = ConfigKey
.build(
"sofa.rpc.serialize.blacklist.override",
"",
false,
"Additional serialization blacklist.",
new String[] { CONFIG_SERIALIZE_BLACKLIST_OVERRIDE });

public static final ConfigKey<String> SERIALIZE_WHITELIST_OVERRIDE = ConfigKey
.build(
"sofa.rpc.serialize.whitelist.override",
"",
false,
"Additional serialization whitelist.",
new String[] { CONFIG_SERIALIZE_WHITELIST_OVERRIDE });

public static final ConfigKey<String> FURY_CHECKER_MODE = ConfigKey
.build(
"sofa.rpc.codec.fury.checkMode",
"whitelist",
Expand Down

0 comments on commit 7fc8c4f

Please sign in to comment.