This is an automated email from the ASF dual-hosted git repository.
lgcareer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new bf3cc0d [Bug][Refactor][issue-3157]use cas to avoid thread safe
problem (#3158)
bf3cc0d is described below
commit bf3cc0d00ef27eb0523b4542e5905256e369b068
Author: tswstarplanet <[email protected]>
AuthorDate: Tue Jul 7 18:45:20 2020 +0800
[Bug][Refactor][issue-3157]use cas to avoid thread safe problem (#3158)
Co-authored-by: lgcareer <[email protected]>
---
.../remote/NettyRemotingServer.java | 69 ++++++++++------------
1 file changed, 32 insertions(+), 37 deletions(-)
diff --git
a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
index 080c586..3eed82b 100644
---
a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
+++
b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
@@ -119,44 +119,39 @@ public class NettyRemotingServer {
* server start
*/
public void start(){
-
- if(this.isStarted.get()){
- return;
- }
-
- this.serverBootstrap
- .group(this.bossGroup, this.workGroup)
- .channel(NioServerSocketChannel.class)
- .option(ChannelOption.SO_REUSEADDR, true)
- .option(ChannelOption.SO_BACKLOG, serverConfig.getSoBacklog())
- .childOption(ChannelOption.SO_KEEPALIVE,
serverConfig.isSoKeepalive())
- .childOption(ChannelOption.TCP_NODELAY,
serverConfig.isTcpNoDelay())
- .childOption(ChannelOption.SO_SNDBUF,
serverConfig.getSendBufferSize())
- .childOption(ChannelOption.SO_RCVBUF,
serverConfig.getReceiveBufferSize())
- .childHandler(new ChannelInitializer<NioSocketChannel>() {
-
- @Override
- protected void initChannel(NioSocketChannel ch) throws
Exception {
- initNettyChannel(ch);
- }
- });
-
- ChannelFuture future;
- try {
- future = serverBootstrap.bind(serverConfig.getListenPort()).sync();
- } catch (Exception e) {
- logger.error("NettyRemotingServer bind fail {},
exit",e.getMessage(), e);
- throw new RuntimeException(String.format("NettyRemotingServer bind
%s fail", serverConfig.getListenPort()));
- }
- if (future.isSuccess()) {
- logger.info("NettyRemotingServer bind success at port : {}",
serverConfig.getListenPort());
- } else if (future.cause() != null) {
- throw new RuntimeException(String.format("NettyRemotingServer bind
%s fail", serverConfig.getListenPort()), future.cause());
- } else {
- throw new RuntimeException(String.format("NettyRemotingServer bind
%s fail", serverConfig.getListenPort()));
+ if (isStarted.compareAndSet(false, true)) {
+ this.serverBootstrap
+ .group(this.bossGroup, this.workGroup)
+ .channel(NioServerSocketChannel.class)
+ .option(ChannelOption.SO_REUSEADDR, true)
+ .option(ChannelOption.SO_BACKLOG,
serverConfig.getSoBacklog())
+ .childOption(ChannelOption.SO_KEEPALIVE,
serverConfig.isSoKeepalive())
+ .childOption(ChannelOption.TCP_NODELAY,
serverConfig.isTcpNoDelay())
+ .childOption(ChannelOption.SO_SNDBUF,
serverConfig.getSendBufferSize())
+ .childOption(ChannelOption.SO_RCVBUF,
serverConfig.getReceiveBufferSize())
+ .childHandler(new ChannelInitializer<NioSocketChannel>() {
+
+ @Override
+ protected void initChannel(NioSocketChannel ch) throws
Exception {
+ initNettyChannel(ch);
+ }
+ });
+
+ ChannelFuture future;
+ try {
+ future =
serverBootstrap.bind(serverConfig.getListenPort()).sync();
+ } catch (Exception e) {
+ logger.error("NettyRemotingServer bind fail {},
exit",e.getMessage(), e);
+ throw new RuntimeException(String.format("NettyRemotingServer
bind %s fail", serverConfig.getListenPort()));
+ }
+ if (future.isSuccess()) {
+ logger.info("NettyRemotingServer bind success at port : {}",
serverConfig.getListenPort());
+ } else if (future.cause() != null) {
+ throw new RuntimeException(String.format("NettyRemotingServer
bind %s fail", serverConfig.getListenPort()), future.cause());
+ } else {
+ throw new RuntimeException(String.format("NettyRemotingServer
bind %s fail", serverConfig.getListenPort()));
+ }
}
- //
- isStarted.compareAndSet(false, true);
}
/**