-
Notifications
You must be signed in to change notification settings - Fork 318
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
Support multi-raft #150
Support multi-raft #150
Conversation
@yuz10 PING!Please check |
src/main/java/io/openmessaging/storage/dledger/DLedgerRpcNettyService.java
Outdated
Show resolved
Hide resolved
src/main/java/io/openmessaging/storage/dledger/DLedgerRpcNettyService.java
Outdated
Show resolved
Hide resolved
src/main/java/io/openmessaging/storage/dledger/DLedgerRpcNettyService.java
Outdated
Show resolved
Hide resolved
src/main/java/io/openmessaging/storage/dledger/cmdline/BossCommand.java
Outdated
Show resolved
Hide resolved
1.add DLedgerProxy to be the container of DLedgerServer. 2.add ConfigManager to manage the config about DLedgerProxy and DLedgerServer. 3.add DLedgerManager to manage the DLedgerServers. 4.support configuration file startup. 5.start parameters are compatible with the old version. 6.refactor the tests.
1.fix some tests for new model
1.code format
1.refactor the code and test
1.fix some test and add a new test
1.delete the print
1.fix some bugs and add some tests about leaderElector
1.add more tests about leaderElector
1.update conflict code
d7d2e9a
to
bf9876a
Compare
1.add startup args "server -c" to start with config file. 2.remove DLedgerRpcNettyServer#memstate. 3.check config before initialize DLedgerRpcNettyService.
src/main/java/io/openmessaging/storage/dledger/DLedgerRpcNettyService.java
Outdated
Show resolved
Hide resolved
DLedgerServer dLedgerServer = this.dLedgerManager.getDLedgerServer(request.getRemoteId()); | ||
try { | ||
PreConditions.check(dLedgerServer != null, DLedgerResponseCode.UNKNOWN_MEMBER, "group[%s] selfId[%s] not exist in proxy", request.getGroup(), request.getRemoteId()); | ||
return this.dLedgerManager.getDLedgerServer(request.getGroup(), request.getRemoteId()).handlePush(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getDLedgerServer twice, the first dLedgerServer no use
1.remove DLedgerRpcNettyService#checkOnePort 2.remove printStack
src/test/java/io/openmessaging/storage/dledger/statemachine/StateMachineCallerTest.java
Outdated
Show resolved
Hide resolved
1.use "groupId#selfId" to identify different DLedgerServer.
1.remove unused imports
0c3cd3d
to
849db96
Compare
1. make ConfigManager more flexible 2. refactor structure about multi-raft 3. more friendly for updating version
…branch 1. fix incompatible code after merge master branch
@yuz10 @RongtongJin Hi~ I have refactored some code about multi-raft structure! Please check! Thanks~ |
Hi TheR1sing3un, please fix the merge conflicts. |
1. refactor the main method in DLedger
done~ |
Multi-DLedger
Structure
For the above several components, do the following detailed explanation.
DLedgerProxy
We previously used
DLedgerServer
directly as a vehicle for receiving and processing requests in DLedger.If we want to upgrade to a Multi-Raft architecture, we need to decouple the parts that receive and send requests from the parts that process them. we use a layer proxy to proxy the underlying Raft node, we can use multiple
DLedgerServers
to share aRpcService
for request processing. ThisDLedgerProxy
is a wrapper around previously implemented methods such as handle requests, and can be routed according to the configuration.That is we
ip:port
can not uniquely identify a Raft node, becauseip:port
can also be represented as a multi-Raft structure external services, then at this time, we need aselfID
to differentiate the different Raft in this Multi-Raft. All of our DLedger communications will need to be located withselfID
at this time. And we added several modules inDLedgerProxy
, namelyConfigManager
andDLedgerManager
. The two modules manage the Raft-Group configuration and the nativeDLedgerServer
instance configuration and processing logic, respectively.We used to be able to locate a Raft instance with an
ip:port
, but now the process we locate withip:port
is a multi-Raft, so we need to locate in process according toselfID
.ConfigManager
ConfigManager
is the configuration management module for DLedger. Subsequently, using a solution such as a configuration center, online changes can be made dynamically in the Region for which the Raft-Group is responsible. At this point,ConfigManager
can make the appropriate requests and responses. Because of course we can have multipleDLedgerServers
share a sameRegionConfig
, becauseRegionConfig
is the same for all Raft in the cluster.Can also manage and configure the configuration of the local
DLedgerServer
instance, and can instantiate theDLedgerServer
according to the startup parameters at startup time, you can also manage the localDLedgerServer
instance by changing the localDLedgerServer
instance's configuration file in real time based on the network request.DLedgerManager
DLedgerManager
is the management module forDLedgerServer
, which includes the ability to route to aDLedgerServer
based on configuration for network requests toDLedgerServer
, and for subsequent optimizations such as the request merge mentioned above, can be unified in this module processing.How to start with Multi-DLedger
If you need to start with
Multi-DLedger
, you need to start with a configuration fileSimple configurations include:
Start in the command line:
java -jar ./DLedger.jar serverc -c ./config.yaml
Request receiving and response process
Previous request response process
Because there is only one
Dledgerserver
, it can directly call the handle methods ofDledgerserver
.Current request response process
Now that we have multiple
DLedgerServer
instances, then we need to specifically route to aDLedgerServer
according to theselftID
in the request. Therefore, we need to let theDledgerManager
inDLedgerProxy
find the specificDLedgerServer
to process the request based onSelfid-> DledgerServer
.