Class PortManager.PortRef
java.lang.Object
org.terracotta.utilities.test.net.PortManager.PortRef
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- PortManager
Represents a reserved TCP port. When use of the port is no longer needed, this
reference should be closed to release the reservation.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final AtomicReference<BiConsumer<Integer,Set<PortManager.PortRef.CloseOption>>> private final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisPortRef.voidclose(Set<PortManager.PortRef.CloseOption> options) Closes thisPortRefusing the options provided.closers()Gets the "closers"AtomicReferencefor use during weak-reference release.booleanisClosed()Returns whether or not thisPortRefis closed.(package private) voidPrepends a close action to thisPortRef.intport()Gets the reserved port number.
-
Field Details
-
port
private final int port -
closers
-
closed
-
-
Constructor Details
-
PortRef
private PortRef(int port)
-
-
Method Details
-
onClose
Prepends a close action to thisPortRef. Actions are executed in reverse order of their addition. Each action is passed the port number being closed.- Parameters:
action- the action to take to close thisPortRefinstance
-
closers
Gets the "closers"AtomicReferencefor use during weak-reference release.- Returns:
- the
AtomicReferenceinstance to call for closing thisPortRef
-
port
public int port()Gets the reserved port number.- Returns:
- the port number
-
isClosed
public boolean isClosed()Returns whether or not thisPortRefis closed.- Returns:
trueif thisPortRefhas been closed;falseotherwise
-
close
public void close()Closes thisPortRef.- Specified by:
closein interfaceAutoCloseable
-
close
Closes thisPortRefusing the options provided.- Parameters:
options- the set ofPortManager.PortRef.CloseOptions to apply to this close call; may be empty but notnull
-