Make loggers not abstract (#181)

* Make loggers not abstract
This commit is contained in:
KirillPamPam
2023-03-21 18:38:46 +04:00
committed by GitHub
parent f41ee1e577
commit a26f1958e9
19 changed files with 4 additions and 72 deletions

View File

@@ -41,9 +41,9 @@ abstract class AbstractHead @JvmOverloads constructor(
private val awaitHeadTimeoutMs: Long = 60_000,
private val upstreamId: String = ""
) : Head {
protected val log = LoggerFactory.getLogger(this::class.java)
companion object {
private val log = LoggerFactory.getLogger(AbstractHead::class.java)
private val executor = Executors.newSingleThreadScheduledExecutor()
}

View File

@@ -49,9 +49,7 @@ abstract class DefaultUpstream(
) :
this(id, hash, Long.MAX_VALUE, UpstreamAvailability.UNAVAILABLE, options, role, targets, node, chainConfig)
companion object {
private val log = LoggerFactory.getLogger(DefaultUpstream::class.java)
}
protected val log = LoggerFactory.getLogger(this::class.java)
private val status = AtomicReference(Status(defaultLag, defaultAvail, statusByLag(defaultLag, defaultAvail)))
private val statusStream = Sinks.many()

View File

@@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.upstream
import io.emeraldpay.dshackle.commons.DynamicMergeFlux
import io.emeraldpay.dshackle.data.BlockContainer
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import org.slf4j.LoggerFactory
import reactor.core.Disposable
import reactor.core.scheduler.Scheduler
@@ -13,10 +12,6 @@ open class DynamicMergedHead(
scheduler: Scheduler
) : AbstractHead(forkChoice, upstreamId = label), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(DynamicMergedHead::class.java)
}
private var subscription: Disposable? = null
private val dynamicFlux: DynamicMergeFlux<String, BlockContainer> = DynamicMergeFlux(scheduler)

View File

@@ -20,7 +20,6 @@ import com.google.common.annotations.VisibleForTesting
import io.emeraldpay.dshackle.cache.Caches
import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import org.slf4j.LoggerFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
@@ -30,10 +29,6 @@ class MergedHead @JvmOverloads constructor(
private val label: String = ""
) : AbstractHead(forkChoice, upstreamId = label), Lifecycle, CachesEnabled {
companion object {
private val log = LoggerFactory.getLogger(MergedHead::class.java)
}
private var subscription: Disposable? = null
override fun isRunning(): Boolean {

View File

@@ -55,10 +55,11 @@ abstract class Multistream(
) : Upstream, Lifecycle, HasEgressSubscription {
companion object {
private val log = LoggerFactory.getLogger(Multistream::class.java)
private const val metrics = "upstreams"
}
protected val log = LoggerFactory.getLogger(this::class.java)
private var started = false
private var cacheSubscription: Disposable? = null

View File

@@ -23,7 +23,6 @@ import io.emeraldpay.dshackle.upstream.Lifecycle
import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import org.slf4j.LoggerFactory
import org.springframework.scheduling.concurrent.CustomizableThreadFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
@@ -39,7 +38,6 @@ class BitcoinRpcHead(
) : Head, AbstractHead(MostWorkForkChoice(), awaitHeadTimeoutMs = 1200_000), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(BitcoinRpcHead::class.java)
val scheduler =
Schedulers.fromExecutor(Executors.newCachedThreadPool(CustomizableThreadFactory("bitcoin-rpc-head")))
}

View File

@@ -26,7 +26,6 @@ import io.emeraldpay.dshackle.upstream.Lifecycle
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.calls.CallMethods
import org.slf4j.LoggerFactory
import reactor.core.Disposable
open class BitcoinRpcUpstream(
@@ -42,10 +41,6 @@ open class BitcoinRpcUpstream(
chainConfig: ChainsConfig.ChainConfig
) : BitcoinUpstream(id, chain, options, role, callMethods, node, esploraClient, chainConfig), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(BitcoinRpcUpstream::class.java)
}
private var validatorSubscription: Disposable? = null
private val capabilities = if (options.providesBalance == true) {

View File

@@ -22,7 +22,6 @@ import io.emeraldpay.dshackle.startup.QuorumForLabels
import io.emeraldpay.dshackle.upstream.DefaultUpstream
import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.calls.DefaultBitcoinMethods
import org.slf4j.LoggerFactory
abstract class BitcoinUpstream(
id: String,
@@ -42,8 +41,4 @@ abstract class BitcoinUpstream(
role: UpstreamsConfig.UpstreamRole,
chainConfig: ChainsConfig.ChainConfig
) : this(id, chain, options, role, DefaultBitcoinMethods(), QuorumForLabels.QuorumItem.empty(), null, chainConfig)
companion object {
private val log = LoggerFactory.getLogger(BitcoinUpstream::class.java)
}
}

View File

@@ -10,7 +10,6 @@ import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import org.apache.commons.codec.binary.Hex
import org.slf4j.LoggerFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
@@ -22,11 +21,6 @@ class BitcoinZMQHead(
private val api: JsonRpcReader,
private val extractBlock: ExtractBlock,
) : Head, AbstractHead(MostWorkForkChoice(), awaitHeadTimeoutMs = 1200_000), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(BitcoinZMQHead::class.java)
}
private var refreshSubscription: Disposable? = null
fun connect(): Flux<BlockContainer> {

View File

@@ -24,7 +24,6 @@ import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.etherjar.hex.HexQuantity
import org.slf4j.LoggerFactory
import reactor.core.publisher.Mono
open class DefaultEthereumHead(
@@ -33,10 +32,6 @@ open class DefaultEthereumHead(
blockValidator: BlockValidator
) : Head, AbstractHead(forkChoice, blockValidator, 60_000, upstreamId) {
companion object {
private val log = LoggerFactory.getLogger(DefaultEthereumHead::class.java)
}
fun getLatestBlock(api: JsonRpcReader): Mono<BlockContainer> {
return api.read(JsonRpcRequest("eth_blockNumber", emptyList()))
.subscribeOn(EthereumRpcHead.scheduler)

View File

@@ -38,7 +38,6 @@ import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
import io.emeraldpay.dshackle.upstream.forkchoice.PriorityForkChoice
import io.emeraldpay.dshackle.upstream.grpc.GrpcUpstream
import org.slf4j.LoggerFactory
import org.springframework.cloud.sleuth.Tracer
import org.springframework.util.ConcurrentReferenceHashMap
import reactor.core.publisher.Flux
@@ -54,10 +53,6 @@ open class EthereumMultistream(
tracer: Tracer
) : Multistream(chain, upstreams as MutableList<Upstream>, caches), EthereumLikeMultistream {
companion object {
private val log = LoggerFactory.getLogger(EthereumMultistream::class.java)
}
private var head: DynamicMergedHead = DynamicMergedHead(
PriorityForkChoice(),
"ETH Multistream of ${chain.chainCode}",

View File

@@ -20,7 +20,6 @@ import io.emeraldpay.dshackle.reader.JsonRpcReader
import io.emeraldpay.dshackle.upstream.BlockValidator
import io.emeraldpay.dshackle.upstream.Lifecycle
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import org.slf4j.LoggerFactory
import org.springframework.scheduling.concurrent.CustomizableThreadFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
@@ -41,8 +40,6 @@ class EthereumRpcHead(
Schedulers.fromExecutor(Executors.newCachedThreadPool(CustomizableThreadFactory("ethereum-rpc-head")))
}
private val log = LoggerFactory.getLogger(EthereumRpcHead::class.java)
private var refreshSubscription: Disposable? = null
override fun start() {

View File

@@ -29,7 +29,6 @@ import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory
import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector
import org.slf4j.LoggerFactory
import org.springframework.context.Lifecycle
import reactor.core.Disposable
@@ -44,7 +43,6 @@ open class EthereumRpcUpstream(
connectorFactory: ConnectorFactory,
chainConfig: ChainsConfig.ChainConfig
) : EthereumUpstream(id, hash, options, role, targets, node, chainConfig), Lifecycle, Upstream, CachesEnabled {
private val log = LoggerFactory.getLogger(EthereumRpcUpstream::class.java)
private val validator: EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions())
private val connector: EthereumConnector = connectorFactory.create(this, validator, chain, false)

View File

@@ -28,7 +28,6 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.etherjar.rpc.json.BlockJson
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
import org.slf4j.LoggerFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
@@ -45,10 +44,6 @@ class EthereumWsHead(
private val skipEnhance: Boolean
) : DefaultEthereumHead(upstreamId, forkChoice, blockValidator), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(EthereumWsHead::class.java)
}
private var subscription: Disposable? = null
override fun isRunning(): Boolean {

View File

@@ -36,7 +36,6 @@ import io.emeraldpay.dshackle.upstream.ethereum.subscribe.NoPendingTxes
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
import io.emeraldpay.dshackle.upstream.forkchoice.PriorityForkChoice
import io.emeraldpay.dshackle.upstream.grpc.GrpcUpstream
import org.slf4j.LoggerFactory
import org.springframework.cloud.sleuth.Tracer
import org.springframework.util.ConcurrentReferenceHashMap
import reactor.core.publisher.Flux
@@ -52,10 +51,6 @@ open class EthereumPosMultiStream(
tracer: Tracer
) : Multistream(chain, upstreams as MutableList<Upstream>, caches), EthereumLikeMultistream {
companion object {
private val log = LoggerFactory.getLogger(EthereumPosMultiStream::class.java)
}
private var head: DynamicMergedHead = DynamicMergedHead(
PriorityForkChoice(),
"ETH Pos Multistream of ${chain.chainCode}",

View File

@@ -30,7 +30,6 @@ import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory
import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector
import org.slf4j.LoggerFactory
import reactor.core.Disposable
open class EthereumPosRpcUpstream(
@@ -44,7 +43,6 @@ open class EthereumPosRpcUpstream(
connectorFactory: ConnectorFactory,
chainConfig: ChainsConfig.ChainConfig
) : EthereumPosUpstream(id, hash, options, role, targets, node, chainConfig), Lifecycle, Upstream, CachesEnabled {
private val log = LoggerFactory.getLogger(EthereumPosRpcUpstream::class.java)
private val validator: EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions())
private val connector: EthereumConnector = connectorFactory.create(this, validator, chain, true)

View File

@@ -38,7 +38,6 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.etherjar.rpc.RpcException
import org.reactivestreams.Publisher
import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import java.math.BigInteger
@@ -65,10 +64,6 @@ class BitcoinGrpcUpstream(
GrpcUpstream,
Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(BitcoinGrpcUpstream::class.java)
}
private val extractBlock = ExtractBlock()
private val defaultReader: JsonRpcReader = client.getReader()
private val blockConverter: Function<BlockchainOuterClass.ChainHead, BlockContainer> = Function { value ->

View File

@@ -43,7 +43,6 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.etherjar.domain.BlockHash
import io.emeraldpay.etherjar.rpc.RpcException
import org.reactivestreams.Publisher
import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import java.math.BigInteger
@@ -106,7 +105,6 @@ open class EthereumGrpcUpstream(
}
}
private val log = LoggerFactory.getLogger(EthereumGrpcUpstream::class.java)
private val upstreamStatus = GrpcUpstreamStatus(overrideLabels)
private val grpcHead = GrpcHead(getId(), chain, this, remote, blockConverter, reloadBlock, MostWorkForkChoice())
private var capabilities: Set<Capability> = emptySet()

View File

@@ -26,7 +26,6 @@ import io.emeraldpay.dshackle.upstream.Lifecycle
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import org.reactivestreams.Publisher
import org.slf4j.LoggerFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
@@ -50,10 +49,6 @@ class GrpcHead(
private val forkChoice: ForkChoice
) : AbstractHead(forkChoice, upstreamId = id), Lifecycle {
companion object {
private val log = LoggerFactory.getLogger(GrpcHead::class.java)
}
private var headSubscription: Disposable? = null
/**