Skip to content

Commit

Permalink
resolve netty epoll confilct (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reason94 authored Sep 28, 2023
1 parent af99c2d commit a88c46b
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions spring-cloud-starter-baidu-starlight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>com.baidu.cloud</groupId>
<artifactId>spring-cloud-starter-baidu-starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Spring Cloud Starlight</description>
Expand All @@ -21,7 +21,7 @@
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
<!-- plugin versions -->
<powermock.version>2.0.9</powermock.version>
<starlight.version>2022.2.0</starlight.version>
<starlight.version>2022.2.2-SNAPSHOT</starlight.version>
</properties>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion starlight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
<packaging>pom</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion starlight/starlight-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-all</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions starlight/starlight-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-api</artifactId>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>com.baidu.cloud</groupId>
<artifactId>spring-cloud-baidu-thirdparty-commons</artifactId>
<version>2022.2.0</version>
<version>2023.0.1-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

import com.baidu.cloud.starlight.api.common.URI;
import com.baidu.cloud.starlight.api.rpc.Processor;
import com.baidu.cloud.thirdparty.netty.util.internal.NativeLibraryLoader;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
* Network peer Created by liuruisen on 2019/11/27.
Expand Down Expand Up @@ -65,4 +69,24 @@ public interface Peer extends GracefullyShutdown {
*/
void updateStatus(PeerStatus status);

/**
* starlight中使用的netty so文件与业务应用中使用的要区分开,防止业务也使用netty报错不兼容
* issue:https://github.com/baidu/starlight/issues/360
*/
default void updateNettyResourceMetaHome() {
try {
Class loaderClass = NativeLibraryLoader.class;
Field homeFiled = loaderClass.getDeclaredField("NATIVE_RESOURCE_HOME");
homeFiled.setAccessible(true);
// 去除final修饰符的影响,将字段设为可修改的
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(homeFiled, homeFiled.getModifiers() & ~Modifier.FINAL);
// 修改字段的内容
homeFiled.set(null, "META-INF/native/thirdparty");
} catch (Throwable e) {
// ignore
}
}

}
2 changes: 1 addition & 1 deletion starlight/starlight-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion starlight/starlight-protocol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-protocol</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight-protocol</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-protocol-brpc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight-protocol</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-protocol-http</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight-protocol</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-protocol-stargate</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion starlight/starlight-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-serialization</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion starlight/starlight-transport/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.cloud</groupId>
<artifactId>starlight</artifactId>
<version>2022.2.1-SNAPSHOT</version>
<version>2022.2.2-SNAPSHOT</version>
</parent>

<artifactId>starlight-transport</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public NettyClient(URI uri) {

this.uri = uri;
INSTANCE_SET.add(this.uri.getAddress());
this.updateNettyResourceMetaHome();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class NettyServer implements ServerPeer {
public NettyServer(URI uri) {
this.uri = uri;
this.rpcChannels = new ConcurrentHashMap<>();
this.updateNettyResourceMetaHome();
}

@Override
Expand Down

0 comments on commit a88c46b

Please sign in to comment.