Skip to content

Commit

Permalink
[TUBEMQ-166]Hide bdbStore configs in master.ini (#122)
Browse files Browse the repository at this point in the history
Change list:
* Migrate all bdb configs.
* Change to relative path in configs
* Modify config reading codes
* Add "deprecated" warning

Signed-off-by: pingyu <shui.yu@126.com>
  • Loading branch information
pingyu authored Jun 3, 2020
1 parent efce761 commit 563636f
Show file tree
Hide file tree
Showing 12 changed files with 633 additions and 233 deletions.
70 changes: 35 additions & 35 deletions conf/master.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ consumerHeartbeatTimeoutMs=30000
producerHeartbeatTimeoutMs=45000
; timeout of broker heartbeat, optional; default is 25000ms
brokerHeartbeatTimeoutMs=25000
;configure modify authorization_token
; configure modify authorization_token
confModAuthToken=abc
webResourcePath=resources

; meta data path; can be absolute, or relative to TubeMQ base directory ($BASE_DIR)
; optional, default is "var/meta_data"
; should be the same to `[bdbStore].bdbEnvHome` if upgrade from version prior 0.5.0
;metaDataPath=var/meta_data


[zookeeper]
; root path of TubeMQ znodes on ZK
zkNodeRoot=/tubemq
Expand All @@ -50,41 +56,35 @@ zkSyncTimeMs=5000
; interval to commits data on ZK; default is 5000ms
zkCommitPeriodMs=5000

[bdbStore]
;name of Berkeley DB, Java Edition(BDB-JE) replication group
bdbRepGroupName=tubemqMasterGroup
;name of node in BDB-JE replication group
bdbNodeName=tubemqMasterGroupNode1
;port for node to communicate to other nodes in replication group
bdbNodePort=9001
;home directory of node in replication group
bdbEnvHome=var/tubemqMasterGroup/master_data
;helperHost(and port) for node to join replication group the first time
bdbHelperHost=127.0.0.1:9001

; config of commit file synchronization in BDB-JE
; 1 for SYNC, will write and synchronously flush the log to disk upon transaction commit
; 2 for NO_SYNC, do not synchronously flush the log upon transaction commit(if application or system fails,data may lost)
; 3 for WRITE_NO_SYNC, synchronously written to the OS's file system buffers upon transaction commit, but the data is not
; actually forced to disk(if the system fails,data may lost)
; commit file synchronization configuration of master node in replication group
bdbLocalSync= 1
; commit file synchronization configuration of replica node in replication group
bdbReplicaSync= 3

; config of ReplicaAckPolicy in BDB-JE
; 1 for SIMPLE_MAJORITY;
; 2 for ALL
; 3 for NONE
bdbReplicaAck= 1

;interval for node status check task
bdbStatusCheckTimeoutMs=10000





[replication]
; name of replication group, optional; default is `tubemqMasterGroup`
;repGroupName=tubemqMasterGroup
; name of current node; MUST BE DIFFERENT for every node in the same group
repNodeName=tubemqMasterGroupNode1
; port for node to communicate to other nodes in replication group, optional; default is 9001
;repNodePort=9001
; helperHost(and port) for node to join master cluster, optional; default is 127.0.0.1:9001
;repHelperHost=127.0.0.1:9001

; meta data disk sync policy
; the overall durability is a function of metaLocalSyncPolicy plus the repReplicaAckPolicy used by the master,
; and the metaReplicaSyncPolicy in effect at each Replica
; see https://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/Durability.html for detail
; 1 for SYNC, will write and synchronously flush the log to disk upon transaction commit
; 2 for NO_SYNC, do not synchronously flush the log upon transaction commit (if application or system fails, data may lost)
; 3 for WRITE_NO_SYNC, synchronously written to the OS's file system buffers upon transaction commit, but the data is not
; actually forced to disk(if the system fails,data may lost)
; sync policy for "local", optional; default is 1(SYNC)
;metaLocalSyncPolicy=1
; sync policy for "replica", optional; default is 3(WRITE_NO_SYNC)
;metaReplicaSyncPolicy=3

; replication acknowledge policy, optional; default is 1(SIMPLE_MAJORITY)
; 1 for SIMPLE_MAJORITY
; 2 for ALL
; 3 for NONE
;repReplicaAckPolicy=1

; interval for node status check task, optional; default is 10000(ms)
;repStatusCheckTimeoutMs=10000
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public abstract class AbstractFileConfig {
protected static final String SECT_TOKEN_BDB = "bdbStore";
protected static final String SECT_TOKEN_TLS = "tlsSetting";
protected static final String SECT_TOKEN_ZKEEPER = "zookeeper";
protected static final String SECT_TOKEN_REPLICATION = "replication";

private String basePath;
private String configPath;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.tubemq.server.common.fileconfig;

import com.sleepycat.je.Durability;

/* Named `MasterReplicationConfig` to avoid conflict with `com.sleepycat.je.rep.ReplicationConfig` */
public class MasterReplicationConfig {
private String repGroupName = "tubemqMasterGroup";
private String repNodeName;
private int repNodePort = 9001;
private String repHelperHost = "127.0.0.1:9001";
private int metaLocalSyncPolicy = 1;
private int metaReplicaSyncPolicy = 3;
private int repReplicaAckPolicy = 1;
private long repStatusCheckTimeoutMs = 10000;

public MasterReplicationConfig() {

}

public String getRepGroupName() {
return repGroupName;
}

public void setRepGroupName(String repGroupName) {
this.repGroupName = repGroupName;
}

public String getRepNodeName() {
return repNodeName;
}

public void setRepNodeName(String repNodeName) {
this.repNodeName = repNodeName;
}

public int getRepNodePort() {
return repNodePort;
}

public void setRepNodePort(int repNodePort) {
this.repNodePort = repNodePort;
}

public String getRepHelperHost() {
return repHelperHost;
}

public void setRepHelperHost(String repHelperHost) {
this.repHelperHost = repHelperHost;
}

public Durability.SyncPolicy getMetaLocalSyncPolicy() {
switch (metaLocalSyncPolicy) {
case 1:
return Durability.SyncPolicy.SYNC;
case 2:
return Durability.SyncPolicy.NO_SYNC;
case 3:
return Durability.SyncPolicy.WRITE_NO_SYNC;
default:
return Durability.SyncPolicy.SYNC;
}
}

public void setMetaLocalSyncPolicy(int metaLocalSyncPolicy) {
this.metaLocalSyncPolicy = metaLocalSyncPolicy;
}

public Durability.SyncPolicy getMetaReplicaSyncPolicy() {
switch (metaReplicaSyncPolicy) {
case 1:
return Durability.SyncPolicy.SYNC;
case 2:
return Durability.SyncPolicy.NO_SYNC;
case 3:
return Durability.SyncPolicy.WRITE_NO_SYNC;
default:
return Durability.SyncPolicy.SYNC;
}
}

public void setMetaReplicaSyncPolicy(int metaReplicaSyncPolicy) {
this.metaReplicaSyncPolicy = metaReplicaSyncPolicy;
}

public Durability.ReplicaAckPolicy getRepReplicaAckPolicy() {
switch (repReplicaAckPolicy) {
case 1:
return Durability.ReplicaAckPolicy.SIMPLE_MAJORITY;
case 2:
return Durability.ReplicaAckPolicy.ALL;
case 3:
return Durability.ReplicaAckPolicy.NONE;
default:
return Durability.ReplicaAckPolicy.SIMPLE_MAJORITY;
}
}

public void setRepReplicaAckPolicy(int repReplicaAckPolicy) {
this.repReplicaAckPolicy = repReplicaAckPolicy;
}

public long getRepStatusCheckTimeoutMs() {
return repStatusCheckTimeoutMs;
}

public void setRepStatusCheckTimeoutMs(long repStatusCheckTimeoutMs) {
this.repStatusCheckTimeoutMs = repStatusCheckTimeoutMs;
}

@Override
public String toString() {
return new StringBuilder(512)
.append("\"MasterReplicationConfig\":{\"repGroupName\":").append(repGroupName)
.append("\",\"repNodeName\":\"").append(repNodeName)
.append("\",\"repNodePort\":").append(repNodePort)
.append("\",\"repHelperHost\":\"").append(repHelperHost)
.append("\",\"metaLocalSyncPolicy\":").append(metaLocalSyncPolicy)
.append(",\"metaReplicaSyncPolicy\":").append(metaReplicaSyncPolicy)
.append(",\"repReplicaAckPolicy\":").append(repReplicaAckPolicy)
.append(",\"repStatusCheckTimeoutMs\":").append(repStatusCheckTimeoutMs)
.append("}").toString();
}
}
Loading

0 comments on commit 563636f

Please sign in to comment.