public class BytesThroughputEstimator<T> extends java.lang.Object implements ThroughputEstimator<T>
This estimator will keep track of the bytes of reported records within a sliding window. The
window consists of the configured number of seconds and each record's bytes will fall into
exactly one given second bucket. When more than window size seconds have passed from the current
time, the bytes reported for the seconds that fall of the window will not be considered anymore.
The bytes of the records will be estimated using the configured Coder
.
Constructor and Description |
---|
BytesThroughputEstimator(int windowSizeSeconds,
SizeEstimator<T> sizeEstimator) |
Modifier and Type | Method and Description |
---|---|
double |
get()
Returns the estimated throughput bytes for now.
|
double |
getFrom(com.google.cloud.Timestamp time)
Returns the estimated throughput bytes for a specified time.
|
void |
update(com.google.cloud.Timestamp timeOfRecords,
T element)
Updates the estimator with the bytes of records.
|
public BytesThroughputEstimator(int windowSizeSeconds, SizeEstimator<T> sizeEstimator)
public void update(com.google.cloud.Timestamp timeOfRecords, T element)
update
in interface ThroughputEstimator<T>
timeOfRecords
- the committed timestamp of the recordselement
- the element to estimate the byte size ofpublic double get()
get
in interface ThroughputEstimator<T>
public double getFrom(com.google.cloud.Timestamp time)
getFrom
in interface ThroughputEstimator<T>
time
- the specified timestamp to check throughput