problem: default quorum options per method may not work for everyone but cannot be reconfigured

This commit is contained in:
Igor Artamonov
2022-06-18 15:15:35 -04:00
parent 6e0ca56033
commit 6aae65cf40

View File

@@ -47,6 +47,7 @@ class ManagedCallMethods(
) )
private val quorum: MutableMap<String, CallQuorum> = HashMap() private val quorum: MutableMap<String, CallQuorum> = HashMap()
private val staticResponse: MutableMap<String, String> = HashMap() private val staticResponse: MutableMap<String, String> = HashMap()
private val redefined = delegated.filter(enabled::contains).sorted()
init { init {
enabled.forEach { m -> enabled.forEach { m ->
@@ -73,7 +74,7 @@ class ManagedCallMethods(
override fun getQuorumFor(method: String): CallQuorum { override fun getQuorumFor(method: String): CallQuorum {
return when { return when {
Collections.binarySearch(delegated, method) >= 0 -> delegate.getQuorumFor(method) isDelegated(method) && !isRedefined(method) -> delegate.getQuorumFor(method)
enabled.contains(method) -> quorum[method] ?: defaultQuorum enabled.contains(method) -> quorum[method] ?: defaultQuorum
else -> { else -> {
log.warn("Getting quorum for unknown method") log.warn("Getting quorum for unknown method")
@@ -82,6 +83,14 @@ class ManagedCallMethods(
} }
} }
private fun isDelegated(method: String): Boolean {
return Collections.binarySearch(delegated, method) >= 0
}
private fun isRedefined(method: String): Boolean {
return Collections.binarySearch(redefined, method) >= 0
}
override fun isCallable(method: String): Boolean { override fun isCallable(method: String): Boolean {
return allAllowed.contains(method) return allAllowed.contains(method)
} }