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

add fury serializer #1348

Merged
merged 41 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5415b1b
add FurySerializer
pandalee99 Jul 19, 2023
112d70b
add FurySerializer
pandalee99 Jul 20, 2023
f7d992e
add FurySerializer
pandalee99 Jul 20, 2023
5ffd32b
add FurySerializer
pandalee99 Jul 25, 2023
90b190c
add fury serializer
pandalee99 Jul 31, 2023
aad7adf
add fury serializer
pandalee99 Aug 14, 2023
586fc1b
add fury serializer with test
pandalee99 Aug 15, 2023
dd05c19
add fury serializer with test
pandalee99 Aug 23, 2023
6cc2eff
add fury serializer with test
pandalee99 Aug 28, 2023
7af8b1e
add fury serializer with test
Aug 29, 2023
1de4a05
Support for multiple parameters
Aug 29, 2023
7eb2c96
add whitelist
pandalee99 Aug 29, 2023
7a7c222
add ClassChecker to implement the whitelist mechanism.
pandalee99 Sep 21, 2023
8cf709d
Support hot update
pandalee99 Oct 8, 2023
9e5662a
(fury version) 0.1.1 update to 0.2.0
pandalee99 Oct 9, 2023
d0d591b
Whitelist function optimization
pandalee99 Oct 23, 2023
78700ae
use yaml to replace json ,change init logic, and enhance checker
pandalee99 Oct 27, 2023
a4ab229
to resolve conflicts
pandalee99 Oct 27, 2023
02f3979
to resolve conflicts
pandalee99 Oct 27, 2023
cc1b341
to resolve conflicts
pandalee99 Oct 27, 2023
0d5a0e3
Merge branch 'sofastack:master' into master
pandalee99 Oct 27, 2023
aeeed0a
to resolve build error
pandalee99 Oct 31, 2023
c665175
bug fix
pandalee99 Nov 2, 2023
090f2c5
fix codestyle
pandalee99 Nov 2, 2023
d7d1f29
fix test error
pandalee99 Nov 2, 2023
59be19d
optimized code
Nov 6, 2023
e227ade
Merge branch 'master' of github.com:sofastack/sofa-rpc into pandale99…
Nov 6, 2023
7fe900d
fury update to 0.3.0
pandalee99 Nov 6, 2023
59fdd58
Merge remote-tracking branch 'origin/master'
pandalee99 Nov 6, 2023
480cffa
Merge branch 'sofastack:master' into master
pandalee99 Nov 6, 2023
63eaab7
Merge remote-tracking branch 'origin/master'
pandalee99 Nov 6, 2023
28621f2
bug fix
pandalee99 Nov 6, 2023
03ee605
Configuration file format changes
pandalee99 Nov 8, 2023
f2d8a83
Refactoring Fury Serialization Integration
Jan 2, 2024
7fc8c4f
Refactoring Fury Serialization Integration
Jan 3, 2024
5b1c7c0
refactor: module
Jan 3, 2024
6b4e3d5
Merge branch 'fury_opensource_refactor' into pandalee99/master
Jan 3, 2024
a8d9d02
Refactoring Fury Serialization Integration
Jan 4, 2024
2c71e38
Refactoring Fury Serialization Integration
Jan 4, 2024
6020075
Refactoring Fury Serialization Integration
Jan 5, 2024
e373752
Refactoring Fury Serialization Integration
Jan 8, 2024
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
6 changes: 6 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@
<artifactId>sofa-rpc-codec-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-codec-sofa-fury</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-fault-tolerance</artifactId>
Expand Down Expand Up @@ -519,6 +524,7 @@
<include>com.alipay.sofa:sofa-rpc-codec-jackson</include>
<include>com.alipay.sofa:sofa-rpc-codec-msgpack</include>
<include>com.alipay.sofa:sofa-rpc-codec-sofa-hessian</include>
<include>com.alipay.sofa:sofa-rpc-codec-sofa-fury</include>
<include>com.alipay.sofa:sofa-rpc-fault-tolerance</include>
<include>com.alipay.sofa:sofa-rpc-fault-hystrix</include>
<include>com.alipay.sofa:sofa-rpc-log-common-tools</include>
Expand Down
6 changes: 6 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<jackson.databind.version>2.12.7.1</jackson.databind.version>
<msgpack.version>0.6.12</msgpack.version>
<protostuff.version>1.5.9</protostuff.version>
<fury.version>0.4.1</fury.version>
<grpc.version>1.53.0</grpc.version>

