mirror of https://github.com/apache/activemq.git
Support weighting the leveldb store replication nodes so that some have a better chance of becoming the master than others.
This commit is contained in:
parent
468e697651
commit
0214bfbfcd
|
@ -81,6 +81,8 @@ class ElectingLevelDBStore extends ProxyLevelDBStore {
|
|||
@BeanProperty
|
||||
var bind = "tcp://0.0.0.0:61619"
|
||||
|
||||
@BeanProperty
|
||||
var weight = 1
|
||||
@BeanProperty
|
||||
var replicas = 3
|
||||
@BeanProperty
|
||||
|
|
|
@ -36,6 +36,9 @@ class LevelDBNodeState extends NodeState {
|
|||
@JsonProperty
|
||||
var position: Long = -1
|
||||
|
||||
@JsonProperty
|
||||
var weight: Int = 0
|
||||
|
||||
@JsonProperty
|
||||
var elected: String = _
|
||||
|
||||
|
@ -93,6 +96,7 @@ class MasterElector(store: ElectingLevelDBStore) extends ClusteredSingleton[Leve
|
|||
rc.id = store.brokerName
|
||||
rc.elected = elected
|
||||
rc.position = position
|
||||
rc.weight = store.weight
|
||||
rc.address = address
|
||||
rc.container = store.container
|
||||
rc.address = address
|
||||
|
@ -140,7 +144,10 @@ class MasterElector(store: ElectingLevelDBStore) extends ClusteredSingleton[Leve
|
|||
if (elected == null) {
|
||||
// Find the member with the most updates.
|
||||
val sortedMembers = members.filter(_._2.position >= 0).sortWith {
|
||||
(a, b) => a._2.position > b._2.position
|
||||
(a, b) => {
|
||||
a._2.position > b._2.position ||
|
||||
(a._2.position == b._2.position && a._2.weight > b._2.weight )
|
||||
}
|
||||
}
|
||||
if (sortedMembers.size != members.size) {
|
||||
info("Not enough cluster members have reported their update positions yet.")
|
||||
|
|
Loading…
Reference in New Issue