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

DefaultConnectionManager#executorInitialized 属性是否没有必要? #131

Closed
dbl-x opened this issue Mar 6, 2019 · 2 comments
Closed
Assignees
Milestone

Comments

@dbl-x
Copy link
Contributor

dbl-x commented Mar 6, 2019

Describe the bug
DefaultConnectionManager#executorInitialized属性看着是为了只初始化一次asyncCreateConnectionExecutor,但实现的实际效果并不能控制只初始化一次(并发情况下)。

若不能控制,为什么不通过asyncCreateConnectionExecutor==null来做初始化呢?为什么增加了一个属性?

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • SOFABolt version: 1.5.x
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:
@dbl-x
Copy link
Contributor Author

dbl-x commented Mar 6, 2019

asyncCreateConnectionExecutor的初始化只是初始化了ThreadPoolExecutor实例,ThreadPoolExecutor内部并不会立即新建线程,只是会有一个ArrayBlockingQueue的开销,看起来没必要做lazy init。
这样只需要将初始化操作移动到构造方法中,也没必要进行并发的控制了,可以删除executorInitialized属性。

@dbl-x
Copy link
Contributor Author

dbl-x commented Mar 6, 2019

image
另外doCreate这段逻辑中,如果同步创建的连接数已经大于等于预期的连接数,那么不再进行异步创建操作,所以判断逻辑应该是syncCreateNumWhenNotWarmup >= url.getConnNum()

dbl-x added a commit that referenced this issue Mar 6, 2019
* refactor DefaultConnectionManager to fix issue: #131
@dbl-x dbl-x added this to the 1.6.0 release milestone Mar 21, 2019
@dbl-x dbl-x closed this as completed Mar 21, 2019
dbl-x added a commit that referenced this issue May 31, 2019
* Add LifeCycle component and refactor some code. (#113)

* Make getAfterRun un-block avoid deadlock. (#107) (#109)

* update readme

* update version to 1.6.0-SNAPSHOT

* 修改RpcClientDemoByMain 和RpcServerDemoByMain 的logger引用对象 (#112)

* 修改日志引用的对象

* add lifecycle component

* fix NPE in ReconnectManager and refactor some code

* Refactor some components with LifeCycle interface. (#114)

Refactor some components with LifeCycle interface.

* Refactor RpcClient with LifeCycle interface and add option module. (#116)

Refactor RpcClient with LifeCycle interface and add option module.

* fix #131 (#132)


* refactor DefaultConnectionManager to fix issue: #131

* refactory ConnectionManager to support start/shutdown operations (#135)

* 重构ScheduledDisconnectStrategy实现 (#136)

* refactory ConnectionManager to support start/shutdown operations

* Reconnector class is used instead of ReconnectManager class

* refactor ScheduledDisconnectStrategy

* Support config strategy (#138)

* support config user ConnectionSelectStrategy impl

* add LifeCycle interface to RemotingServer

* fix some code according to CR

* fix #137 (#141)

* update version 1.6.0-SNAPSHOT->1.6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants