This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/master by this push:
new e4fb4d0 Prefer using SLF4J instead of logl
e4fb4d0 is described below
commit e4fb4d018bc419ef1bc2b7bf8064ca44b1c3f332
Author: Antoine Toulme <[email protected]>
AuthorDate: Sat Feb 29 16:42:44 2020 -0800
Prefer using SLF4J instead of logl
---
dependency-versions.gradle | 7 +-
devp2p/build.gradle | 3 +-
.../org/apache/tuweni/devp2p/DiscoveryService.kt | 20 ++--
.../apache/tuweni/devp2p/DiscoveryServiceTest.kt | 11 +-
dns-discovery/build.gradle | 2 +-
ethstats/build.gradle | 3 +-
.../apache/tuweni/ethstats/EthStatsReporter.java | 8 +-
.../tuweni/ethstats/EthStatsReporterTest.java | 5 -
gossip/build.gradle | 3 +-
hobbits-relayer/build.gradle | 3 +-
les/build.gradle | 3 +-
net-coroutines/build.gradle | 3 +-
.../tuweni/net/coroutines/CoroutineChannelGroup.kt | 12 +-
.../tuweni/net/coroutines/CoroutineSelector.kt | 14 +--
.../tuweni/net/coroutines/CoroutineSelectorTest.kt | 9 +-
rlpx/build.gradle | 3 +-
.../apache/tuweni/rlpx/vertx/VertxRLPxService.java | 31 +----
.../tuweni/rlpx/wire/DefaultWireConnection.java | 8 +-
.../tuweni/rlpx/vertx/VertxAcceptanceTest.java | 60 ++--------
.../tuweni/rlpx/vertx/VertxRLPxServiceTest.java | 118 +++----------------
.../rlpx/wire/DefaultWireConnectionTest.java | 127 +++++----------------
.../org/apache/tuweni/rlpx/wire/PingPongTest.java | 20 +---
scuttlebutt-client-lib/build.gradle | 5 +-
.../scuttlebutt/lib/ScuttlebuttClientFactory.java | 19 +--
scuttlebutt-discovery/build.gradle | 3 +-
.../ScuttlebuttLocalDiscoveryService.java | 11 +-
.../ScuttlebuttLocalDiscoveryServiceTest.java | 57 ++-------
scuttlebutt-handshake/build.gradle | 4 +-
.../vertx/SecureScuttlebuttVertxClient.java | 25 +---
.../handshake/vertx/VertxIntegrationTest.java | 13 +--
scuttlebutt-rpc/build.gradle | 5 +-
.../tuweni/scuttlebutt/rpc/mux/RPCHandler.java | 17 +--
.../scuttlebutt/rpc/PatchworkIntegrationTest.java | 12 +-
.../rpc/mux/PatchworkIntegrationTest.java | 17 +--
34 files changed, 139 insertions(+), 522 deletions(-)
diff --git a/dependency-versions.gradle b/dependency-versions.gradle
index 11b2eed..f5fe997 100644
--- a/dependency-versions.gradle
+++ b/dependency-versions.gradle
@@ -63,14 +63,11 @@ dependencyManagement {
entry 'spek-api'
entry 'spek-junit-platform-engine'
}
- dependencySet(group: 'org.logl', version: '0.3.1') {
- entry 'logl-api'
- entry 'logl-logl'
- entry 'logl-vertx'
- }
dependency('org.mapdb:mapdb:3.0.7')
dependency('org.miracl.milagro.amcl:milagro-crypto-java:0.4.0')
dependency('org.rocksdb:rocksdbjni:5.17.2')
+ dependency('org.slf4j:slf4j-api:1.7.30')
+
dependency('org.xerial.snappy:snappy-java:1.1.7.2')
}
}
diff --git a/devp2p/build.gradle b/devp2p/build.gradle
index b068a67..77704b2 100644
--- a/devp2p/build.gradle
+++ b/devp2p/build.gradle
@@ -22,7 +22,7 @@ dependencies {
compile project(':rlp')
compile 'io.vertx:vertx-core'
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
compileOnly 'org.bouncycastle:bcprov-jdk15on'
@@ -30,7 +30,6 @@ dependencies {
testCompile 'org.bouncycastle:bcprov-jdk15on'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
- testCompile 'org.logl:logl-logl'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git
a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
index 9a09060..039f5bc 100644
--- a/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
+++ b/devp2p/src/main/kotlin/org/apache/tuweni/devp2p/DiscoveryService.kt
@@ -16,6 +16,7 @@
*/
package org.apache.tuweni.devp2p
+import org.slf4j.LoggerFactory
import com.google.common.cache.Cache
import com.google.common.cache.CacheBuilder
import kotlinx.coroutines.CancellationException
@@ -53,8 +54,6 @@ import org.apache.tuweni.kademlia.xorDistCmp
import org.apache.tuweni.net.coroutines.CommonCoroutineGroup
import org.apache.tuweni.net.coroutines.CoroutineChannelGroup
import org.apache.tuweni.net.coroutines.CoroutineDatagramChannel
-import org.logl.LogMessage.patternFormat
-import org.logl.LoggerProvider
import java.io.IOException
import java.net.InetAddress
import java.net.InetSocketAddress
@@ -115,7 +114,6 @@ interface DiscoveryService {
* @param advertiseTcpPort the TCP port to advertise to peers, or `null`
if it should be the same as the UDP port.
* @param routingTable a [PeerRoutingTable] which handles the ÐΞVp2p
routing table
* @param packetFilter a filter for incoming packets
- * @param loggerProvider a provider for a logger
* @param channelGroup the [CoroutineChannelGroup] for network channels
created by this service
* @param bufferAllocator a [ByteBuffer] allocator, which must return
buffers of size 1280 bytes or larger
* @param timeSupplier a function supplying the current time, in
milliseconds since the epoch
@@ -134,7 +132,6 @@ interface DiscoveryService {
advertiseTcpPort: Int? = null,
routingTable: PeerRoutingTable =
DevP2PPeerRoutingTable(keyPair.publicKey()),
packetFilter: ((SECP256K1.PublicKey, InetSocketAddress) -> Boolean)? =
null,
- loggerProvider: LoggerProvider = LoggerProvider.nullProvider(),
channelGroup: CoroutineChannelGroup = CommonCoroutineGroup,
bufferAllocator: () -> ByteBuffer = DEFAULT_BUFFER_ALLOCATOR,
timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER
@@ -152,7 +149,6 @@ interface DiscoveryService {
advertiseTcpPort,
routingTable,
packetFilter,
- loggerProvider,
channelGroup,
bufferAllocator,
timeSupplier
@@ -173,7 +169,6 @@ interface DiscoveryService {
* @param advertiseTcpPort the TCP port to advertise to peers, or `null`
if it should be the same as the UDP port.
* @param routingTable a [PeerRoutingTable] which handles the ÐΞVp2p
routing table
* @param packetFilter a filter for incoming packets
- * @param loggerProvider a provider for a logger
* @param channelGroup the [CoroutineChannelGroup] for network channels
created by this service
* @param bufferAllocator a [ByteBuffer] allocator, which must return
buffers of size 1280 bytes or larger
* @param timeSupplier a function supplying the current time, in
milliseconds since the epoch
@@ -191,14 +186,13 @@ interface DiscoveryService {
advertiseTcpPort: Int? = null,
routingTable: PeerRoutingTable =
DevP2PPeerRoutingTable(keyPair.publicKey()),
packetFilter: ((SECP256K1.PublicKey, InetSocketAddress) -> Boolean)? =
null,
- loggerProvider: LoggerProvider = LoggerProvider.nullProvider(),
channelGroup: CoroutineChannelGroup = CommonCoroutineGroup,
bufferAllocator: () -> ByteBuffer = DEFAULT_BUFFER_ALLOCATOR,
timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER
): DiscoveryService {
return CoroutineDiscoveryService(
keyPair, seq, enrData, bindAddress, bootstrapURIs, advertiseAddress,
advertiseUdpPort, advertiseTcpPort,
- peerRepository, routingTable, packetFilter, loggerProvider,
channelGroup, bufferAllocator, timeSupplier
+ peerRepository, routingTable, packetFilter, channelGroup,
bufferAllocator, timeSupplier
)
}
}
@@ -290,14 +284,16 @@ internal class CoroutineDiscoveryService(
private val peerRepository: PeerRepository = EphemeralPeerRepository(),
private val routingTable: PeerRoutingTable =
DevP2PPeerRoutingTable(keyPair.publicKey()),
private val packetFilter: ((SECP256K1.PublicKey, InetSocketAddress) ->
Boolean)? = null,
- loggerProvider: LoggerProvider = LoggerProvider.nullProvider(),
channelGroup: CoroutineChannelGroup = CommonCoroutineGroup,
private val bufferAllocator: () -> ByteBuffer =
DiscoveryService.DEFAULT_BUFFER_ALLOCATOR,
private val timeSupplier: () -> Long =
DiscoveryService.CURRENT_TIME_SUPPLIER,
private val channel: CoroutineDatagramChannel =
CoroutineDatagramChannel.open(channelGroup)
) : DiscoveryService, CoroutineScope {
- private val logger = loggerProvider.getLogger(DiscoveryService::class.java)
+ companion object {
+ internal val logger = LoggerFactory.getLogger(DiscoveryService::class.java)
+ }
+
private val serviceDescriptor = "ÐΞVp2p discovery " +
System.identityHashCode(this)
private val selfEndpoint: Endpoint
private val enr: Bytes
@@ -455,7 +451,7 @@ internal class CoroutineDiscoveryService(
try {
receivePacket(datagram, address, arrivalTime)
} catch (e: Throwable) {
- logger.error(patternFormat("{}: unexpected error during packet
handling", serviceDescriptor), e)
+ logger.error(serviceDescriptor + ": unexpected error during packet
handling", e)
}
}
job.invokeOnCompletion { activityLatch.countDown() }
@@ -961,7 +957,7 @@ internal class CoroutineDiscoveryService(
// ignore
} catch (e: Exception) {
logger.error(
- patternFormat("{}: Error while sending FindNode requests for peer
{}", serviceDescriptor, peer.nodeId),
+ "$serviceDescriptor: Error while sending FindNode requests for peer
${peer.nodeId}",
e
)
}
diff --git
a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/DiscoveryServiceTest.kt
b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/DiscoveryServiceTest.kt
index 0eedbd0..e933bfb 100644
--- a/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/DiscoveryServiceTest.kt
+++ b/devp2p/src/test/kotlin/org/apache/tuweni/devp2p/DiscoveryServiceTest.kt
@@ -29,8 +29,6 @@ import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
-import org.logl.Level
-import org.logl.logl.SimpleLogger
import java.net.InetAddress
import java.net.InetSocketAddress
import java.net.SocketAddress
@@ -71,7 +69,6 @@ internal class DiscoveryServiceTest {
fun shouldRespondToPingAndRecordEndpoint() = runBlocking {
val peerRepository = EphemeralPeerRepository()
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = SECP256K1.KeyPair.random(),
peerRepository = peerRepository
)
@@ -103,7 +100,6 @@ internal class DiscoveryServiceTest {
val peerRepository = EphemeralPeerRepository()
val routingTable = DevP2PPeerRoutingTable(serviceKeyPair.publicKey())
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = serviceKeyPair,
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().toHexString() +
"@127.0.0.1:" + bootstrapClient.localPort)
@@ -145,7 +141,6 @@ internal class DiscoveryServiceTest {
val peerRepository = EphemeralPeerRepository()
val routingTable = DevP2PPeerRoutingTable(serviceKeyPair.publicKey())
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = serviceKeyPair,
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().toHexString() +
"@127.0.0.1:" + bootstrapClient.localPort)
@@ -178,7 +173,6 @@ internal class DiscoveryServiceTest {
val boostrapClient =
CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = SECP256K1.KeyPair.random(),
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().bytes().toHexString() +
"@127.0.0.1:" + boostrapClient.localPort)
@@ -202,7 +196,6 @@ internal class DiscoveryServiceTest {
val boostrapClient =
CoroutineDatagramChannel.open().bind(InetSocketAddress(0))
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = SECP256K1.KeyPair.random(),
bootstrapURIs = listOf(
URI("enode://" + bootstrapKeyPair.publicKey().bytes().toHexString() +
"@127.0.0.1:" + boostrapClient.localPort)
@@ -228,7 +221,6 @@ internal class DiscoveryServiceTest {
fun shouldRequirePingPongBeforeRespondingToFindNodesFromUnverifiedPeer() =
runBlocking {
val peerRepository = EphemeralPeerRepository()
val discoveryService = DiscoveryService.open(
- loggerProvider =
SimpleLogger.withLogLevel(Level.ERROR).toOutputStream(System.err),
keyPair = SECP256K1.KeyPair.random(),
peerRepository = peerRepository
)
@@ -271,8 +263,7 @@ internal class DiscoveryServiceTest {
/* ktlint-enable */
val discoveryService = DiscoveryService.open(
SECP256K1.KeyPair.random(),
- bootstrapURIs = boostrapNodes,
- loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toOutputStream(System.out)
+ bootstrapURIs = boostrapNodes
)
runBlocking {
diff --git a/dns-discovery/build.gradle b/dns-discovery/build.gradle
index b7af47c..061a2ff 100644
--- a/dns-discovery/build.gradle
+++ b/dns-discovery/build.gradle
@@ -24,7 +24,7 @@ dependencies {
compile 'dnsjava:dnsjava'
compile 'io.vertx:vertx-core'
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
compileOnly 'org.bouncycastle:bcprov-jdk15on'
diff --git a/ethstats/build.gradle b/ethstats/build.gradle
index 75c99fd..333ed48 100644
--- a/ethstats/build.gradle
+++ b/ethstats/build.gradle
@@ -19,8 +19,7 @@ dependencies {
compile 'com.google.guava:guava'
compile 'io.vertx:vertx-core'
compile 'org.bouncycastle:bcprov-jdk15on'
- compile 'org.logl:logl-api'
- compile 'org.logl:logl-logl'
+ compile 'org.slf4j:slf4j-api'
compile project(':bytes')
compile project(':eth')
diff --git
a/ethstats/src/main/java/org/apache/tuweni/ethstats/EthStatsReporter.java
b/ethstats/src/main/java/org/apache/tuweni/ethstats/EthStatsReporter.java
index b811a26..c17501c 100644
--- a/ethstats/src/main/java/org/apache/tuweni/ethstats/EthStatsReporter.java
+++ b/ethstats/src/main/java/org/apache/tuweni/ethstats/EthStatsReporter.java
@@ -41,7 +41,8 @@ import io.vertx.core.WorkerExecutor;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.WebSocket;
-import org.logl.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* ETHNetStats reporting service.
@@ -54,6 +55,7 @@ import org.logl.Logger;
public final class EthStatsReporter {
private final static ObjectMapper mapper = new ObjectMapper();
+ private final static Logger logger =
LoggerFactory.getLogger(EthStatsReporter.class);
static {
mapper.registerModule(new EthJsonModule());
@@ -67,7 +69,6 @@ public final class EthStatsReporter {
private final String id;
private final Vertx vertx;
private final List<URI> ethstatsServerURIs;
- private final Logger logger;
private final AtomicBoolean started = new AtomicBoolean(false);
private final AtomicBoolean waitingOnPong = new AtomicBoolean(false);
private final NodeInfo nodeInfo;
@@ -85,7 +86,6 @@ public final class EthStatsReporter {
* Default constructor.
*
* @param vertx a Vert.x instance, externally managed.
- * @param logger a logger
* @param ethstatsServerURIs the URIs to connect to eth-netstats, such as
ws://www.ethnetstats.org:3000/api. URIs are
* tried in sequence, and the first one to work is used.
* @param secret the secret to use when we connect to eth-netstats
@@ -100,7 +100,6 @@ public final class EthStatsReporter {
*/
public EthStatsReporter(
Vertx vertx,
- Logger logger,
List<URI> ethstatsServerURIs,
String secret,
String name,
@@ -113,7 +112,6 @@ public final class EthStatsReporter {
Consumer<List<UInt256>> historyRequester) {
this.id = UUID.randomUUID().toString();
this.vertx = vertx;
- this.logger = logger;
this.ethstatsServerURIs = ethstatsServerURIs;
this.secret = secret;
this.nodeInfo = new NodeInfo(name, node, port, network, protocol, os,
osVer);
diff --git
a/ethstats/src/test/java/org/apache/tuweni/ethstats/EthStatsReporterTest.java
b/ethstats/src/test/java/org/apache/tuweni/ethstats/EthStatsReporterTest.java
index 936aed9..f502d99 100644
---
a/ethstats/src/test/java/org/apache/tuweni/ethstats/EthStatsReporterTest.java
+++
b/ethstats/src/test/java/org/apache/tuweni/ethstats/EthStatsReporterTest.java
@@ -26,9 +26,6 @@ import java.util.Collections;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.Logger;
-import org.logl.logl.SimpleLogger;
@ExtendWith(VertxExtension.class)
public class EthStatsReporterTest {
@@ -36,11 +33,9 @@ public class EthStatsReporterTest {
//@Disabled
@Test
void testConnectToLocalEthStats(@VertxInstance Vertx vertx) throws
InterruptedException {
- Logger logger =
SimpleLogger.withLogLevel(Level.DEBUG).toOutputStream(System.out).getLogger("wat");
EthStatsReporter reporter = new EthStatsReporter(
vertx,
- logger,
Collections.singletonList(URI.create("ws://localhost:3000/api")),
"wat",
"name",
diff --git a/gossip/build.gradle b/gossip/build.gradle
index 46bb4a2..daae430 100644
--- a/gossip/build.gradle
+++ b/gossip/build.gradle
@@ -21,8 +21,7 @@ dependencies {
compile 'info.picocli:picocli'
compile 'io.vertx:vertx-core'
compile 'org.bouncycastle:bcprov-jdk15on'
- compile 'org.logl:logl-api'
- compile 'org.logl:logl-logl'
+ compile 'org.slf4j:slf4j-api'
compile project(':bytes')
compile project(':config')
compile project(':plumtree')
diff --git a/hobbits-relayer/build.gradle b/hobbits-relayer/build.gradle
index e1386a1..d07a64b 100644
--- a/hobbits-relayer/build.gradle
+++ b/hobbits-relayer/build.gradle
@@ -20,8 +20,7 @@ dependencies {
compile 'info.picocli:picocli'
compile 'io.vertx:vertx-core'
compile 'org.bouncycastle:bcprov-jdk15on'
- compile 'org.logl:logl-api'
- compile 'org.logl:logl-logl'
+ compile 'org.slf4j:slf4j-api'
testCompile project(':junit')
testCompile 'org.bouncycastle:bcprov-jdk15on'
diff --git a/les/build.gradle b/les/build.gradle
index d9c9d6c..e715034 100644
--- a/les/build.gradle
+++ b/les/build.gradle
@@ -20,7 +20,7 @@ dependencies {
compile project(':kv')
compile project(':rlpx')
compile 'com.google.guava:guava'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
compileOnly 'io.vertx:vertx-core'
compile 'org.xerial.snappy:snappy-java'
@@ -31,7 +31,6 @@ dependencies {
testCompile 'org.bouncycastle:bcprov-jdk15on'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
- testCompile 'org.logl:logl-logl'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git a/net-coroutines/build.gradle b/net-coroutines/build.gradle
index 53b9193..ebdcd7b 100644
--- a/net-coroutines/build.gradle
+++ b/net-coroutines/build.gradle
@@ -15,12 +15,11 @@ description = 'Classes and utilities for coroutine based
networking.'
dependencies {
compile 'com.google.guava:guava'
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
testCompile project(':junit')
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
- testCompile 'org.logl:logl-logl'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git
a/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineChannelGroup.kt
b/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineChannelGroup.kt
index 2d60c77..95e8214 100644
---
a/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineChannelGroup.kt
+++
b/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineChannelGroup.kt
@@ -16,7 +16,7 @@
*/
package org.apache.tuweni.net.coroutines
-import org.logl.LoggerProvider
+import org.slf4j.LoggerFactory
import java.nio.channels.Channel
import java.nio.channels.SelectableChannel
import java.nio.channels.ShutdownChannelGroupException
@@ -61,12 +61,11 @@ sealed class CoroutineChannelGroup {
fun open(
nSelectors: Int = Runtime.getRuntime().availableProcessors(),
executor: Executor = Executors.newFixedThreadPool(nSelectors,
CoroutineSelector.DEFAULT_THREAD_FACTORY),
- loggerProvider: LoggerProvider = LoggerProvider.nullProvider(),
selectTimeout: Long = 1000,
idleTimeout: Long = 10000
): CoroutineChannelGroup {
require(nSelectors > 0) { "nSelectors must be larger than zero" }
- return CoroutineSelectorChannelGroup(nSelectors, executor,
loggerProvider, selectTimeout, idleTimeout)
+ return CoroutineSelectorChannelGroup(nSelectors, executor,
selectTimeout, idleTimeout)
}
}
@@ -113,15 +112,16 @@ sealed class CoroutineChannelGroup {
internal class CoroutineSelectorChannelGroup(
nSelectors: Int,
private val executor: Executor,
- loggerProvider: LoggerProvider,
selectTimeout: Long,
idleTimeout: Long
) : CoroutineChannelGroup() {
- private val logger =
loggerProvider.getLogger(CoroutineChannelGroup::class.java)
+ companion object {
+ private val logger =
LoggerFactory.getLogger(CoroutineChannelGroup::class.java)
+ }
private var selectors: Array<CoroutineSelector>? = Array(nSelectors) {
- CoroutineSelector.open(executor, loggerProvider, selectTimeout,
idleTimeout)
+ CoroutineSelector.open(executor, selectTimeout, idleTimeout)
}
private val channels =
Collections.synchronizedSet(Collections.newSetFromMap(WeakHashMap<Channel,
Boolean>()))
@Volatile
diff --git
a/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelector.kt
b/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelector.kt
index 6c3fb1b..a4d73a3 100644
---
a/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelector.kt
+++
b/net-coroutines/src/main/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelector.kt
@@ -17,11 +17,10 @@
package org.apache.tuweni.net.coroutines
import com.google.common.util.concurrent.ThreadFactoryBuilder
+import org.slf4j.LoggerFactory
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.suspendCancellableCoroutine
-import org.logl.LogMessage
-import org.logl.LoggerProvider
import java.nio.channels.CancelledKeyException
import java.nio.channels.ClosedChannelException
import java.nio.channels.ClosedSelectorException
@@ -57,7 +56,6 @@ sealed class CoroutineSelector {
*/
fun open(
executor: Executor =
Executors.newSingleThreadExecutor(DEFAULT_THREAD_FACTORY),
- loggerProvider: LoggerProvider = LoggerProvider.nullProvider(),
selectTimeout: Long = 1000,
idleTimeout: Long = 10000
): CoroutineSelector {
@@ -66,7 +64,7 @@ sealed class CoroutineSelector {
val idleTasks = idleTimeout / selectTimeout
require(idleTasks <= Integer.MAX_VALUE) { "idleTimeout is too large" }
- return SingleThreadCoroutineSelector(executor, Selector.open(),
loggerProvider, selectTimeout, idleTasks.toInt())
+ return SingleThreadCoroutineSelector(executor, Selector.open(),
selectTimeout, idleTasks.toInt())
}
}
@@ -118,12 +116,13 @@ sealed class CoroutineSelector {
internal class SingleThreadCoroutineSelector(
private val executor: Executor,
private val selector: Selector,
- loggerProvider: LoggerProvider,
private val selectTimeout: Long,
private val idleTasks: Int
) : CoroutineSelector() {
- private val logger = loggerProvider.getLogger(CoroutineSelector::class.java)
+ companion object {
+ private val logger = LoggerFactory.getLogger(CoroutineSelector::class.java)
+ }
private val pendingInterests = Channel<SelectionInterest>(capacity =
Channel.UNLIMITED)
private val pendingCancellations = Channel<SelectionCancellation>(capacity =
Channel.UNLIMITED)
@@ -258,8 +257,7 @@ internal class SingleThreadCoroutineSelector(
processPendingCloses()
} catch (e: Throwable) {
selector.close()
- logger.error(LogMessage.patternFormat("Selector {}: An unexpected
exception occurred in selection loop",
- System.identityHashCode(selector)), e)
+ logger.error("Selector System.identityHashCode(selector)): An unexpected
exception occurred in selection loop", e)
cancelAll(e)
processPendingCloses(e)
}
diff --git
a/net-coroutines/src/test/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelectorTest.kt
b/net-coroutines/src/test/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelectorTest.kt
index 63c533e..cf1eff6 100644
---
a/net-coroutines/src/test/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelectorTest.kt
+++
b/net-coroutines/src/test/kotlin/org/apache/tuweni/net/coroutines/CoroutineSelectorTest.kt
@@ -26,7 +26,6 @@ import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
-import org.logl.logl.SimpleLogger
import java.lang.IllegalArgumentException
import java.net.InetSocketAddress
import java.nio.ByteBuffer
@@ -145,7 +144,7 @@ internal class CoroutineSelectorTest {
client.configureBlocking(false)
server.configureBlocking(false)
- val selector = CoroutineSelector.open(loggerProvider =
SimpleLogger.toOutputStream(System.err))
+ val selector = CoroutineSelector.open()
assertFalse(selector.cancelSelections(client))
@@ -174,7 +173,7 @@ internal class CoroutineSelectorTest {
fun shouldThrowWhenSelectingClosedChannel() {
val pipe = Pipe.open()
pipe.source().configureBlocking(false)
- val selector = CoroutineSelector.open(loggerProvider =
SimpleLogger.toOutputStream(System.err))
+ val selector = CoroutineSelector.open()
pipe.source().close()
assertThrows<ClosedChannelException> {
@@ -190,7 +189,7 @@ internal class CoroutineSelectorTest {
pipe1.source().configureBlocking(false)
val pipe2 = Pipe.open()
pipe2.source().configureBlocking(false)
- val selector = CoroutineSelector.open(loggerProvider =
SimpleLogger.toOutputStream(System.err))
+ val selector = CoroutineSelector.open()
val job1 = async {
selector.select(pipe1.source(), SelectionKey.OP_READ)
@@ -217,7 +216,7 @@ internal class CoroutineSelectorTest {
pipe1.source().configureBlocking(false)
val pipe2 = Pipe.open()
pipe2.source().configureBlocking(false)
- val selector = CoroutineSelector.open(loggerProvider =
SimpleLogger.toOutputStream(System.err))
+ val selector = CoroutineSelector.open()
val job1 = async {
selector.select(pipe1.source(), SelectionKey.OP_READ)
diff --git a/rlpx/build.gradle b/rlpx/build.gradle
index 8a94dab..818d478 100644
--- a/rlpx/build.gradle
+++ b/rlpx/build.gradle
@@ -16,7 +16,7 @@ dependencies {
compile project(':concurrent')
compile project(':rlp')
compile 'com.google.guava:guava'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
compileOnly 'io.vertx:vertx-core'
compile 'org.xerial.snappy:snappy-java'
@@ -27,7 +27,6 @@ dependencies {
testCompile 'org.bouncycastle:bcprov-jdk15on'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
- testCompile 'org.logl:logl-logl'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git
a/rlpx/src/main/java/org/apache/tuweni/rlpx/vertx/VertxRLPxService.java
b/rlpx/src/main/java/org/apache/tuweni/rlpx/vertx/VertxRLPxService.java
index a5bb2f8..7eeaba5 100644
--- a/rlpx/src/main/java/org/apache/tuweni/rlpx/vertx/VertxRLPxService.java
+++ b/rlpx/src/main/java/org/apache/tuweni/rlpx/vertx/VertxRLPxService.java
@@ -46,8 +46,8 @@ import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetServer;
import io.vertx.core.net.NetServerOptions;
import io.vertx.core.net.NetSocket;
-import org.logl.Logger;
-import org.logl.LoggerProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Implementation of RLPx service using Vert.x.
@@ -55,9 +55,8 @@ import org.logl.LoggerProvider;
public final class VertxRLPxService implements RLPxService {
private final static int DEVP2P_VERSION = 5;
+ private final static Logger logger =
LoggerFactory.getLogger(VertxRLPxService.class);
- private final LoggerProvider loggerProvider;
- private final Logger logger;
private final AtomicBoolean started = new AtomicBoolean(false);
private final Vertx vertx;
private final int listenPort;
@@ -83,7 +82,6 @@ public final class VertxRLPxService implements RLPxService {
* Default constructor.
*
* @param vertx Vert.x object used to build the network components
- * @param loggerProvider logger provider to log messages
* @param listenPort the port to listen to
* @param networkInterface the network interface to bind to
* @param advertisedPort the port to advertise in HELLO messages to peers
@@ -93,7 +91,6 @@ public final class VertxRLPxService implements RLPxService {
*/
public VertxRLPxService(
Vertx vertx,
- LoggerProvider loggerProvider,
int listenPort,
String networkInterface,
int advertisedPort,
@@ -102,7 +99,6 @@ public final class VertxRLPxService implements RLPxService {
String clientId) {
this(
vertx,
- loggerProvider,
listenPort,
networkInterface,
advertisedPort,
@@ -116,7 +112,6 @@ public final class VertxRLPxService implements RLPxService {
* Default constructor.
*
* @param vertx Vert.x object used to build the network components
- * @param loggerProvider logger provider to log messages
* @param listenPort the port to listen to
* @param networkInterface the network interface to bind to
* @param advertisedPort the port to advertise in HELLO messages to peers
@@ -127,7 +122,6 @@ public final class VertxRLPxService implements RLPxService {
*/
public VertxRLPxService(
Vertx vertx,
- LoggerProvider loggerProvider,
int listenPort,
String networkInterface,
int advertisedPort,
@@ -141,7 +135,6 @@ public final class VertxRLPxService implements RLPxService {
throw new IllegalArgumentException("Client ID must contain a valid
identifier");
}
this.vertx = vertx;
- this.loggerProvider = loggerProvider;
this.listenPort = listenPort;
this.networkInterface = networkInterface;
this.advertisedPort = advertisedPort;
@@ -149,8 +142,6 @@ public final class VertxRLPxService implements RLPxService {
this.subProtocols = subProtocols;
this.clientId = clientId;
this.repository = repository;
-
- this.logger = loggerProvider.getLogger("VertxRLPxService");
}
@Override
@@ -360,23 +351,13 @@ public final class VertxRLPxService implements
RLPxService {
private DefaultWireConnection createConnection(RLPxConnection conn,
NetSocket netSocket) {
String id = UUID.randomUUID().toString();
- DefaultWireConnection wireConnection = new DefaultWireConnection(
- id,
- conn.publicKey().bytes(),
- conn.peerPublicKey().bytes(),
- loggerProvider.getLogger("wireConnection-" + id),
- message -> {
+ DefaultWireConnection wireConnection =
+ new DefaultWireConnection(id, conn.publicKey().bytes(),
conn.peerPublicKey().bytes(), message -> {
synchronized (conn) {
Bytes bytes = conn.write(message);
vertx.eventBus().send(netSocket.writeHandlerID(),
Buffer.buffer(bytes.toArrayUnsafe()));
}
- },
- conn::configureAfterHandshake,
- netSocket::end,
- handlers,
- DEVP2P_VERSION,
- clientId,
- advertisedPort());
+ }, conn::configureAfterHandshake, netSocket::end, handlers,
DEVP2P_VERSION, clientId, advertisedPort());
repository.add(wireConnection);
return wireConnection;
}
diff --git
a/rlpx/src/main/java/org/apache/tuweni/rlpx/wire/DefaultWireConnection.java
b/rlpx/src/main/java/org/apache/tuweni/rlpx/wire/DefaultWireConnection.java
index 628d5b5..1017c8e 100644
--- a/rlpx/src/main/java/org/apache/tuweni/rlpx/wire/DefaultWireConnection.java
+++ b/rlpx/src/main/java/org/apache/tuweni/rlpx/wire/DefaultWireConnection.java
@@ -27,16 +27,18 @@ import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
import com.google.common.collect.RangeMap;
import com.google.common.collect.TreeRangeMap;
-import org.logl.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A stateful connection between two peers under the Devp2p wire protocol.
*/
public final class DefaultWireConnection implements WireConnection {
+ private final static Logger logger =
LoggerFactory.getLogger(DefaultWireConnection.class);
+
private final Bytes nodeId;
private final Bytes peerNodeId;
- private final Logger logger;
private final String id;
private final Consumer<RLPxMessage> writer;
private final Consumer<HelloMessage> afterHandshakeListener;
@@ -70,7 +72,6 @@ public final class DefaultWireConnection implements
WireConnection {
String id,
Bytes nodeId,
Bytes peerNodeId,
- Logger logger,
Consumer<RLPxMessage> writer,
Consumer<HelloMessage> afterHandshakeListener,
Runnable disconnectHandler,
@@ -81,7 +82,6 @@ public final class DefaultWireConnection implements
WireConnection {
this.id = id;
this.nodeId = nodeId;
this.peerNodeId = peerNodeId;
- this.logger = logger;
this.writer = writer;
this.afterHandshakeListener = afterHandshakeListener;
this.disconnectHandler = disconnectHandler;
diff --git
a/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxAcceptanceTest.java
b/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxAcceptanceTest.java
index 4486bf6..bd064fe 100644
--- a/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxAcceptanceTest.java
+++ b/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxAcceptanceTest.java
@@ -12,7 +12,6 @@
*/
package org.apache.tuweni.rlpx.vertx;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,9 +30,6 @@ import org.apache.tuweni.rlpx.wire.SubProtocol;
import org.apache.tuweni.rlpx.wire.SubProtocolHandler;
import org.apache.tuweni.rlpx.wire.SubProtocolIdentifier;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
@@ -46,10 +42,6 @@ import io.vertx.core.Vertx;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.Logger;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
@ExtendWith({VertxExtension.class, BouncyCastleExtension.class})
class VertxAcceptanceTest {
@@ -122,24 +114,13 @@ class VertxAcceptanceTest {
SECP256K1.KeyPair secondKp = SECP256K1.KeyPair.random();
MyCustomSubProtocol sp = new MyCustomSubProtocol(1);
MyCustomSubProtocol secondSp = new MyCustomSubProtocol(2);
- LoggerProvider logProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err,
UTF_8))));
MemoryWireConnectionsRepository repository = new
MemoryWireConnectionsRepository();
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- logProvider,
- 0,
- "localhost",
- 10000,
- kp,
- Collections.singletonList(sp),
- "Client 1",
- repository);
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 0, "localhost", 10000, kp,
Collections.singletonList(sp), "Client 1", repository);
MemoryWireConnectionsRepository secondRepository = new
MemoryWireConnectionsRepository();
VertxRLPxService secondService = new VertxRLPxService(
vertx,
- logProvider,
0,
"localhost",
10000,
@@ -178,22 +159,10 @@ class VertxAcceptanceTest {
MemoryWireConnectionsRepository repository = new
MemoryWireConnectionsRepository();
MemoryWireConnectionsRepository secondRepository = new
MemoryWireConnectionsRepository();
-
- LoggerProvider logProvider =
- SimpleLogger.toPrintWriter(new PrintWriter(new BufferedWriter(new
OutputStreamWriter(System.err, UTF_8))));
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- logProvider,
- 0,
- "localhost",
- 10000,
- kp,
- Collections.singletonList(sp),
- "Client 1",
- repository);
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 0, "localhost", 10000, kp,
Collections.singletonList(sp), "Client 1", repository);
VertxRLPxService secondService = new VertxRLPxService(
vertx,
- logProvider,
0,
"localhost",
10000,
@@ -243,27 +212,16 @@ class VertxAcceptanceTest {
@Test
@Disabled
void connectToPeer(@VertxInstance Vertx vertx) throws Exception {
- LoggerProvider logProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err,
UTF_8))));
- Logger logger = logProvider.getLogger("test");
+
SECP256K1.KeyPair kp = SECP256K1.KeyPair.fromSecretKey(
SECP256K1.SecretKey
.fromBytes(Bytes32.fromHexString("0x2CADB9DDEA3E675CC5349A1AF053CF2E144AF657016A6155DF4AD767F561F18E")));
- logger.debug(kp.secretKey().bytes().toHexString());
-
- logger.debug("enode://" + kp.publicKey().toHexString() +
"@127.0.0.1:36000");
MemoryWireConnectionsRepository repository = new
MemoryWireConnectionsRepository();
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- logProvider,
- 36000,
- "localhost",
- 36000,
- kp,
- Collections.singletonList(new SubProtocol() {
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 36000, "localhost", 36000, kp,
Collections.singletonList(new SubProtocol() {
@Override
public SubProtocolIdentifier id() {
return new SubProtocolIdentifier() {
@@ -293,9 +251,7 @@ class VertxAcceptanceTest {
public SubProtocolHandler createHandler(RLPxService service) {
return null;
}
- }),
- "Client 1",
- repository);
+ }), "Client 1", repository);
service.start().join();
AsyncCompletion completion = service.connectTo(
diff --git
a/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxRLPxServiceTest.java
b/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxRLPxServiceTest.java
index 2725f03..47f3213 100644
--- a/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxRLPxServiceTest.java
+++ b/rlpx/src/test/java/org/apache/tuweni/rlpx/vertx/VertxRLPxServiceTest.java
@@ -12,7 +12,6 @@
*/
package org.apache.tuweni.rlpx.vertx;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -24,18 +23,12 @@ import org.apache.tuweni.junit.VertxExtension;
import org.apache.tuweni.junit.VertxInstance;
import org.apache.tuweni.rlpx.MemoryWireConnectionsRepository;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
@ExtendWith({VertxExtension.class, BouncyCastleExtension.class})
class VertxRLPxServiceTest {
@@ -44,73 +37,34 @@ class VertxRLPxServiceTest {
void invalidPort(@VertxInstance Vertx vertx) {
assertThrows(
IllegalArgumentException.class,
- () -> new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- -1,
- "localhost",
- 30,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- "a"));
+ () -> new VertxRLPxService(vertx, -1, "localhost", 30,
SECP256K1.KeyPair.random(), new ArrayList<>(), "a"));
}
@Test
void invalidAdvertisedPort(@VertxInstance Vertx vertx) {
assertThrows(
IllegalArgumentException.class,
- () -> new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 3,
- "localhost",
- -1,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- "a"));
+ () -> new VertxRLPxService(vertx, 3, "localhost", -1,
SECP256K1.KeyPair.random(), new ArrayList<>(), "a"));
}
@Test
void invalidClientId(@VertxInstance Vertx vertx) {
assertThrows(
IllegalArgumentException.class,
- () -> new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 34,
- "localhost",
- 23,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- null));
+ () -> new VertxRLPxService(vertx, 34, "localhost", 23,
SECP256K1.KeyPair.random(), new ArrayList<>(), null));
}
@Test
void invalidClientIdSpaces(@VertxInstance Vertx vertx) {
assertThrows(
IllegalArgumentException.class,
- () -> new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 34,
- "localhost",
- 23,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- " "));
+ () -> new VertxRLPxService(vertx, 34, "localhost", 23,
SECP256K1.KeyPair.random(), new ArrayList<>(), " "));
}
@Test
void startAndStopService(@VertxInstance Vertx vertx) throws
InterruptedException {
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 10000,
- "localhost",
- 10000,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- "a");
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 10000, "localhost", 10000,
SECP256K1.KeyPair.random(), new ArrayList<>(), "a");
service.start().join();
try {
@@ -122,15 +76,8 @@ class VertxRLPxServiceTest {
@Test
void startServiceWithPortZero(@VertxInstance Vertx vertx) throws
InterruptedException {
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 0,
- "localhost",
- 0,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- "a");
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 0, "localhost", 0,
SECP256K1.KeyPair.random(), new ArrayList<>(), "a");
service.start().join();
try {
@@ -143,15 +90,8 @@ class VertxRLPxServiceTest {
@Test
void stopServiceWithoutStartingItFirst(@VertxInstance Vertx vertx) {
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 0,
- "localhost",
- 10000,
- SECP256K1.KeyPair.random(),
- new ArrayList<>(),
- "abc");
+ VertxRLPxService service =
+ new VertxRLPxService(vertx, 0, "localhost", 10000,
SECP256K1.KeyPair.random(), new ArrayList<>(), "abc");
AsyncCompletion completion = service.stop();
assertTrue(completion.isDone());
}
@@ -160,26 +100,11 @@ class VertxRLPxServiceTest {
void connectToOtherPeer(@VertxInstance Vertx vertx) throws Exception {
SECP256K1.KeyPair ourPair = SECP256K1.KeyPair.random();
SECP256K1.KeyPair peerPair = SECP256K1.KeyPair.random();
- VertxRLPxService service = new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 0,
- "localhost",
- 10000,
- ourPair,
- new ArrayList<>(),
- "abc");
+ VertxRLPxService service = new VertxRLPxService(vertx, 0, "localhost",
10000, ourPair, new ArrayList<>(), "abc");
service.start().join();
- VertxRLPxService peerService = new VertxRLPxService(
- vertx,
- LoggerProvider.nullProvider(),
- 0,
- "localhost",
- 10000,
- peerPair,
- new ArrayList<>(),
- "abc");
+ VertxRLPxService peerService =
+ new VertxRLPxService(vertx, 0, "localhost", 10000, peerPair, new
ArrayList<>(), "abc");
peerService.start().join();
try {
@@ -195,25 +120,14 @@ class VertxRLPxServiceTest {
SECP256K1.KeyPair ourPair = SECP256K1.KeyPair.random();
SECP256K1.KeyPair peerPair = SECP256K1.KeyPair.random();
- LoggerProvider logProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err,
UTF_8))));
-
MemoryWireConnectionsRepository repository = new
MemoryWireConnectionsRepository();
VertxRLPxService service =
- new VertxRLPxService(vertx, logProvider, 0, "localhost", 10000,
ourPair, new ArrayList<>(), "abc", repository);
+ new VertxRLPxService(vertx, 0, "localhost", 10000, ourPair, new
ArrayList<>(), "abc", repository);
service.start().join();
MemoryWireConnectionsRepository peerRepository = new
MemoryWireConnectionsRepository();
- VertxRLPxService peerService = new VertxRLPxService(
- vertx,
- logProvider,
- 0,
- "localhost",
- 10000,
- peerPair,
- new ArrayList<>(),
- "abc",
- peerRepository);
+ VertxRLPxService peerService =
+ new VertxRLPxService(vertx, 0, "localhost", 10000, peerPair, new
ArrayList<>(), "abc", peerRepository);
peerService.start().join();
try {
diff --git
a/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/DefaultWireConnectionTest.java
b/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/DefaultWireConnectionTest.java
index 0e0617a..256d279 100644
---
a/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/DefaultWireConnectionTest.java
+++
b/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/DefaultWireConnectionTest.java
@@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.LoggerProvider;
@ExtendWith(BouncyCastleExtension.class)
class DefaultWireConnectionTest {
@@ -36,20 +35,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfNoHelloExchanged() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 3,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 3, "abc", 10000);
conn.messageReceived(new RLPxMessage(45, Bytes.EMPTY));
assertEquals(1, capturedDisconnect.get().messageId());
@@ -61,20 +50,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfNoHelloReceived() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 4,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 4, "abc", 10000);
conn.sendHello();
conn.messageReceived(new RLPxMessage(45, Bytes.EMPTY));
assertEquals(1, capturedDisconnect.get().messageId());
@@ -86,20 +65,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfNoMapping() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 28,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 28, "abc", 10000);
conn.sendHello();
conn.messageReceived(
new RLPxMessage(
@@ -115,20 +84,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfNoNodeID() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 32,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 32, "abc", 10000);
conn.sendHello();
conn.messageReceived(
new RLPxMessage(0, HelloMessage.create(Bytes.EMPTY, 30303, 4, "blah",
Collections.emptyList()).toBytes()));
@@ -142,20 +101,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfNodeIDMismatches() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 32,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 32, "abc", 10000);
conn.sendHello();
conn.messageReceived(
new RLPxMessage(
@@ -171,20 +120,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfConnectedToSelf() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- nodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 33,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, nodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 33, "abc", 10000);
conn.sendHello();
conn.messageReceived(
new RLPxMessage(0, HelloMessage.create(nodeId, 30303, 1, "blah",
Collections.emptyList()).toBytes()));
@@ -198,20 +137,10 @@ class DefaultWireConnectionTest {
@Test
void disconnectIfInvalidP2PConnection() {
AtomicReference<RLPxMessage> capturedDisconnect = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedDisconnect::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 5,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedDisconnect::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 5, "abc", 10000);
conn.sendHello();
conn.messageReceived(
new RLPxMessage(0, HelloMessage.create(peerNodeId, 30303, 6, "blah",
Collections.emptyList()).toBytes()));
diff --git a/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/PingPongTest.java
b/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/PingPongTest.java
index fc9a3d0..4769873 100644
--- a/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/PingPongTest.java
+++ b/rlpx/src/test/java/org/apache/tuweni/rlpx/wire/PingPongTest.java
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.LoggerProvider;
@ExtendWith(BouncyCastleExtension.class)
class PingPongTest {
@@ -43,7 +42,6 @@ class PingPongTest {
"abc",
nodeId,
peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
capturedPing::set,
helloMessage -> {
@@ -66,20 +64,10 @@ class PingPongTest {
@Test
void pongPingRoundtrip() {
AtomicReference<RLPxMessage> capturedPong = new AtomicReference<>();
- DefaultWireConnection conn = new DefaultWireConnection(
- "abc",
- nodeId,
- peerNodeId,
- LoggerProvider.nullProvider().getLogger("rlpx"),
- capturedPong::set,
- helloMessage -> {
- },
- () -> {
- },
- new LinkedHashMap<>(),
- 1,
- "abc",
- 10000);
+ DefaultWireConnection conn =
+ new DefaultWireConnection("abc", nodeId, peerNodeId,
capturedPong::set, helloMessage -> {
+ }, () -> {
+ }, new LinkedHashMap<>(), 1, "abc", 10000);
conn.messageReceived(new RLPxMessage(2, Bytes.EMPTY));
assertNotNull(capturedPong.get());
diff --git a/scuttlebutt-client-lib/build.gradle
b/scuttlebutt-client-lib/build.gradle
index 9ee66a5..c63a60b 100644
--- a/scuttlebutt-client-lib/build.gradle
+++ b/scuttlebutt-client-lib/build.gradle
@@ -17,10 +17,7 @@ dependencies {
compile project(":scuttlebutt-handshake")
compileOnly 'io.vertx:vertx-core'
compile 'io.vertx:vertx-core'
-
- compile 'org.logl:logl-api'
- compile 'org.logl:logl-logl'
- compile 'org.logl:logl-vertx'
+ compile 'org.slf4j:slf4j-api'
testCompile project(':junit')
testCompile 'org.junit.jupiter:junit-jupiter-api'
diff --git
a/scuttlebutt-client-lib/src/main/java/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.java
b/scuttlebutt-client-lib/src/main/java/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.java
index 2baecd6..ba3f138 100644
---
a/scuttlebutt-client-lib/src/main/java/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.java
+++
b/scuttlebutt-client-lib/src/main/java/org/apache/tuweni/scuttlebutt/lib/ScuttlebuttClientFactory.java
@@ -12,7 +12,6 @@
*/
package org.apache.tuweni.scuttlebutt.lib;
-import static java.nio.charset.StandardCharsets.UTF_8;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
@@ -22,16 +21,10 @@ import org.apache.tuweni.io.Base64;
import
org.apache.tuweni.scuttlebutt.handshake.vertx.SecureScuttlebuttVertxClient;
import org.apache.tuweni.scuttlebutt.rpc.mux.RPCHandler;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.function.Consumer;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Vertx;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
/**
* A factory for constructing a new instance of ScuttlebuttClient with the
given configuration parameters
@@ -85,10 +78,8 @@ public final class ScuttlebuttClientFactory {
String host,
int port,
Signature.KeyPair keyPair) {
- LoggerProvider loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out,
UTF_8))));
- return fromNetWithNetworkKey(vertx, host, port, keyPair, DEFAULT_NETWORK,
mapper, loggerProvider);
+ return fromNetWithNetworkKey(vertx, host, port, keyPair, DEFAULT_NETWORK,
mapper);
}
/**
@@ -98,7 +89,6 @@ public final class ScuttlebuttClientFactory {
* @param keyPair The keys to use for the secret handshake
* @param networkIdentifier The scuttlebutt network key to use.
* @param objectMapper The ObjectMapper for serializing the content of
published scuttlebutt messages
- * @param loggerProvider the logging configuration provider
* @return the scuttlebutt client
*/
public static AsyncResult<ScuttlebuttClient> fromNetWithNetworkKey(
@@ -107,11 +97,10 @@ public final class ScuttlebuttClientFactory {
int port,
Signature.KeyPair keyPair,
Bytes32 networkIdentifier,
- ObjectMapper objectMapper,
- LoggerProvider loggerProvider) {
+ ObjectMapper objectMapper) {
SecureScuttlebuttVertxClient secureScuttlebuttVertxClient =
- new SecureScuttlebuttVertxClient(loggerProvider, vertx, keyPair,
networkIdentifier);
+ new SecureScuttlebuttVertxClient(vertx, keyPair, networkIdentifier);
return secureScuttlebuttVertxClient
.connectTo(
@@ -120,7 +109,7 @@ public final class ScuttlebuttClientFactory {
keyPair.publicKey(),
(
Consumer<Bytes> sender,
- Runnable terminationFn) -> new RPCHandler(vertx, sender,
terminationFn, objectMapper, loggerProvider))
+ Runnable terminationFn) -> new RPCHandler(vertx, sender,
terminationFn, objectMapper))
.thenApply(handler -> new ScuttlebuttClient(handler, objectMapper));
}
diff --git a/scuttlebutt-discovery/build.gradle
b/scuttlebutt-discovery/build.gradle
index 256963a..69326f9 100644
--- a/scuttlebutt-discovery/build.gradle
+++ b/scuttlebutt-discovery/build.gradle
@@ -18,14 +18,13 @@ dependencies {
compile project(':crypto')
compile project(':scuttlebutt')
compile 'io.vertx:vertx-core'
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
testCompile project(':junit')
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
- testCompile 'org.logl:logl-logl'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git
a/scuttlebutt-discovery/src/main/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.java
b/scuttlebutt-discovery/src/main/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.java
index 0a696cb..137594e 100644
---
a/scuttlebutt-discovery/src/main/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.java
+++
b/scuttlebutt-discovery/src/main/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryService.java
@@ -26,7 +26,8 @@ import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.datagram.DatagramPacket;
import io.vertx.core.datagram.DatagramSocket;
-import org.logl.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Scuttlebutt local discovery service, based on the Scuttlebutt network
protocol defined
@@ -42,10 +43,10 @@ import org.logl.Logger;
*
*/
public class ScuttlebuttLocalDiscoveryService {
+ private final static Logger logger =
LoggerFactory.getLogger(ScuttlebuttLocalDiscoveryService.class);
private final AtomicBoolean started = new AtomicBoolean(false);
private final Vertx vertx;
- private final Logger logger;
private final List<Consumer<LocalIdentity>> listeners = new ArrayList<>();
private final List<LocalIdentity> identities = new ArrayList<>();
private final int listenPort;
@@ -60,24 +61,21 @@ public class ScuttlebuttLocalDiscoveryService {
* Default constructor.
*
* @param vertx Vert.x instance used to create the UDP socket
- * @param logger the logger used to log events and errors
* @param listenPort the port to bind the UDP socket to
* @param listenNetworkInterface the network interface to bind the UDP
socket to
* @param multicastAddress the address to broadcast multicast packets to
*/
public ScuttlebuttLocalDiscoveryService(
Vertx vertx,
- Logger logger,
int listenPort,
String listenNetworkInterface,
String multicastAddress) {
- this(vertx, logger, listenPort, listenPort, listenNetworkInterface,
multicastAddress, true);
+ this(vertx, listenPort, listenPort, listenNetworkInterface,
multicastAddress, true);
}
ScuttlebuttLocalDiscoveryService(
Vertx vertx,
- Logger logger,
int listenPort,
int broadcastPort,
String listenNetworkInterface,
@@ -90,7 +88,6 @@ public class ScuttlebuttLocalDiscoveryService {
}
}
this.vertx = vertx;
- this.logger = logger;
this.listenPort = listenPort;
this.broadcastPort = broadcastPort;
this.listenNetworkInterface = listenNetworkInterface;
diff --git
a/scuttlebutt-discovery/src/test/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.java
b/scuttlebutt-discovery/src/test/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.java
index e399cfb..6b8c1ed 100644
---
a/scuttlebutt-discovery/src/test/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.java
+++
b/scuttlebutt-discovery/src/test/java/org/apache/tuweni/scuttlebutt/discovery/ScuttlebuttLocalDiscoveryServiceTest.java
@@ -12,7 +12,6 @@
*/
package org.apache.tuweni.scuttlebutt.discovery;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -24,18 +23,12 @@ import org.apache.tuweni.junit.VertxExtension;
import org.apache.tuweni.junit.VertxInstance;
import org.apache.tuweni.scuttlebutt.Identity;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.concurrent.atomic.AtomicReference;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
@ExtendWith(VertxExtension.class)
class ScuttlebuttLocalDiscoveryServiceTest {
@@ -47,24 +40,14 @@ class ScuttlebuttLocalDiscoveryServiceTest {
@Test
void startStop(@VertxInstance Vertx vertx) throws Exception {
- ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(
- vertx,
- LoggerProvider.nullProvider().getLogger("test"),
- 0,
- "0.0.0.0",
- "233.0.10.0");
+ ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(vertx, 0, "0.0.0.0", "233.0.10.0");
service.start().join();
service.stop().join();
}
@Test
void startStart(@VertxInstance Vertx vertx) throws Exception {
- ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(
- vertx,
- LoggerProvider.nullProvider().getLogger("test"),
- 0,
- "0.0.0.0",
- "233.0.10.0");
+ ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(vertx, 0, "0.0.0.0", "233.0.10.0");
service.start().join();
service.start().join();
service.stop().join();
@@ -74,22 +57,12 @@ class ScuttlebuttLocalDiscoveryServiceTest {
void invalidMulticastAddress(@VertxInstance Vertx vertx) throws Exception {
assertThrows(
IllegalArgumentException.class,
- () -> new ScuttlebuttLocalDiscoveryService(
- vertx,
- LoggerProvider.nullProvider().getLogger("test"),
- 8008,
- "0.0.0.0",
- "10.0.0.0"));
+ () -> new ScuttlebuttLocalDiscoveryService(vertx, 8008, "0.0.0.0",
"10.0.0.0"));
}
@Test
void stopFirst(@VertxInstance Vertx vertx) throws Exception {
- ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(
- vertx,
- LoggerProvider.nullProvider().getLogger("test"),
- 0,
- "0.0.0.0",
- "233.0.10.0");
+ ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(vertx, 0, "0.0.0.0", "233.0.10.0");
service.stop().join();
service.start().join();
service.stop().join();
@@ -97,24 +70,10 @@ class ScuttlebuttLocalDiscoveryServiceTest {
@Test
void broadcastAndListen(@VertxInstance Vertx vertx) throws Exception {
- LoggerProvider loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err,
UTF_8))));
- ScuttlebuttLocalDiscoveryService service = new
ScuttlebuttLocalDiscoveryService(
- vertx,
- loggerProvider.getLogger("test"),
- 18008,
- 18009,
- "127.0.0.1",
- "127.0.0.1",
- false);
- ScuttlebuttLocalDiscoveryService service2 = new
ScuttlebuttLocalDiscoveryService(
- vertx,
- loggerProvider.getLogger("test2"),
- 18009,
- 18008,
- "127.0.0.1",
- "127.0.0.1",
- false);
+ ScuttlebuttLocalDiscoveryService service =
+ new ScuttlebuttLocalDiscoveryService(vertx, 18008, 18009, "127.0.0.1",
"127.0.0.1", false);
+ ScuttlebuttLocalDiscoveryService service2 =
+ new ScuttlebuttLocalDiscoveryService(vertx, 18009, 18008, "127.0.0.1",
"127.0.0.1", false);
try {
service2.start().join();
diff --git a/scuttlebutt-handshake/build.gradle
b/scuttlebutt-handshake/build.gradle
index d3bf9af..1a7622f 100644
--- a/scuttlebutt-handshake/build.gradle
+++ b/scuttlebutt-handshake/build.gradle
@@ -17,8 +17,8 @@ dependencies {
compile project(':concurrent')
compile project(':crypto')
compile project(':scuttlebutt')
+ compile 'org.slf4j:slf4j-api'
compileOnly 'io.vertx:vertx-core'
- compile 'org.logl:logl-api'
testCompile project(':junit')
@@ -27,8 +27,6 @@ dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-params'
testCompile 'io.vertx:vertx-core'
- testCompile 'org.logl:logl-logl'
- testCompile 'org.logl:logl-vertx'
testCompile project(':scuttlebutt-rpc')
diff --git
a/scuttlebutt-handshake/src/main/java/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.java
b/scuttlebutt-handshake/src/main/java/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.java
index 1a56665..1464630 100644
---
a/scuttlebutt-handshake/src/main/java/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.java
+++
b/scuttlebutt-handshake/src/main/java/org/apache/tuweni/scuttlebutt/handshake/vertx/SecureScuttlebuttVertxClient.java
@@ -30,8 +30,8 @@ import io.vertx.core.buffer.Buffer;
import io.vertx.core.net.NetClient;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetSocket;
-import org.logl.Logger;
-import org.logl.LoggerProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Secure Scuttlebutt client using Vert.x to manage persistent TCP connections.
@@ -39,9 +39,10 @@ import org.logl.LoggerProvider;
*/
public final class SecureScuttlebuttVertxClient {
+ private static final Logger logger =
LoggerFactory.getLogger(NetSocketClientHandler.class);
+
private class NetSocketClientHandler<T extends ClientHandler> {
- private final Logger logger;
private final NetSocket socket;
private final SecureScuttlebuttHandshakeClient handshakeClient;
private final ClientHandlerFactory<T> handlerFactory;
@@ -53,12 +54,10 @@ public final class SecureScuttlebuttVertxClient {
private Bytes messageBuffer = Bytes.EMPTY;
NetSocketClientHandler(
- Logger logger,
NetSocket socket,
Signature.PublicKey remotePublicKey,
ClientHandlerFactory<T> handlerFactory,
CompletableAsyncResult<T> completionHandle) {
- this.logger = logger;
this.socket = socket;
this.handshakeClient = SecureScuttlebuttHandshakeClient.create(keyPair,
networkIdentifier, remotePublicKey);
this.handlerFactory = handlerFactory;
@@ -149,7 +148,6 @@ public final class SecureScuttlebuttVertxClient {
return size.toInt();
}
- private final LoggerProvider loggerProvider;
private final Vertx vertx;
private final Signature.KeyPair keyPair;
private final Bytes32 networkIdentifier;
@@ -158,17 +156,11 @@ public final class SecureScuttlebuttVertxClient {
/**
* Default constructor.
*
- * @param loggerProvider the LoggerProvider
* @param vertx the Vert.x instance
* @param keyPair the identity of the server according to the Secure
Scuttlebutt protocol
* @param networkIdentifier the network identifier of the server according
to the Secure Scuttlebutt protocol
*/
- public SecureScuttlebuttVertxClient(
- LoggerProvider loggerProvider,
- Vertx vertx,
- Signature.KeyPair keyPair,
- Bytes32 networkIdentifier) {
- this.loggerProvider = loggerProvider;
+ public SecureScuttlebuttVertxClient(Vertx vertx, Signature.KeyPair keyPair,
Bytes32 networkIdentifier) {
this.vertx = vertx;
this.keyPair = keyPair;
this.networkIdentifier = networkIdentifier;
@@ -195,12 +187,7 @@ public final class SecureScuttlebuttVertxClient {
completion.completeExceptionally(res.cause());
} else {
NetSocket socket = res.result();
- new NetSocketClientHandler<T>(
- loggerProvider.getLogger(host + ":" + port),
- socket,
- remotePublicKey,
- handlerFactory,
- completion);
+ new NetSocketClientHandler<T>(socket, remotePublicKey, handlerFactory,
completion);
}
});
diff --git
a/scuttlebutt-handshake/src/test/java/org/apache/tuweni/scuttlebutt/handshake/vertx/VertxIntegrationTest.java
b/scuttlebutt-handshake/src/test/java/org/apache/tuweni/scuttlebutt/handshake/vertx/VertxIntegrationTest.java
index 6b32dcb..6e39a67 100644
---
a/scuttlebutt-handshake/src/test/java/org/apache/tuweni/scuttlebutt/handshake/vertx/VertxIntegrationTest.java
+++
b/scuttlebutt-handshake/src/test/java/org/apache/tuweni/scuttlebutt/handshake/vertx/VertxIntegrationTest.java
@@ -12,7 +12,6 @@
*/
package org.apache.tuweni.scuttlebutt.handshake.vertx;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -27,9 +26,6 @@ import org.apache.tuweni.junit.VertxInstance;
import org.apache.tuweni.scuttlebutt.rpc.RPCCodec;
import org.apache.tuweni.scuttlebutt.rpc.RPCFlag;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@@ -38,10 +34,6 @@ import io.vertx.core.Vertx;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
-import org.logl.vertx.LoglLogDelegateFactory;
@ExtendWith(VertxExtension.class)
@@ -100,9 +92,6 @@ class VertxIntegrationTest {
@Test
void connectToServer(@VertxInstance Vertx vertx) throws Exception {
- LoggerProvider provider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out,
UTF_8))));
- LoglLogDelegateFactory.setProvider(provider);
Signature.KeyPair serverKeyPair = Signature.KeyPair.random();
Bytes32 networkIdentifier = Bytes32.random();
AtomicReference<MyServerHandler> serverHandlerRef = new
AtomicReference<>();
@@ -119,7 +108,7 @@ class VertxIntegrationTest {
server.start().join();
SecureScuttlebuttVertxClient client =
- new SecureScuttlebuttVertxClient(provider, vertx,
Signature.KeyPair.random(), networkIdentifier);
+ new SecureScuttlebuttVertxClient(vertx, Signature.KeyPair.random(),
networkIdentifier);
MyClientHandler handler = client.connectTo(20000, "0.0.0.0",
serverKeyPair.publicKey(), MyClientHandler::new).get();
Thread.sleep(1000);
diff --git a/scuttlebutt-rpc/build.gradle b/scuttlebutt-rpc/build.gradle
index 0bd4356..8adceaa 100644
--- a/scuttlebutt-rpc/build.gradle
+++ b/scuttlebutt-rpc/build.gradle
@@ -19,7 +19,7 @@ dependencies {
compileOnly 'io.vertx:vertx-core'
compile project(':scuttlebutt')
compile project(':scuttlebutt-handshake')
- compile 'org.logl:logl-api'
+ compile 'org.slf4j:slf4j-api'
compile 'com.fasterxml.jackson.core:jackson-databind'
@@ -31,8 +31,5 @@ dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-params'
testCompile 'io.vertx:vertx-core'
- testCompile 'org.logl:logl-logl'
- testCompile 'org.logl:logl-vertx'
-
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
}
diff --git
a/scuttlebutt-rpc/src/main/java/org/apache/tuweni/scuttlebutt/rpc/mux/RPCHandler.java
b/scuttlebutt-rpc/src/main/java/org/apache/tuweni/scuttlebutt/rpc/mux/RPCHandler.java
index eb3fadc..a0b7746 100644
---
a/scuttlebutt-rpc/src/main/java/org/apache/tuweni/scuttlebutt/rpc/mux/RPCHandler.java
+++
b/scuttlebutt-rpc/src/main/java/org/apache/tuweni/scuttlebutt/rpc/mux/RPCHandler.java
@@ -35,16 +35,16 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
-import org.logl.Logger;
-import org.logl.LoggerProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles RPC requests and responses from an active connection to a
scuttlebutt node.
*/
public class RPCHandler implements Multiplexer, ClientHandler {
+ private final static Logger logger =
LoggerFactory.getLogger(RPCHandler.class);
private final Consumer<Bytes> messageSender;
- private final Logger logger;
private final Runnable connectionCloser;
private final ObjectMapper objectMapper;
@@ -66,21 +66,14 @@ public class RPCHandler implements Multiplexer,
ClientHandler {
* @param messageSender sends the request to the node
* @param terminationFn closes the connection
* @param objectMapper the objectMapper to serialize and deserialize message
request and response bodies
- * @param logger
*/
- public RPCHandler(
- Vertx vertx,
- Consumer<Bytes> messageSender,
- Runnable terminationFn,
- ObjectMapper objectMapper,
- LoggerProvider logger) {
+ public RPCHandler(Vertx vertx, Consumer<Bytes> messageSender, Runnable
terminationFn, ObjectMapper objectMapper) {
this.vertx = vertx;
this.messageSender = messageSender;
this.connectionCloser = terminationFn;
this.closed = false;
this.objectMapper = objectMapper;
- this.logger = logger.getLogger("rpc handler");
}
@Override
@@ -153,7 +146,7 @@ public class RPCHandler implements Multiplexer,
ClientHandler {
private void logOutgoingRequest(RPCMessage rpcMessage) {
if (logger.isDebugEnabled()) {
- String requestString = new String(rpcMessage.asString());
+ String requestString = rpcMessage.asString();
String logMessage = String.format("[%d] Outgoing request: %s",
rpcMessage.requestNumber(), requestString);
logger.debug(logMessage);
}
diff --git
a/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/PatchworkIntegrationTest.java
b/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/PatchworkIntegrationTest.java
index 9d8527d..e58ee6b 100644
---
a/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/PatchworkIntegrationTest.java
+++
b/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/PatchworkIntegrationTest.java
@@ -27,10 +27,7 @@ import org.apache.tuweni.junit.VertxInstance;
import org.apache.tuweni.scuttlebutt.handshake.vertx.ClientHandler;
import
org.apache.tuweni.scuttlebutt.handshake.vertx.SecureScuttlebuttVertxClient;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -44,10 +41,6 @@ import io.vertx.core.Vertx;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
-import org.logl.vertx.LoglLogDelegateFactory;
/**
* Test used with a local installation of Patchwork on the developer machine.
@@ -99,9 +92,6 @@ class PatchworkIntegrationTest {
void runWithPatchWork(@VertxInstance Vertx vertx) throws Exception {
String host = "localhost";
int port = 8008;
- LoggerProvider loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out,
UTF_8))));
- LoglLogDelegateFactory.setProvider(loggerProvider);
Optional<String> ssbDir =
Optional.fromNullable(System.getenv().get("ssb_dir"));
Optional<String> homePath =
@@ -156,7 +146,7 @@ class PatchworkIntegrationTest {
Bytes32 networkKeyBytes32 = Bytes32.wrap(Base64.decode(networkKeyBase64));
SecureScuttlebuttVertxClient secureScuttlebuttVertxClient =
- new SecureScuttlebuttVertxClient(loggerProvider, vertx, keyPair,
networkKeyBytes32);
+ new SecureScuttlebuttVertxClient(vertx, keyPair, networkKeyBytes32);
AsyncResult<ClientHandler> onConnect =
secureScuttlebuttVertxClient.connectTo(port, host, publicKey,
MyClientHandler::new);
diff --git
a/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/mux/PatchworkIntegrationTest.java
b/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/mux/PatchworkIntegrationTest.java
index e9bed6a..41c892a 100644
---
a/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/mux/PatchworkIntegrationTest.java
+++
b/scuttlebutt-rpc/src/test/java/org/apache/tuweni/scuttlebutt/rpc/mux/PatchworkIntegrationTest.java
@@ -29,10 +29,7 @@ import org.apache.tuweni.scuttlebutt.rpc.RPCFunction;
import org.apache.tuweni.scuttlebutt.rpc.RPCResponse;
import org.apache.tuweni.scuttlebutt.rpc.RPCStreamRequest;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -47,17 +44,10 @@ import io.vertx.core.Vertx;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.logl.Level;
-import org.logl.LoggerProvider;
-import org.logl.logl.SimpleLogger;
-import org.logl.vertx.LoglLogDelegateFactory;
@ExtendWith(VertxExtension.class)
public class PatchworkIntegrationTest {
- LoggerProvider loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out,
UTF_8))));
-
@Test
@Disabled
public void testWithPatchwork(@VertxInstance Vertx vertx) throws Exception {
@@ -198,17 +188,14 @@ public class PatchworkIntegrationTest {
String host = "localhost";
int port = 8008;
- LoggerProvider loggerProvider =
SimpleLogger.withLogLevel(Level.DEBUG).toPrintWriter(
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out,
UTF_8))));
- LoglLogDelegateFactory.setProvider(loggerProvider);
SecureScuttlebuttVertxClient secureScuttlebuttVertxClient =
- new SecureScuttlebuttVertxClient(loggerProvider, vertx, keyPair,
networkKeyBytes32);
+ new SecureScuttlebuttVertxClient(vertx, keyPair, networkKeyBytes32);
AsyncResult<RPCHandler> onConnect =
secureScuttlebuttVertxClient.connectTo(port, host,
keyPair.publicKey(), (sender, terminationFn) -> {
- return new RPCHandler(vertx, sender, terminationFn, new
ObjectMapper(), loggerProvider);
+ return new RPCHandler(vertx, sender, terminationFn, new
ObjectMapper());
});
return onConnect.get();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]