Class ProgressEventDispatcher
- java.lang.Object
-
- com.google.cloud.tools.jib.builder.ProgressEventDispatcher
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ProgressEventDispatcher extends java.lang.Object implements java.io.Closeable
DispatchesProgressEvent
s associated with a managedAllocation
. Keeps track of the allocation units that are remaining so that it can emit the remaining progress units uponclose()
.This class is not thread-safe. Only use a single instance per thread and create child instances with
newChildProducer()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ProgressEventDispatcher.Factory
Creates a newProgressEventDispatcher
based off an existingProgressEventDispatcher
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Emits the remaining allocation units as progress units in aProgressEvent
.void
dispatchProgress(long progressUnits)
ProgressEventDispatcher.Factory
newChildProducer()
Creates a newProgressEventDispatcher.Factory
for aProgressEventDispatcher
that manages a childAllocation
.static ProgressEventDispatcher
newRoot(EventHandlers eventHandlers, java.lang.String description, long allocationUnits)
Creates a newProgressEventDispatcher
with a rootAllocation
.
-
-
-
Method Detail
-
newRoot
public static ProgressEventDispatcher newRoot(EventHandlers eventHandlers, java.lang.String description, long allocationUnits)
Creates a newProgressEventDispatcher
with a rootAllocation
.- Parameters:
eventHandlers
- theEventHandlers
description
- user-facing description of what the allocation representsallocationUnits
- number of allocation units- Returns:
- a new
ProgressEventDispatcher
-
newChildProducer
public ProgressEventDispatcher.Factory newChildProducer()
Creates a newProgressEventDispatcher.Factory
for aProgressEventDispatcher
that manages a childAllocation
. Since each childAllocation
accounts for 1 allocation unit of its parent, this method decrements theremainingAllocationUnits
by1
.- Returns:
- a new
ProgressEventDispatcher.Factory
-
close
public void close()
Emits the remaining allocation units as progress units in aProgressEvent
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
dispatchProgress
public void dispatchProgress(long progressUnits)
- Parameters:
progressUnits
- units of progress
-
-