<!--common-->
Expand Down Expand Up @@ -298,6 +299,11 @@
<artifactId>msgpack</artifactId>
<version>${msgpack.version}</version>
</dependency>
<dependency>
<groupId>org.furyio</groupId>
<artifactId>fury-core</artifactId>
<version>${fury.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 @@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.rpc.codec.sofahessian;
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,28 +29,33 @@
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;

/**
* Load blacklist from file.
*
* @author <a href="mailto:[email protected]">GengZhang</a>
*/
public class BlackListFileLoader {
public class BlackAndWhiteListFileLoader {

private static final Logger LOGGER = LoggerFactory.getLogger(BlackListFileLoader.class);
private static final Logger LOGGER = LoggerFactory
.getLogger(BlackAndWhiteListFileLoader.class);

public static final List<String> SOFA_SERIALIZE_BLACK_LIST = loadFile("/sofa-rpc/serialize_blacklist.txt");
public static final List<String> SOFA_SERIALIZE_BLACK_LIST = loadBlackListFile("/sofa-rpc/serialize_blacklist.txt");

static List<String> loadFile(String path) {
List<String> blackPrefixList = new ArrayList<String>();
public static final List<String> SOFA_SERIALIZER_WHITE_LIST = loadWhiteListFile("/sofa-rpc/serialize_whitelist.txt");

public static List<String> loadBlackListFile(String path) {
List<String> blackPrefixList = new ArrayList<>();
InputStream input = null;
try {
input = BlackListFileLoader.class.getResourceAsStream(path);
input = BlackAndWhiteListFileLoader.class.getResourceAsStream(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 @@ -68,6 +72,31 @@ static List<String> loadFile(String path) {
return blackPrefixList;
}

public static List<String> loadWhiteListFile(String path) {
List<String> whitePrefixList = new ArrayList<>();
InputStream input = null;
try {
input = BlackAndWhiteListFileLoader.class.getResourceAsStream(path);
if (input != null) {
readToList(input, "UTF-8", whitePrefixList);
}
String overStr = SofaConfigs.getOrCustomDefault(SERIALIZE_WHITELIST_OVERRIDE, "");
if (StringUtils.isNotBlank(overStr)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Serialize whitelist will override with configuration: {}", overStr);
}
overrideWhiteList(whitePrefixList, overStr);
}
} catch (Exception e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error(e.getMessage(), e);
}
} finally {
closeQuietly(input);
}
return whitePrefixList;
}

/**
* 读文件,将结果丢入List
*
Expand Down Expand Up @@ -100,12 +129,12 @@ private static void readToList(InputStream input, String encoding, List<String>

/**
* Override blacklist with override string.
*
* @param originList Origin black list
*
* @param originList Origin black list
* @param overrideStr The override string
*/
static void overrideBlackList(List<String> originList, String overrideStr) {
List<String> adds = new LinkedList<String>();
public static void overrideBlackList(List<String> originList, String overrideStr) {
List<String> adds = new LinkedList<>();
String[] overrideItems = StringUtils.splitWithCommaOrSemicolon(overrideStr);
for (String overrideItem : overrideItems) {
if (StringUtils.isNotBlank(overrideItem)) {
Expand All @@ -127,4 +156,19 @@ static void overrideBlackList(List<String> originList, String overrideStr) {
originList.addAll(adds);
}
}

public static void overrideWhiteList(List<String> originList, String overrideStr) {
List<String> adds = new LinkedList<>();
String[] overrideItems = StringUtils.splitWithCommaOrSemicolon(overrideStr);
for (String overrideItem : overrideItems) {
if (StringUtils.isNotBlank(overrideItem)) {
if (!originList.contains(overrideItem)) {
adds.add(overrideItem);
}
}
}
if (adds.size() > 0) {
originList.addAll(adds);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 com.alipay.sofa.rpc.codec.common;

/**
* @author Even
* @date 2024/1/5 19:12
*/
public enum SerializeCheckStatus {
/**
* Disable serialize check for all classes
*/
DISABLE(0),

/**
* Only deny danger classes, warn if other classes are not in allow list
*/
WARN(1),

/**
* Only allow classes in allow list, deny if other classes are not in allow list
*/
STRICT(2);

private final int mode;

SerializeCheckStatus(int mode) {
this.mode = mode;
}

public int getSerializeCheckMode() {
return mode;
}
}
46 changes: 46 additions & 0 deletions codec/codec-sofa-fury/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-codec</artifactId>
<version>${revision}</version>
</parent>

<artifactId>sofa-rpc-codec-sofa-fury</artifactId>

<dependencies>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-codec-api</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-api</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-log</artifactId>
</dependency>

<!-- 默认不主动依赖 -->
<dependency>
<groupId>org.furyio</groupId>
<artifactId>fury-core</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading
Loading