loadtest: Add loadtest code

This commit is contained in:
Andras Slemmer
2016-10-17 17:50:33 +01:00
parent 9078676521
commit 07df9f17b3
27 changed files with 1550 additions and 46 deletions

View File

@ -31,6 +31,7 @@ import java.util.*
import java.util.concurrent.Future
import java.util.concurrent.TimeUnit.SECONDS
import java.util.concurrent.TimeoutException
import java.util.concurrent.atomic.AtomicInteger
/**
* This file defines a small "Driver" DSL for starting up nodes that is only intended for development, demos and tests.
@ -77,8 +78,9 @@ sealed class PortAllocation {
abstract fun nextPort(): Int
fun nextHostAndPort(): HostAndPort = HostAndPort.fromParts("localhost", nextPort())
class Incremental(private var portCounter: Int) : PortAllocation() {
override fun nextPort() = portCounter++
class Incremental(startingPort: Int) : PortAllocation() {
val portCounter = AtomicInteger(startingPort)
override fun nextPort() = portCounter.andIncrement
}
class RandomFree(): PortAllocation() {
override fun nextPort(): Int {

View File

@ -159,4 +159,3 @@ data class ProtocolHandle<A>(
val progress: Observable<ProgressTracker.Change>,
val returnValue: Observable<A>
)

View File

@ -71,7 +71,7 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService) {
fun dispatch(msg: ClientRPCRequestMessage) {
val (argsBytes, replyTo, observationsTo, methodName) = msg
val response: ErrorOr<Any?> = ErrorOr.catch {
val response: ErrorOr<Any> = ErrorOr.catch {
val method = methodTable[methodName] ?: throw RPCException("Received RPC for unknown method $methodName - possible client/server version skew?")
if (method.isAnnotationPresent(RPCReturnsObservables::class.java) && observationsTo == null)
throw RPCException("Received RPC without any destination for observations, but the RPC returns observables")
@ -166,4 +166,4 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService) {
}
return address
}
}
}

View File

@ -3,6 +3,7 @@
package net.corda.node.services.messaging
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.KryoException
import com.esotericsoftware.kryo.Registration
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
@ -13,6 +14,7 @@ import de.javakaffee.kryoserializers.ArraysAsListSerializer
import de.javakaffee.kryoserializers.guava.*
import net.corda.contracts.asset.Cash
import net.corda.core.ErrorOr
import net.corda.core.TransientProperty
import net.corda.core.contracts.*
import net.corda.core.crypto.DigitalSignature
import net.corda.core.crypto.Party
@ -31,11 +33,13 @@ import net.corda.node.services.User
import net.corda.protocols.CashProtocolResult
import net.i2p.crypto.eddsa.EdDSAPrivateKey
import net.i2p.crypto.eddsa.EdDSAPublicKey
import org.apache.activemq.artemis.api.core.SimpleString
import org.objenesis.strategy.StdInstantiatorStrategy
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import rx.Notification
import rx.Observable
import java.security.PublicKey
import java.time.Instant
import java.util.*
@ -198,6 +202,8 @@ private class RPCKryo(observableSerializer: Serializer<Observable<Any>>? = null)
register(ServiceType.parse("ab").javaClass)
register(WorldCoordinate::class.java)
register(HostAndPort::class.java)
register(SimpleString::class.java)
register(ServiceEntry::class.java)
// Exceptions. We don't bother sending the stack traces as the client will fill in its own anyway.
register(IllegalArgumentException::class.java)
// Kryo couldn't serialize Collections.unmodifiableCollection in Throwable correctly, causing null pointer exception when try to access the deserialize object.
@ -207,6 +213,8 @@ private class RPCKryo(observableSerializer: Serializer<Observable<Any>>? = null)
register(Collections.unmodifiableList(emptyList<String>()).javaClass)
register(PermissionException::class.java)
register(ProtocolHandle::class.java)
register(KryoException::class.java)
register(StringBuffer::class.java)
}
// Helper method, attempt to reduce boiler plate code