Package com.apicatalog.rdf.canon
Class RdfCanonTimeTicker
- java.lang.Object
-
- com.apicatalog.rdf.canon.RdfCanonTimeTicker
-
- All Implemented Interfaces:
RdfCanonTicker
public final class RdfCanonTimeTicker extends java.lang.Object implements RdfCanonTicker
An implementation ofRdfCanonTickerthat monitors elapsed time in milliseconds and interrupts the RDF canonicalization process if a specified maximum duration is exceeded.This ticker uses
System.currentTimeMillis()to measure elapsed time. It throws anIllegalStateExceptionif the canonicalization process runs longer than the allowed time limit.Example usage:
RdfCanonTicker ticker = new ElapsedTimeTicker(5000); // 5 seconds timeout- See Also:
RdfCanonTicker
-
-
Field Summary
Fields Modifier and Type Field Description private longmaxDurationMillisMaximum allowed execution time in milliseconds.private longstartTimeMillisStart time in milliseconds, initialized on the firsttick()call.-
Fields inherited from interface com.apicatalog.rdf.canon.RdfCanonTicker
EMPTY
-
-
Constructor Summary
Constructors Constructor Description RdfCanonTimeTicker(long maxDurationMillis)Creates a newElapsedTimeTickerwith a specified timeout duration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidtick()Invoked periodically during RDF canonicalization to check if the maximum execution time has been exceeded.
-
-
-
Constructor Detail
-
RdfCanonTimeTicker
public RdfCanonTimeTicker(long maxDurationMillis)
Creates a newElapsedTimeTickerwith a specified timeout duration.- Parameters:
maxDurationMillis- the maximum allowed execution time in milliseconds; must be positive- Throws:
java.lang.IllegalArgumentException- ifmaxDurationMillisis zero or negative
-
-
Method Detail
-
tick
public void tick() throws java.lang.IllegalStateExceptionInvoked periodically during RDF canonicalization to check if the maximum execution time has been exceeded.- Specified by:
tickin interfaceRdfCanonTicker- Throws:
java.lang.IllegalStateException- if the allowed time limit has been reached
-
-