Class ReservoirTraceStorageStrategy
- java.lang.Object
-
- fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy
-
- All Implemented Interfaces:
TraceStorageStrategy
public class ReservoirTraceStorageStrategy extends Object implements TraceStorageStrategy
Strategy for finding traces that need removing from a list, according to a reservoir sampling algorithm. https://en.wikipedia.org/wiki/Reservoir_sampling.
-
-
Constructor Summary
Constructors Modifier Constructor Description ReservoirTraceStorageStrategy()
protected
ReservoirTraceStorageStrategy(long seed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestTrace
getTraceForRemoval(Collection<RequestTrace> traces, int maxSize, RequestTrace traceToRemove)
Gets the trace that needs removing.
-
-
-
Method Detail
-
getTraceForRemoval
public RequestTrace getTraceForRemoval(Collection<RequestTrace> traces, int maxSize, RequestTrace traceToRemove)
Gets the trace that needs removing. Removes the provided trace if present, or a random trace each trace having the same probability of being kept or removed.- Specified by:
getTraceForRemoval
in interfaceTraceStorageStrategy
- Parameters:
traces
- the list of traces to test.maxSize
- the maximum size of the list.traceToRemove
- the trace to remove if present- Returns:
- the trace that needs removing, or null if no traces need removing.
-
-