mirror of
https://github.com/corda/corda.git
synced 2025-05-29 21:54:26 +00:00
Merge remote-tracking branch 'open-source/master' into thomas/os-merge-2018-08-07
This commit is contained in:
commit
44a4742c1b
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@ -5,4 +5,4 @@ When reporting an issue please make sure it contains;
|
|||||||
* A clear description of the issue
|
* A clear description of the issue
|
||||||
* Any logs or stack traces that you can provide (use a site like https://pastebin.com for larger logs)
|
* Any logs or stack traces that you can provide (use a site like https://pastebin.com for larger logs)
|
||||||
* Steps to reproduce the issue
|
* Steps to reproduce the issue
|
||||||
* The version/tag/release or commit hash it occured on
|
* The version/tag/release or commit hash it occurred on
|
||||||
|
@ -35,7 +35,7 @@ import net.corda.node.services.transactions.bftSMaRtSerialFilter
|
|||||||
import net.corda.node.utilities.createKeyPairAndSelfSignedTLSCertificate
|
import net.corda.node.utilities.createKeyPairAndSelfSignedTLSCertificate
|
||||||
import net.corda.node.utilities.registration.HTTPNetworkRegistrationService
|
import net.corda.node.utilities.registration.HTTPNetworkRegistrationService
|
||||||
import net.corda.node.utilities.registration.NodeRegistrationHelper
|
import net.corda.node.utilities.registration.NodeRegistrationHelper
|
||||||
import net.corda.node.utilities.registration.UnableToRegisterNodeWithDoormanException
|
import net.corda.node.utilities.registration.NodeRegistrationException
|
||||||
import net.corda.node.utilities.saveToKeyStore
|
import net.corda.node.utilities.saveToKeyStore
|
||||||
import net.corda.node.utilities.saveToTrustStore
|
import net.corda.node.utilities.saveToTrustStore
|
||||||
import net.corda.nodeapi.internal.addShutdownHook
|
import net.corda.nodeapi.internal.addShutdownHook
|
||||||
@ -154,13 +154,13 @@ open class NodeStartup(val args: Array<String>) {
|
|||||||
if (cmdlineOptions.nodeRegistrationOption != null) {
|
if (cmdlineOptions.nodeRegistrationOption != null) {
|
||||||
// Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig]
|
// Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig]
|
||||||
registerWithNetwork(conf, versionInfo, cmdlineOptions.nodeRegistrationOption)
|
registerWithNetwork(conf, versionInfo, cmdlineOptions.nodeRegistrationOption)
|
||||||
// At this point the node registration was succesfull. We can delete the marker file.
|
// At this point the node registration was successful. We can delete the marker file.
|
||||||
deleteNodeRegistrationMarker(cmdlineOptions.baseDirectory)
|
deleteNodeRegistrationMarker(cmdlineOptions.baseDirectory)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
logStartupInfo(versionInfo, cmdlineOptions, conf)
|
logStartupInfo(versionInfo, cmdlineOptions, conf)
|
||||||
} catch (e: UnableToRegisterNodeWithDoormanException) {
|
} catch (e: NodeRegistrationException) {
|
||||||
logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.")
|
logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.", e)
|
||||||
return false
|
return false
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error("Exception during node registration", e)
|
logger.error("Exception during node registration", e)
|
||||||
|
@ -600,10 +600,11 @@ class SingleThreadedStateMachineManager(
|
|||||||
private fun scheduleTimeoutException(flow: Flow, retryCount: Int): ScheduledFuture<*> {
|
private fun scheduleTimeoutException(flow: Flow, retryCount: Int): ScheduledFuture<*> {
|
||||||
return with(serviceHub.configuration.flowTimeout) {
|
return with(serviceHub.configuration.flowTimeout) {
|
||||||
val timeoutDelaySeconds = timeout.seconds * Math.pow(backoffBase, retryCount.toDouble()).toLong()
|
val timeoutDelaySeconds = timeout.seconds * Math.pow(backoffBase, retryCount.toDouble()).toLong()
|
||||||
|
val jitteredDelaySeconds = maxOf(1L, timeoutDelaySeconds/2 + (Math.random() * timeoutDelaySeconds/2).toLong())
|
||||||
timeoutScheduler.schedule({
|
timeoutScheduler.schedule({
|
||||||
val event = Event.Error(FlowTimeoutException(maxRestartCount))
|
val event = Event.Error(FlowTimeoutException(maxRestartCount))
|
||||||
flow.fiber.scheduleEvent(event)
|
flow.fiber.scheduleEvent(event)
|
||||||
}, timeoutDelaySeconds, TimeUnit.SECONDS)
|
}, jitteredDelaySeconds, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.bouncycastle.openssl.jcajce.JcaPEMWriter
|
|||||||
import org.bouncycastle.util.io.pem.PemObject
|
import org.bouncycastle.util.io.pem.PemObject
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
|
import java.net.ConnectException
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.security.KeyPair
|
import java.security.KeyPair
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
@ -100,7 +101,14 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
|||||||
|
|
||||||
val keyPair = nodeKeyStore.loadOrCreateKeyPair(SELF_SIGNED_PRIVATE_KEY)
|
val keyPair = nodeKeyStore.loadOrCreateKeyPair(SELF_SIGNED_PRIVATE_KEY)
|
||||||
|
|
||||||
val requestId = submitOrResumeCertificateSigningRequest(keyPair)
|
val requestId = try {
|
||||||
|
submitOrResumeCertificateSigningRequest(keyPair)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (e is ConnectException || e is ServiceUnavailableException || e is IOException) {
|
||||||
|
throw NodeRegistrationException(e)
|
||||||
|
}
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
|
||||||
val certificates = try {
|
val certificates = try {
|
||||||
pollServerForCertificates(requestId)
|
pollServerForCertificates(requestId)
|
||||||
@ -113,7 +121,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
|||||||
}
|
}
|
||||||
validateCertificates(keyPair.public, certificates)
|
validateCertificates(keyPair.public, certificates)
|
||||||
storePrivateKeyWithCertificates(nodeKeyStore, keyPair, certificates, keyAlias)
|
storePrivateKeyWithCertificates(nodeKeyStore, keyPair, certificates, keyAlias)
|
||||||
onSuccess(keyPair, certificates, tlsCrlIssuerCert?.let { it.subjectX500Principal.toX500Name() })
|
onSuccess(keyPair, certificates, tlsCrlIssuerCert?.subjectX500Principal?.toX500Name())
|
||||||
// All done, clean up temp files.
|
// All done, clean up temp files.
|
||||||
requestIdStore.deleteIfExists()
|
requestIdStore.deleteIfExists()
|
||||||
}
|
}
|
||||||
@ -193,7 +201,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
|||||||
if (idlePeriodDuration != null) {
|
if (idlePeriodDuration != null) {
|
||||||
Thread.sleep(idlePeriodDuration.toMillis())
|
Thread.sleep(idlePeriodDuration.toMillis())
|
||||||
} else {
|
} else {
|
||||||
throw UnableToRegisterNodeWithDoormanException()
|
throw NodeRegistrationException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +250,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
|||||||
protected open fun isTlsCrlIssuerCertRequired(): Boolean = false
|
protected open fun isTlsCrlIssuerCertRequired(): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnableToRegisterNodeWithDoormanException : IOException()
|
class NodeRegistrationException(cause: Throwable?) : IOException("Unable to contact node registration service", cause)
|
||||||
|
|
||||||
class NodeRegistrationHelper(private val config: NodeConfiguration, certService: NetworkRegistrationService, regConfig: NodeRegistrationOption, computeNextIdleDoormanConnectionPollInterval: (Duration?) -> Duration? = FixedPeriodLimitedRetrialStrategy(10, Duration.ofMinutes(1))) :
|
class NodeRegistrationHelper(private val config: NodeConfiguration, certService: NetworkRegistrationService, regConfig: NodeRegistrationOption, computeNextIdleDoormanConnectionPollInterval: (Duration?) -> Duration? = FixedPeriodLimitedRetrialStrategy(10, Duration.ofMinutes(1))) :
|
||||||
NetworkRegistrationHelper(config,
|
NetworkRegistrationHelper(config,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user