Minor: auto-format of module: node

This commit is contained in:
Mike Hearn
2017-04-11 12:42:53 +02:00
parent 3a7bcee15b
commit d6af727751
32 changed files with 130 additions and 111 deletions

View File

@ -9,8 +9,8 @@ import net.corda.core.readLines
import net.corda.node.LOGS_DIRECTORY_NAME
import net.corda.node.services.api.RegulatorService
import net.corda.node.services.transactions.SimpleNotaryService
import org.assertj.core.api.Assertions.assertThat
import net.corda.nodeapi.ArtemisMessagingComponent
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.nio.file.Paths
import java.util.concurrent.Executors

View File

@ -1,4 +1,5 @@
@file:JvmName("Corda")
package net.corda.node
import com.jcabi.manifests.Manifests

View File

@ -1,4 +1,5 @@
@file:JvmName("Driver")
package net.corda.node.driver
import com.google.common.net.HostAndPort
@ -287,6 +288,7 @@ class ShutdownManager(private val executorService: ExecutorService) {
val registeredShutdowns = ArrayList<ListenableFuture<() -> Unit>>()
var isShutdown = false
}
private val state = ThreadBox(State())
fun shutdown() {

View File

@ -199,10 +199,12 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
log.warn("Corda node is running in dev mode.")
configuration.configureWithDevSSLCertificate()
}
require(hasSSLCertificates()) { "Identity certificate not found. " +
require(hasSSLCertificates()) {
"Identity certificate not found. " +
"Please either copy your existing identity key and certificate from another node, " +
"or if you don't have one yet, fill out the config file and run corda.jar --initial-registration. " +
"Read more at: https://docs.corda.net/permissioning.html" }
"Read more at: https://docs.corda.net/permissioning.html"
}
log.info("Node starting up ...")

View File

@ -129,6 +129,7 @@ class CordaRPCOpsImpl(
services.storageService.attachments.importAttachment(jar)
}
}
override fun authoriseContractUpgrade(state: StateAndRef<*>, upgradedContractClass: Class<out UpgradedContract<*, *>>) = services.vaultService.authoriseContractUpgrade(state, upgradedContractClass)
override fun deauthoriseContractUpgrade(state: StateAndRef<*>) = services.vaultService.deauthoriseContractUpgrade(state)
override fun currentNodeTime(): Instant = Instant.now(services.clock)

View File

@ -23,10 +23,9 @@ import net.corda.node.services.config.FullNodeConfiguration
import net.corda.node.services.messaging.ArtemisMessagingServer
import net.corda.node.services.messaging.NodeMessagingClient
import net.corda.node.services.transactions.PersistentUniquenessProvider
import net.corda.node.services.transactions.RaftNonValidatingNotaryService
import net.corda.node.services.transactions.RaftUniquenessProvider
import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.node.services.transactions.RaftNonValidatingNotaryService
import net.corda.node.services.transactions.*
import net.corda.node.utilities.AddressUtils
import net.corda.node.utilities.AffinityExecutor
import net.corda.nodeapi.ArtemisMessagingComponent.NetworkMapAddress

View File

@ -9,7 +9,10 @@ import io.requery.sql.*
import io.requery.sql.platform.H2
import io.requery.util.function.Function
import io.requery.util.function.Supplier
import net.corda.core.schemas.requery.converters.*
import net.corda.core.schemas.requery.converters.InstantConverter
import net.corda.core.schemas.requery.converters.SecureHashConverter
import net.corda.core.schemas.requery.converters.StateRefConverter
import net.corda.core.schemas.requery.converters.VaultStateStatusConverter
import org.jetbrains.exposed.sql.transactions.TransactionManager
import java.sql.Connection
import java.util.*
@ -128,8 +131,7 @@ class KotlinConfigurationTransactionWrapper(private val model: EntityModel,
override fun getConnection(): Connection {
val tx = TransactionManager.manager.currentOrNull()
return CordaConnection(
tx?.connection ?:
TransactionManager.manager.newTransaction(Connection.TRANSACTION_REPEATABLE_READ).connection
tx?.connection ?: TransactionManager.manager.newTransaction(Connection.TRANSACTION_REPEATABLE_READ).connection
)
}
}

View File

@ -4,7 +4,9 @@ import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import io.requery.Persistable
import io.requery.meta.EntityModel
import io.requery.sql.*
import io.requery.sql.KotlinEntityDataStore
import io.requery.sql.SchemaModifier
import io.requery.sql.TableCreationMode
import net.corda.core.utilities.loggerFor
import org.jetbrains.exposed.sql.transactions.TransactionManager
import java.sql.Connection

View File

