-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[ISSUE #7300] jRaft-Controller Implemention #7301
Changes from 26 commits
7529187
2edc6c7
c24e268
855a8ba
c973b56
14d45c7
1196047
d775f87
ed2e82f
8800d69
8b38ee6
e01ef73
a172a60
8f3f8c1
adffdf2
9ce99b6
6c86484
14bac4b
863b49e
05062f3
27e8134
44d5717
323ea1c
03b0cb2
15002d0
677faf3
2b33ccb
8e1f71c
2f362ef
e0f8ede
e5b4ae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,14 @@ | |
import org.apache.rocketmq.common.metrics.MetricsExporterType; | ||
|
||
public class ControllerConfig { | ||
|
||
private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV)); | ||
private String configStorePath = System.getProperty("user.home") + File.separator + "controller" + File.separator + "controller.properties"; | ||
public static final String DLEDGER_CONTROLLER = "DLedger"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be better to use an enum There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using enum is indeed more elegant, but I think using string constants here is sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
public static final String JRAFT_CONTROLLER = "jRaft"; | ||
|
||
private JraftConfig jraftConfig = new JraftConfig(); | ||
|
||
private String controllerType = DLEDGER_CONTROLLER; | ||
/** | ||
* Interval of periodic scanning for non-active broker; | ||
* Unit: millisecond | ||
|
@@ -45,7 +49,13 @@ public class ControllerConfig { | |
private String controllerDLegerPeers; | ||
private String controllerDLegerSelfId; | ||
private int mappedFileSize = 1024 * 1024 * 1024; | ||
private String controllerStorePath = System.getProperty("user.home") + File.separator + "DledgerController"; | ||
private String controllerStorePath = ""; | ||
|
||
/** | ||
* Max retry count for electing master when failed because of network or system error. | ||
*/ | ||
private int electMasterMaxRetryCount = 3; | ||
|
||
|
||
/** | ||
* Whether the controller can elect a master which is not in the syncStateSet. | ||
|
@@ -171,6 +181,9 @@ public void setMappedFileSize(int mappedFileSize) { | |
} | ||
|
||
public String getControllerStorePath() { | ||
if (controllerStorePath.isEmpty()) { | ||
yulangz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
controllerStorePath = System.getProperty("user.home") + File.separator + controllerType + "Controller"; | ||
} | ||
return controllerStorePath; | ||
} | ||
|
||
|
@@ -295,4 +308,28 @@ public boolean isMetricsInDelta() { | |
public void setMetricsInDelta(boolean metricsInDelta) { | ||
this.metricsInDelta = metricsInDelta; | ||
} | ||
|
||
public String getControllerType() { | ||
return controllerType; | ||
} | ||
|
||
public void setControllerType(String controllerType) { | ||
this.controllerType = controllerType; | ||
} | ||
|
||
public JraftConfig getJraftConfig() { | ||
return jraftConfig; | ||
} | ||
|
||
public void setJraftConfig(JraftConfig jraftConfig) { | ||
this.jraftConfig = jraftConfig; | ||
} | ||
|
||
public int getElectMasterMaxRetryCount() { | ||
return this.electMasterMaxRetryCount; | ||
} | ||
|
||
public void setElectMasterMaxRetryCount(int electMasterMaxRetryCount) { | ||
this.electMasterMaxRetryCount = electMasterMaxRetryCount; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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 org.apache.rocketmq.common; | ||
|
||
public class JraftConfig { | ||
int jRaftElectionTimeoutMs = 1000; | ||
|
||
int jRaftScanWaitTimeoutMs = 1000; | ||
int jRaftSnapshotIntervalSecs = 3600; | ||
String jRaftGroupId = "jRaft-Controller"; | ||
String jRaftServerId = "localhost:9880"; | ||
String jRaftInitConf = "localhost:9880,localhost:9881,localhost:9882"; | ||
String jRaftControllerRPCAddr = "localhost:9770,localhost:9771,localhost:9772"; | ||
Comment on lines
+20
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to add private embellishments. |
||
|
||
public int getjRaftElectionTimeoutMs() { | ||
return jRaftElectionTimeoutMs; | ||
} | ||
|
||
public void setjRaftElectionTimeoutMs(int jRaftElectionTimeoutMs) { | ||
this.jRaftElectionTimeoutMs = jRaftElectionTimeoutMs; | ||
} | ||
|
||
public int getjRaftSnapshotIntervalSecs() { | ||
return jRaftSnapshotIntervalSecs; | ||
} | ||
|
||
public void setjRaftSnapshotIntervalSecs(int jRaftSnapshotIntervalSecs) { | ||
this.jRaftSnapshotIntervalSecs = jRaftSnapshotIntervalSecs; | ||
} | ||
|
||
public String getjRaftGroupId() { | ||
return jRaftGroupId; | ||
} | ||
|
||
public void setjRaftGroupId(String jRaftGroupId) { | ||
this.jRaftGroupId = jRaftGroupId; | ||
} | ||
|
||
public String getjRaftServerId() { | ||
return jRaftServerId; | ||
} | ||
|
||
public void setjRaftServerId(String jRaftServerId) { | ||
this.jRaftServerId = jRaftServerId; | ||
} | ||
|
||
public String getjRaftInitConf() { | ||
return jRaftInitConf; | ||
} | ||
|
||
public void setjRaftInitConf(String jRaftInitConf) { | ||
this.jRaftInitConf = jRaftInitConf; | ||
} | ||
|
||
public String getjRaftControllerRPCAddr() { | ||
return jRaftControllerRPCAddr; | ||
} | ||
|
||
public void setjRaftControllerRPCAddr(String jRaftControllerRPCAddr) { | ||
this.jRaftControllerRPCAddr = jRaftControllerRPCAddr; | ||
} | ||
|
||
public String getjRaftAddress() { | ||
return this.jRaftServerId; | ||
} | ||
|
||
public int getjRaftScanWaitTimeoutMs() { | ||
return jRaftScanWaitTimeoutMs; | ||
} | ||
|
||
public void setjRaftScanWaitTimeoutMs(int jRaftScanWaitTimeoutMs) { | ||
this.jRaftScanWaitTimeoutMs = jRaftScanWaitTimeoutMs; | ||
} | ||
} |
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.
It should be 1.3.14?