Cleaned up TimeWindow and added a bit more docs.

This commit is contained in:
Shams Asari
2017-07-20 13:32:53 +01:00
parent bf98f64269
commit e702025f62
18 changed files with 189 additions and 96 deletions

View File

@ -2,8 +2,10 @@ package net.corda.services.messaging
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
import net.corda.core.*
import net.corda.core.crypto.random63BitValue
import net.corda.core.elapsedTime
import net.corda.core.getOrThrow
import net.corda.core.internal.times
import net.corda.core.messaging.MessageRecipients
import net.corda.core.messaging.SingleMessageRecipient
import net.corda.core.node.services.ServiceInfo
@ -43,7 +45,7 @@ class P2PMessagingTest : NodeBasedTest() {
// Start the network map a second time - this will restore message queues from the journal.
// This will hang and fail prior the fix. https://github.com/corda/corda/issues/37
stopAllNodes()
startNodes().getOrThrow(timeout = startUpDuration.multipliedBy(3))
startNodes().getOrThrow(timeout = startUpDuration * 3)
}
// https://github.com/corda/corda/issues/71

View File

@ -3,12 +3,12 @@ package net.corda.node.utilities
import co.paralleluniverse.fibers.Suspendable
import co.paralleluniverse.strands.SettableFuture
import com.google.common.util.concurrent.ListenableFuture
import net.corda.core.internal.until
import net.corda.core.then
import rx.Observable
import rx.Subscriber
import rx.subscriptions.Subscriptions
import java.time.Clock
import java.time.Duration
import java.time.Instant
import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicLong
@ -80,7 +80,7 @@ fun Clock.awaitWithDeadline(deadline: Instant, future: Future<*> = GuavaSettable
} else {
null
}
nanos = Duration.between(this.instant(), deadline).toNanos()
nanos = (instant() until deadline).toNanos()
if (nanos > 0) {
try {
// This will return when it times out, or when the clock mutates or when when the original future completes.

View File

@ -1,10 +1,13 @@
package net.corda.node.utilities
import net.corda.core.internal.until
import net.corda.core.serialization.SerializeAsToken
import net.corda.core.serialization.SerializeAsTokenContext
import net.corda.core.serialization.SingletonSerializationToken
import net.corda.core.serialization.SingletonSerializationToken.Companion.singletonSerializationToken
import java.time.*
import java.time.Clock
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
import javax.annotation.concurrent.ThreadSafe
/**
@ -21,7 +24,7 @@ class TestClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableC
val currentDate = LocalDate.now(this)
if (currentDate.isBefore(date)) {
// It's ok to increment
delegateClock = Clock.offset(delegateClock, Duration.between(currentDate.atStartOfDay(), date.atStartOfDay()))
delegateClock = Clock.offset(delegateClock, currentDate.atStartOfDay() until date.atStartOfDay())
notifyMutationObservers()
return true
}