@ -104,6 +104,7 @@ class NodeMessagingClient(override val config: NodeConfiguration,
var rpcNotificationConsumer: ClientConsumer? = null
var verificationResponseConsumer: ClientConsumer? = null
}
val verifierService = when (config.verifierType) {
VerifierType.InMemory -> InMemoryTransactionVerifierService(numberOfWorkers = 4)
VerifierType.OutOfProcess -> createOutOfProcessVerifierService()
@ -421,8 +422,10 @@ class NodeMessagingClient(override val config: NodeConfiguration,
putLongProperty(HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + amqDelay)
}
}
log.trace { "Send to: $mqAddress topic: ${message.topicSession.topic} " +
"sessionID: ${message.topicSession.sessionID} uuid: ${message.uniqueMessageId}" }
log.trace {
"Send to: $mqAddress topic: ${message.topicSession.topic} " +
"sessionID: ${message.topicSession.sessionID} uuid: ${message.uniqueMessageId}"
}
producer!!.send(mqAddress, artemisMessage)
}
}

View File

@ -70,7 +70,9 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
// representing what happened, which is useful for us to send over the wire.
val subscription = obj.materialize().subscribe { materialised: Notification<out Any> ->
val newKryo = createRPCKryoForSerialization(qName, dispatcher)
val bits = try { MarshalledObservation(handle, materialised).serialize(newKryo) } finally {
val bits = try {
MarshalledObservation(handle, materialised).serialize(newKryo)
} finally {
releaseRPCKryoForSerialization(newKryo)
}
rpcLog.debug("RPC sending observation: $materialised")
@ -91,7 +93,9 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
throw RPCException("Received RPC without any destination for observations, but the RPC returns observables")
val kryo = createRPCKryoForSerialization(observationsTo, this)
val args = try { argsBytes.deserialize(kryo) } finally {
val args = try {
argsBytes.deserialize(kryo)
} finally {
releaseRPCKryoForSerialization(kryo)
}
@ -173,6 +177,7 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
// TODO remove this User once webserver doesn't need it
private val nodeUser = User(NODE_USER, NODE_USER, setOf())
@VisibleForTesting
protected open fun getUser(message: ClientMessage): User {
val validatedUser = message.requiredString(Message.HDR_VALIDATED_USER.toString())

View File

@ -10,8 +10,7 @@ class FlowSession(
val flow: FlowLogic<*>,
val ourSessionId: Long,
val initiatingParty: Party?,
var state: FlowSessionState)
{
var state: FlowSessionState) {
val receivedMessages = ConcurrentLinkedQueue<ReceivedSessionMessage<*>>()
val fiber: FlowStateMachineImpl<*> get() = flow.stateMachine as FlowStateMachineImpl<*>

View File

@ -26,6 +26,7 @@ interface SessionInitResponse : ExistingSessionMessage {
val initiatorSessionId: Long
override val recipientSessionId: Long get() = initiatorSessionId
}
data class SessionConfirm(override val initiatorSessionId: Long, val initiatedSessionId: Long) : SessionInitResponse
data class SessionReject(override val initiatorSessionId: Long, val errorMessage: String) : SessionInitResponse

View File

@ -5,7 +5,6 @@ import co.paralleluniverse.fibers.FiberExecutorScheduler
import co.paralleluniverse.io.serialization.kryo.KryoSerializer
import co.paralleluniverse.strands.Strand
import com.codahale.metrics.Gauge
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.pool.KryoPool
import com.google.common.collect.HashMultimap
import com.google.common.util.concurrent.ListenableFuture
@ -79,6 +78,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
companion object {
private val logger = loggerFor<StateMachineManager>()
internal val sessionTopic = TopicSession("platform.session")
init {
Fiber.setDefaultUncaughtExceptionHandler { fiber, throwable ->
(fiber as FlowStateMachineImpl<*>).logger.error("Caught exception from flow", throwable)
@ -107,6 +107,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
changesPublisher.bufferUntilDatabaseCommit().onNext(Change(fiber.logic, addOrRemove, fiber.id))
}
}
private val mutex = ThreadBox(InnerState())
// True if we're shutting down, so don't resume anything.

View File

@ -9,7 +9,6 @@ import net.corda.core.node.services.TransactionVerifierService
import net.corda.core.random63BitValue
import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.utilities.debug
import net.corda.core.utilities.loggerFor
import net.corda.node.services.api.MonitoringService
import net.corda.nodeapi.VerifierApi
@ -22,15 +21,18 @@ abstract class OutOfProcessTransactionVerifierService(
companion object {
val log = loggerFor<OutOfProcessTransactionVerifierService>()
}
private data class VerificationHandle(
val transactionId: SecureHash,
val resultFuture: SettableFuture<Unit>,
val durationTimerContext: Timer.Context
)
private val verificationHandles = ConcurrentHashMap<Long, VerificationHandle>()
// Metrics
private fun metric(name: String) = "OutOfProcessTransactionVerifierService.$name"
private val durationTimer = monitoringService.metrics.timer(metric("Verification.Duration"))
private val successMeter = monitoringService.metrics.meter(metric("Verification.Success"))
private val failureMeter = monitoringService.metrics.meter(metric("Verification.Failure"))

View File

@ -13,7 +13,10 @@ import net.corda.contracts.asset.Cash
import net.corda.core.ThreadBox
import net.corda.core.bufferUntilSubscribed
import net.corda.core.contracts.*
import net.corda.core.crypto.*
import net.corda.core.crypto.AbstractParty
import net.corda.core.crypto.CompositeKey
import net.corda.core.crypto.Party
import net.corda.core.crypto.SecureHash
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.StatesNotAvailableException
import net.corda.core.node.services.Vault
@ -292,8 +295,7 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
log.trace("Releasing ${update.value()} soft locked states for $lockId")
}
}
}
else if (stateRefs.isNotEmpty()) {
} else if (stateRefs.isNotEmpty()) {
try {
session.withTransaction(TransactionIsolation.REPEATABLE_READ) {
val updatedRows = update(VaultStatesEntity::class)

View File

@ -1,4 +1,5 @@
package net.corda.node.services.vault
import net.corda.core.contracts.StateRef
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StateMachineRunId

View File

@ -1,11 +1,13 @@
package net.corda.node.utilities
import com.google.common.util.concurrent.ListeningScheduledExecutorService
import com.google.common.util.concurrent.SettableFuture
import com.google.common.util.concurrent.Uninterruptibles
import net.corda.core.utilities.loggerFor
import java.util.*
import java.util.concurrent.*
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executor
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ScheduledThreadPoolExecutor
import java.util.function.Supplier
/**

View File

@ -261,6 +261,7 @@ fun <T : Any> rx.Observable<T>.wrapWithDatabaseTransaction(db: Database? = null)
// Composite columns for use with below Exposed helpers.
data class PartyColumns(val name: Column<String>, val owningKey: Column<CompositeKey>)
data class StateRefColumns(val txId: Column<SecureHash>, val index: Column<Int>)
data class TxnNoteColumns(val txId: Column<SecureHash>, val note: Column<String>)

View File

@ -28,6 +28,7 @@ class InteractiveShellTest {
constructor(amount: Amount<Currency>) : this(amount.toString())
constructor(pair: Pair<Amount<Currency>, SecureHash.SHA256>) : this(pair.toString())
constructor(party: Party) : this(party.name)
override fun call() = a
}

View File

@ -14,8 +14,8 @@ import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.persistence.NodeAttachmentService
import net.corda.node.services.persistence.schemas.AttachmentEntity
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.node.MockNetwork
import net.corda.node.utilities.databaseTransaction
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.makeTestDataSourceProperties
import org.jetbrains.exposed.sql.Database
import org.junit.Before

View File

@ -256,6 +256,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
data class Added(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info)
}
data class Removed(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info)
}

View File

@ -4,7 +4,10 @@ import net.corda.core.crypto.Party
import net.corda.core.crypto.composite
import net.corda.core.crypto.generateKeyPair
import net.corda.node.services.identity.InMemoryIdentityService
import net.corda.testing.*
import net.corda.testing.ALICE
import net.corda.testing.ALICE_PUBKEY
import net.corda.testing.BOB
import net.corda.testing.BOB_PUBKEY
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull

View File

@ -8,7 +8,6 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryChangeFlow.Instigator
import net.corda.flows.StateReplacementException
import net.corda.node.internal.AbstractNode

View File

@ -11,14 +11,12 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryError
import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow
import net.corda.node.internal.AbstractNode
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.MINI_CORP_KEY
import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before

View File

@ -8,7 +8,6 @@ import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryError
import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow
@ -16,7 +15,6 @@ import net.corda.node.internal.AbstractNode
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.ValidatingNotaryService
import net.corda.testing.MEGA_CORP_KEY
import net.corda.testing.MINI_CORP_KEY
import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before

View File

@ -14,9 +14,6 @@ import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.core.utilities.LogHelper
import net.corda.node.services.schema.HibernateObserver
import net.corda.node.services.schema.NodeSchemaService
import net.corda.node.services.vault.NodeVaultService
import net.corda.node.utilities.configureDatabase
import net.corda.node.utilities.databaseTransaction
import net.corda.testing.BOB_KEY
@ -173,8 +170,7 @@ class VaultWithCashTest {
LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()}
""")
txn1
}
catch(e: Exception) {
} catch(e: Exception) {
println(e)
}
}
@ -206,8 +202,7 @@ class VaultWithCashTest {
LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()}
""")
txn2
}
catch(e: Exception) {
} catch(e: Exception) {
println(e)
}
}

View File

@ -15,7 +15,6 @@ import net.corda.core.utilities.LogHelper
import net.corda.node.services.RPCUserService
import net.corda.node.services.RPCUserServiceImpl
import net.corda.node.services.api.MonitoringService
import net.corda.node.services.config.FullNodeConfiguration
import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.config.configureWithDevSSLCertificate
import net.corda.node.services.network.InMemoryNetworkMapCache

View File

@ -5,7 +5,6 @@ import org.junit.Test
import java.util.*
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicReference
import kotlin.concurrent.thread
import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertNotEquals