Class ZKGlobalWatermarkTracker
- java.lang.Object
-
- cz.o2.proxima.core.utils.zookeeper.ZKGlobalWatermarkTracker
-
- All Implemented Interfaces:
TimeProvider
,GlobalWatermarkTracker
,WatermarkSupplier
,java.io.Serializable
public class ZKGlobalWatermarkTracker extends java.lang.Object implements GlobalWatermarkTracker
AGlobalWatermarkTracker
that stores global information in Apache Zookeeper.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CFG_MAX_ACCEPTABLE_UPDATE_AGE_MS
static java.lang.String
CFG_NAME
static java.lang.String
CFG_TIME_PROVIDER
static java.lang.String
ZK_SESSION_TIMEOUT
static java.lang.String
ZK_URI
-
Constructor Summary
Constructors Constructor Description ZKGlobalWatermarkTracker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finished(java.lang.String name)
Remove given process from the tracker.long
getGlobalWatermark(java.lang.String processName, long currentWatermark)
Retrieve global watermark tracked by this tracker.java.lang.String
getName()
Retrieve name of this tracker.void
initWatermarks(java.util.Map<java.lang.String,java.lang.Long> initialWatermarks)
Setup parallel consumers.protected java.lang.Object
readResolve()
void
setup(java.util.Map<java.lang.String,java.lang.Object> cfg)
Configure the tracker using given configuration.java.lang.String
toString()
java.util.concurrent.CompletableFuture<java.lang.Void>
update(java.lang.String processName, long currentWatermark)
Update watermark of given process.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.core.storage.watermark.GlobalWatermarkTracker
getWatermark
-
Methods inherited from interface cz.o2.proxima.core.time.WatermarkSupplier
getCurrentTime
-
-
-
-
Field Detail
-
CFG_NAME
public static final java.lang.String CFG_NAME
- See Also:
- Constant Field Values
-
ZK_URI
public static final java.lang.String ZK_URI
- See Also:
- Constant Field Values
-
ZK_SESSION_TIMEOUT
public static final java.lang.String ZK_SESSION_TIMEOUT
- See Also:
- Constant Field Values
-
CFG_TIME_PROVIDER
public static final java.lang.String CFG_TIME_PROVIDER
- See Also:
- Constant Field Values
-
CFG_MAX_ACCEPTABLE_UPDATE_AGE_MS
public static final java.lang.String CFG_MAX_ACCEPTABLE_UPDATE_AGE_MS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:GlobalWatermarkTracker
Retrieve name of this tracker.- Specified by:
getName
in interfaceGlobalWatermarkTracker
- Returns:
- name of the tracker
-
setup
public void setup(java.util.Map<java.lang.String,java.lang.Object> cfg)
Description copied from interface:GlobalWatermarkTracker
Configure the tracker using given configuration.- Specified by:
setup
in interfaceGlobalWatermarkTracker
- Parameters:
cfg
- the (scoped) configuration map
-
initWatermarks
public void initWatermarks(java.util.Map<java.lang.String,java.lang.Long> initialWatermarks)
Description copied from interface:GlobalWatermarkTracker
Setup parallel consumers. This SHOULD be used once when the tracker is constructed to setup initial names and watermarks of consumers. Note that consumers might be added during runtime, but their added watermark cannot move the watermark back in time.- Specified by:
initWatermarks
in interfaceGlobalWatermarkTracker
- Parameters:
initialWatermarks
- map of process name to the initial watermark
-
update
public java.util.concurrent.CompletableFuture<java.lang.Void> update(java.lang.String processName, long currentWatermark)
Description copied from interface:GlobalWatermarkTracker
Update watermark of given process. This call MAY add a new process, which was not part ofGlobalWatermarkTracker.initWatermarks(java.util.Map<java.lang.String, java.lang.Long>)
. This is asynchronous operation. Users can wait for the completion using the returnedCompletableFuture
.- Specified by:
update
in interfaceGlobalWatermarkTracker
- Parameters:
processName
- name of the processcurrentWatermark
- current processing watermark of the process- Returns:
CompletableFuture
to be able to wait for result being persisted
-
finished
public void finished(java.lang.String name)
Description copied from interface:GlobalWatermarkTracker
Remove given process from the tracker. The watermark of the process (if any) will no longer hold the global watermark. This is asynchronous operation. Users can wait for the completion using the returnedCompletableFuture
.Note that this is semantically equivalent to call to
GlobalWatermarkTracker.update(java.lang.String, long)
(name, Instant.ofEpochMilli(Long.MAX_VALUE))- Specified by:
finished
in interfaceGlobalWatermarkTracker
- Parameters:
name
- name of the process to remove
-
getGlobalWatermark
public long getGlobalWatermark(@Nullable java.lang.String processName, long currentWatermark)
Description copied from interface:GlobalWatermarkTracker
Retrieve global watermark tracked by this tracker.- Specified by:
getGlobalWatermark
in interfaceGlobalWatermarkTracker
- Parameters:
processName
- name of process querying the global watermarkcurrentWatermark
- current watermark of process querying the watermark- Returns:
- the global watermark
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
readResolve
protected java.lang.Object readResolve()
-
-