Package org.apache.solr.common.util
Class TimeSource.SimTimeSource
- java.lang.Object
- 
- org.apache.solr.common.util.TimeSource
- 
- org.apache.solr.common.util.TimeSource.SimTimeSource
 
 
- 
- Enclosing class:
- TimeSource
 
 public static final class TimeSource.SimTimeSource extends TimeSource Implementation that usesTimeSource.NANO_TIMEaccelerated by a double multiplier.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.apache.solr.common.util.TimeSourceTimeSource.CurrentTimeSource, TimeSource.NanoTimeSource, TimeSource.SimTimeSource
 
- 
 - 
Field Summary- 
Fields inherited from class org.apache.solr.common.util.TimeSourceCURRENT_TIME, NANO_TIME
 
- 
 - 
Constructor SummaryConstructors Constructor Description SimTimeSource(double multiplier)Create a simulated time source that runs faster than real time by a multiplier.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longconvertDelay(TimeUnit fromUnit, long value, TimeUnit toUnit)This method allows using TimeSource with APIs that require providing just plain time intervals, e.g.longgetEpochTimeNs()Return Epoch time.long[]getTimeAndEpochNs()Return both the source's time value and the corresponding epoch time value.longgetTimeNs()Return a time value, in nanosecond units.voidsleep(long ms)Sleep according to this source's notion of time.StringtoString()- 
Methods inherited from class org.apache.solr.common.util.TimeSourceget
 
- 
 
- 
- 
- 
Method Detail- 
getTimeNspublic long getTimeNs() Description copied from class:TimeSourceReturn a time value, in nanosecond units. Depending on implementation this value may or may not be related to Epoch time.- Specified by:
- getTimeNsin class- TimeSource
 
 - 
getEpochTimeNspublic long getEpochTimeNs() Description copied from class:TimeSourceReturn Epoch time. Implementations that are not natively based on epoch time may return values that are consistently off by a (small) fixed number of milliseconds from the actual epoch time.- Specified by:
- getEpochTimeNsin class- TimeSource
 
 - 
getTimeAndEpochNspublic long[] getTimeAndEpochNs() Description copied from class:TimeSourceReturn both the source's time value and the corresponding epoch time value. This method ensures that epoch time calculations use the same internal value of time as that reported byTimeSource.getTimeNs().- Specified by:
- getTimeAndEpochNsin class- TimeSource
- Returns:
- an array where the first element is TimeSource.getTimeNs()and the second element isTimeSource.getEpochTimeNs().
 
 - 
sleeppublic void sleep(long ms) throws InterruptedExceptionDescription copied from class:TimeSourceSleep according to this source's notion of time. E.g. accelerated time source such asTimeSource.SimTimeSourcewill sleep proportionally shorter, according to its multiplier.- Specified by:
- sleepin class- TimeSource
- Parameters:
- ms- number of milliseconds to sleep
- Throws:
- InterruptedException- when the current thread is interrupted
 
 - 
convertDelaypublic long convertDelay(TimeUnit fromUnit, long value, TimeUnit toUnit) Description copied from class:TimeSourceThis method allows using TimeSource with APIs that require providing just plain time intervals, e.g.Object.wait(long). Values returned by this method are adjusted according to the time source's notion of time - e.g. accelerated time source provided byTimeSource.SimTimeSourcewill return intervals that are proportionally shortened by the multiplier.NOTE: converting small values may significantly affect precision of the returned values due to rounding, especially for accelerated time source, so care should be taken to use time units that result in relatively large values. For example, converting a value of 1 expressed in seconds would result in less precision than converting a value of 1000 expressed in milliseconds. - Specified by:
- convertDelayin class- TimeSource
- Parameters:
- fromUnit- source unit
- value- original value
- toUnit- target unit
- Returns:
- converted value, possibly scaled by the source's notion of accelerated time (see TimeSource.SimTimeSource)
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- TimeSource
 
 
- 
 
-