public class TimestampSet
extends java.lang.Object
implements java.lang.Iterable<java.util.Map.Entry<java.lang.Integer,java.lang.Double>>, java.util.Map<java.lang.Integer,java.lang.Double>
The timestamp set is represented as a dictionary of integer-float pairs, where the integer index refers to the location at which the timestamp was added and the floating-point time gives the time at which an event was there.
The class provides methods for constructing, manipulating and querying the contents of the timestamp set.
Note that this class is NOT itself thread-safe.
This class defines a number of constants for representing different points in the journey of an event/message through the layers of the IAF, which can be enabled by setting the relevant recordUpstream/recordDownstream configuration setting. The most commonly used timestamps are:
AP_TIMESTAMP_DOWNSTREAM_IAF_MAPPER_ENTRY
/AP_TIMESTAMP_DOWNSTREAM_IAF_MAPPER_ENTRY
,
AP_TIMESTAMP_UPSTREAM_IAF_MAPPER_ENTRY
/AP_TIMESTAMP_UPSTREAM_IAF_MAPPER_ENTRY
AP_TIMESTAMP_DOWNSTREAM_IAF_DECODER_ENTRY
/AP_TIMESTAMP_DOWNSTREAM_IAF_DECODER_EXIT
,
AP_TIMESTAMP_UPSTREAM_IAF_ENCODER_ENTRY
/AP_TIMESTAMP_UPSTREAM_IAF_ENCODER_EXIT
AP_TIMESTAMP_DOWNSTREAM_IAF_TRANSPORT_ENTRY
/AP_TIMESTAMP_DOWNSTREAM_IAF_TRANSPORT_EXIT
,
AP_TIMESTAMP_UPSTREAM_IAF_TRANSPORT_ENTRY
/AP_TIMESTAMP_UPSTREAM_IAF_TRANSPORT_EXIT
Constructor and Description |
---|
TimestampSet()
Constructs a new TimestampSet, initially empty.
|
TimestampSet(java.util.Map<java.lang.Integer,java.lang.Double> m)
Constructs a new TimestampSet, with the same name/time pairs as
the specified Map or TimestampSet.
|
Modifier and Type | Method and Description |
---|---|
void |
addNow(java.lang.Integer index)
Add a new index-time pair to the event.
|
void |
addTime(java.lang.Integer index,
java.lang.Double theTime)
Add a new index-time pair to the timestamp.
|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(java.lang.Object index)
Returns true if this map contains the specified key
|
boolean |
containsValue(java.lang.Object time)
Returns true if this map maps one or more names to the
specified time.
|
java.util.Set<java.util.Map.Entry<java.lang.Integer,java.lang.Double>> |
entrySet() |
java.lang.Double |
findTime(java.lang.Integer index)
Search for a named element in the timestamp set and return its
time.
|
java.lang.Double |
findTimeAndRemove(java.lang.Integer index)
Search for a named element in the timestamp set and return its
time.
|
java.lang.Double |
get(java.lang.Object index)
Returns the time to which the specified name is mapped, or
null if the map contains no mapping for this index.
|
static double |
getMicroTime()
Get the current microsecond-accurate relative timestamp.
|
boolean |
isEmpty()
Returns true if this map contains no index-time mappings.
|
java.util.Iterator<java.util.Map.Entry<java.lang.Integer,java.lang.Double>> |
iterator()
Returns a standard Java Iterator over the contents of the TimestampSet using
Map.Entry objects. |
java.util.Set<java.lang.Integer> |
keySet() |
java.lang.Double |
put(java.lang.Integer index,
java.lang.Double time)
Adds or replaces the specified (index,time) pair in the underlying map
|
void |
putAll(java.util.Map<? extends java.lang.Integer,? extends java.lang.Double> m)
Copies all of the mappings from the specified map to this map
These mappings will replace any mappings that
this map had for any of the indices currently in the specified map.
|
void |
putNow(java.lang.Integer index)
Set the time of a specified timestamp in the timestamp set to current time, regardless of
whether a timestamp with the given index already exists.
|
java.lang.Double |
remove(java.lang.Object index)
Removes the mapping for this index from this map if present.
|
java.lang.Double |
replace(java.lang.Integer index,
java.lang.Double newTime)
Deprecated.
This method has been deprecated to avoid confusion with Map.replace; please
update code to use
put(Integer, Double) instead. |
void |
replaceWithNow(java.lang.Integer index)
Deprecated.
This method has been deprecated to avoid confusion with Map.replace; please
update code to use
putNow(Integer) instead. |
int |
size()
Get the number of elements (name-time pairs) currently stored by the
event.
|
java.lang.String |
toString()
Return a printable string representation of the timestamp set.
|
java.util.Collection<java.lang.Double> |
values()
Returns a collection view of the times contained in this map.
|
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_TRANSPORT_ENTRY
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_TRANSPORT_EXIT
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_DECODER_ENTRY
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_DECODER_EXIT
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_MAPPER_ENTRY
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_MAPPER_EXIT
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_APAMA_ENTRY
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_APAMA_EXIT
public static final int AP_TIMESTAMP_DOWNSTREAM_IAF_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_SENDER_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_SENDER_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_INPUT_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_INPUT_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_SERVICE_MONITOR_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_SERVICE_MONITOR_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_RESERVED1_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_RESERVED1_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_RESERVED2_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_RESERVED2_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_APPLICATION_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_APPLICATION_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_OUTPUT_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_OUTPUT_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CORRELATOR_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_MERGER_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_MERGE_MAX
public static final int AP_TIMESTAMP_DOWNSTREAM_CLIENT_MIN
public static final int AP_TIMESTAMP_DOWNSTREAM_CLIENT_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CLIENT_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CLIENT_MAX
public static final int AP_TIMESTAMP_UPSTREAM_SENDER_MIN
public static final int AP_TIMESTAMP_UPSTREAM_SENDER_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_INPUT_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_INPUT_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_APPLICATION_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_APPLICATION_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_RESERVED2_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_RESERVED2_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_RESERVED1_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_RESERVED1_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_SERVICE_MONITOR_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_SERVICE_MONITOR_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_OUTPUT_MIN
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_OUTPUT_MAX
public static final int AP_TIMESTAMP_UPSTREAM_CORRELATOR_MAX
public static final int AP_TIMESTAMP_UPSTREAM_MERGER_MIN
public static final int AP_TIMESTAMP_UPSTREAM_MERGER_MAX
public static final int AP_TIMESTAMP_UPSTREAM_IAF_MIN
public static final int AP_TIMESTAMP_UPSTREAM_IAF_APAMA_ENTRY
public static final int AP_TIMESTAMP_UPSTREAM_IAF_APAMA_EXIT
public static final int AP_TIMESTAMP_UPSTREAM_IAF_MAPPER_ENTRY
public static final int AP_TIMESTAMP_UPSTREAM_IAF_MAPPER_EXIT
public static final int AP_TIMESTAMP_UPSTREAM_IAF_ENCODER_ENTRY
public static final int AP_TIMESTAMP_UPSTREAM_IAF_ENCODER_EXIT
public static final int AP_TIMESTAMP_UPSTREAM_IAF_TRANSPORT_ENTRY
public static final int AP_TIMESTAMP_UPSTREAM_IAF_TRANSPORT_EXIT
public static final int AP_TIMESTAMP_UPSTREAM_IAF_MAX
public TimestampSet()
public TimestampSet(java.util.Map<java.lang.Integer,java.lang.Double> m)
public int size()
size
in interface java.util.Map<java.lang.Integer,java.lang.Double>
public void addNow(java.lang.Integer index) throws TimestampSetException
index
- The name of the new elementTimestampSetException
- Thrown if index=null
public void addTime(java.lang.Integer index, java.lang.Double theTime) throws TimestampSetException
index
- The index of the new elementtheTime
- The time of the new elementTimestampSetException
- Thrown if index=null
@Deprecated public java.lang.Double replace(java.lang.Integer index, java.lang.Double newTime) throws TimestampSetException
put(Integer, Double)
instead.put(Integer, Double)
.
This method does not have the same semantics as the new Map.replace method introduced in Java 1.8, and has therefore been deprecated to avoid confusion.
replace
in interface java.util.Map<java.lang.Integer,java.lang.Double>
TimestampSetException
public void replaceWithNow(java.lang.Integer index) throws TimestampSetException
putNow(Integer)
instead.putNow(Integer)
.
This method does not have the same semantics as the new Map.replace method introduced in Java 1.8, and has therefore been deprecated to avoid confusion.
TimestampSetException
public void putNow(java.lang.Integer index) throws TimestampSetException
index
- The name of the element to be updatedTimestampSetException
- Thrown if index=null
public java.lang.Double findTime(java.lang.Integer index)
index
- The element name to search fornull
if no matching element could be found. Note that this function cannot
distinguish between an element with a missing time and an element that
does not exist - null
will be returned in either case.public java.lang.Double findTimeAndRemove(java.lang.Integer index)
index
- The element name to search fornull
if
no matching element could be found. If the element was found, it will be
deleted from the event. Note that this function cannot distinguish
between an element with a missing time and an element that does not
exist - null
will be returned in either case.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<java.util.Map.Entry<java.lang.Integer,java.lang.Double>> iterator()
Map.Entry
objects. If the map is modified while an iteration
over the set is in progress (except through the iterator's own
remove operation, or through the setTime operation on
a map entry returned by the iterator) the results of the iteration are
undefined.
Instead of calling this method directly, it may be easier to use the
following construction:
for (Map.Entry
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.Integer,java.lang.Double>>
public java.lang.Double put(java.lang.Integer index, java.lang.Double time) throws TimestampSetException
put
in interface java.util.Map<java.lang.Integer,java.lang.Double>
index
- Any stringtime
- Any string or null
null
), or null
if the index did not existTimestampSetException
- If index=null
Map.put(Object, Object)
public java.util.Set<java.util.Map.Entry<java.lang.Integer,java.lang.Double>> entrySet()
entrySet
in interface java.util.Map<java.lang.Integer,java.lang.Double>
Map.entrySet()
public java.util.Set<java.lang.Integer> keySet()
keySet
in interface java.util.Map<java.lang.Integer,java.lang.Double>
Map.keySet()
public void clear()
clear
in interface java.util.Map<java.lang.Integer,java.lang.Double>
Map.clear()
public boolean containsKey(java.lang.Object index)
containsKey
in interface java.util.Map<java.lang.Integer,java.lang.Double>
index
- The key whose presence in this map is to be testedMap.containsKey(Object)
public boolean containsValue(java.lang.Object time)
containsValue
in interface java.util.Map<java.lang.Integer,java.lang.Double>
time
- time whose presence in this map is to be tested.Map.containsValue(Object)
public java.lang.Double get(java.lang.Object index)
get
in interface java.util.Map<java.lang.Integer,java.lang.Double>
index
- the index whose associated time is to be returned.Map.put(Object, Object)
,
Map.get(Object)
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.Integer,java.lang.Double>
Map.isEmpty()
public void putAll(java.util.Map<? extends java.lang.Integer,? extends java.lang.Double> m)
putAll
in interface java.util.Map<java.lang.Integer,java.lang.Double>
m
- mappings to be stored in this map.java.lang.NullPointerException
- if the specified map is null.Map.putAll(Map)
public java.lang.Double remove(java.lang.Object index)
remove
in interface java.util.Map<java.lang.Integer,java.lang.Double>
index
- index whose mapping is to be removed from the map.Map.remove(Object)
public java.util.Collection<java.lang.Double> values()
values
in interface java.util.Map<java.lang.Integer,java.lang.Double>
Map.values()
public static double getMicroTime()
Submit a bug or feature
Copyright (c) 2013-2016 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.