mirror of
https://github.com/corda/corda.git
synced 2025-06-13 12:48:18 +00:00
Retire HostAndPort (#962)
* Don't attempt to parse a resolved InetSocketAddress toString * A mock node isn't reachable via an address
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
package net.corda.nodeapi
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting
|
||||
import com.google.common.net.HostAndPort
|
||||
import net.corda.core.crypto.toBase58String
|
||||
import net.corda.core.messaging.MessageRecipientGroup
|
||||
import net.corda.core.messaging.MessageRecipients
|
||||
@ -11,6 +9,7 @@ import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.read
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.SingletonSerializeAsToken
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.nodeapi.config.SSLConfiguration
|
||||
import java.security.KeyStore
|
||||
import java.security.PublicKey
|
||||
@ -43,11 +42,11 @@ abstract class ArtemisMessagingComponent : SingletonSerializeAsToken() {
|
||||
}
|
||||
|
||||
interface ArtemisPeerAddress : ArtemisAddress, SingleMessageRecipient {
|
||||
val hostAndPort: HostAndPort
|
||||
val hostAndPort: NetworkHostAndPort
|
||||
}
|
||||
|
||||
@CordaSerializable
|
||||
data class NetworkMapAddress(override val hostAndPort: HostAndPort) : ArtemisPeerAddress {
|
||||
data class NetworkMapAddress(override val hostAndPort: NetworkHostAndPort) : ArtemisPeerAddress {
|
||||
override val queueName: String get() = NETWORK_MAP_QUEUE
|
||||
}
|
||||
|
||||
@ -63,13 +62,13 @@ abstract class ArtemisMessagingComponent : SingletonSerializeAsToken() {
|
||||
* @param hostAndPort The address of the node.
|
||||
*/
|
||||
@CordaSerializable
|
||||
data class NodeAddress(override val queueName: String, override val hostAndPort: HostAndPort) : ArtemisPeerAddress {
|
||||
data class NodeAddress(override val queueName: String, override val hostAndPort: NetworkHostAndPort) : ArtemisPeerAddress {
|
||||
companion object {
|
||||
fun asPeer(peerIdentity: PublicKey, hostAndPort: HostAndPort): NodeAddress {
|
||||
fun asPeer(peerIdentity: PublicKey, hostAndPort: NetworkHostAndPort): NodeAddress {
|
||||
return NodeAddress("$PEERS_PREFIX${peerIdentity.toBase58String()}", hostAndPort)
|
||||
}
|
||||
|
||||
fun asService(serviceIdentity: PublicKey, hostAndPort: HostAndPort): NodeAddress {
|
||||
fun asService(serviceIdentity: PublicKey, hostAndPort: NetworkHostAndPort): NodeAddress {
|
||||
return NodeAddress("$SERVICES_PREFIX${serviceIdentity.toBase58String()}", hostAndPort)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.corda.nodeapi
|
||||
|
||||
import com.google.common.net.HostAndPort
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.nodeapi.config.SSLConfiguration
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory
|
||||
@ -36,7 +36,7 @@ class ArtemisTcpTransport {
|
||||
|
||||
fun tcpTransport(
|
||||
direction: ConnectionDirection,
|
||||
hostAndPort: HostAndPort,
|
||||
hostAndPort: NetworkHostAndPort,
|
||||
config: SSLConfiguration?,
|
||||
enableSSL: Boolean = true
|
||||
): TransportConfiguration {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package net.corda.nodeapi.config
|
||||
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigUtil
|
||||
import net.corda.core.noneOrSingle
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.core.utilities.parseNetworkHostAndPort
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.net.Proxy
|
||||
@ -67,7 +68,7 @@ private fun Config.getSingleValue(path: String, type: KType): Any? {
|
||||
Boolean::class -> getBoolean(path)
|
||||
LocalDate::class -> LocalDate.parse(getString(path))
|
||||
Instant::class -> Instant.parse(getString(path))
|
||||
HostAndPort::class -> HostAndPort.fromString(getString(path))
|
||||
NetworkHostAndPort::class -> getString(path).parseNetworkHostAndPort()
|
||||
Path::class -> Paths.get(getString(path))
|
||||
URL::class -> URL(getString(path))
|
||||
Properties::class -> getConfig(path).toProperties()
|
||||
@ -95,7 +96,7 @@ private fun Config.getCollectionValue(path: String, type: KType): Collection<Any
|
||||
Boolean::class -> getBooleanList(path)
|
||||
LocalDate::class -> getStringList(path).map(LocalDate::parse)
|
||||
Instant::class -> getStringList(path).map(Instant::parse)
|
||||
HostAndPort::class -> getStringList(path).map(HostAndPort::fromString)
|
||||
NetworkHostAndPort::class -> getStringList(path).map { it.parseNetworkHostAndPort() }
|
||||
Path::class -> getStringList(path).map { Paths.get(it) }
|
||||
URL::class -> getStringList(path).map(::URL)
|
||||
X500Name::class -> getStringList(path).map(::X500Name)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.corda.nodeapi.serialization
|
||||
|
||||
import com.esotericsoftware.kryo.KryoException
|
||||
import com.google.common.net.HostAndPort
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
import net.corda.core.serialization.SerializationCustomization
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import org.apache.activemq.artemis.api.core.SimpleString
|
||||
import rx.Notification
|
||||
import rx.exceptions.OnErrorNotImplementedException
|
||||
@ -33,7 +33,7 @@ class DefaultWhitelist : CordaPluginRegistry() {
|
||||
addToWhitelist(listOf(Unit).javaClass) // SingletonList
|
||||
addToWhitelist(setOf(Unit).javaClass) // SingletonSet
|
||||
addToWhitelist(mapOf(Unit to Unit).javaClass) // SingletonSet
|
||||
addToWhitelist(HostAndPort::class.java)
|
||||
addToWhitelist(NetworkHostAndPort::class.java)
|
||||
addToWhitelist(SimpleString::class.java)
|
||||
addToWhitelist(KryoException::class.java)
|
||||
addToWhitelist(StringBuffer::class.java)
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.corda.nodeapi.config
|
||||
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory.empty
|
||||
import com.typesafe.config.ConfigRenderOptions.defaults
|
||||
import com.typesafe.config.ConfigValueFactory
|
||||
import net.corda.core.div
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.testing.getTestX509Name
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
@ -59,10 +59,10 @@ class ConfigParsingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HostAndPort`() {
|
||||
testPropertyType<HostAndPortData, HostAndPortListData, HostAndPort>(
|
||||
HostAndPort.fromParts("localhost", 2223),
|
||||
HostAndPort.fromParts("localhost", 2225),
|
||||
fun `NetworkHostAndPort`() {
|
||||
testPropertyType<NetworkHostAndPortData, NetworkHostAndPortListData, NetworkHostAndPort>(
|
||||
NetworkHostAndPort("localhost", 2223),
|
||||
NetworkHostAndPort("localhost", 2225),
|
||||
valuesToString = true)
|
||||
}
|
||||
|
||||
@ -223,8 +223,8 @@ class ConfigParsingTest {
|
||||
data class LocalDateListData(override val values: List<LocalDate>) : ListData<LocalDate>
|
||||
data class InstantData(override val value: Instant) : SingleData<Instant>
|
||||
data class InstantListData(override val values: List<Instant>) : ListData<Instant>
|
||||
data class HostAndPortData(override val value: HostAndPort) : SingleData<HostAndPort>
|
||||
data class HostAndPortListData(override val values: List<HostAndPort>) : ListData<HostAndPort>
|
||||
data class NetworkHostAndPortData(override val value: NetworkHostAndPort) : SingleData<NetworkHostAndPort>
|
||||
data class NetworkHostAndPortListData(override val values: List<NetworkHostAndPort>) : ListData<NetworkHostAndPort>
|
||||
data class PathData(override val value: Path) : SingleData<Path>
|
||||
data class PathListData(override val values: List<Path>) : ListData<Path>
|
||||
data class URLData(override val value: URL) : SingleData<URL>
|
||||
|
Reference in New Issue
Block a user