Package org.apache.hadoop.hbase.net
Class BoundSocketMaker
java.lang.Object
org.apache.hadoop.hbase.net.BoundSocketMaker
- All Implemented Interfaces:
Closeable
,AutoCloseable
Utility to generate a bound socket. Useful testing for BindException. Use one of the Constructors
to create an instance of this class. On creation it will have put up a ServerSocket on a random
port. Get the port it is bound to using
getPort()
. In your test, then try to start a
Server using same port to generate a BindException. Call close()
when done to shut down
the Socket.-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private final ServerSocket
-
Constructor Summary
ModifierConstructorDescriptionprivate
BoundSocketMaker
(String hostname, Supplier<Integer> randomPortMaker) BoundSocketMaker
(Supplier<Integer> randomPortMaker) -
Method Summary
-
Field Details
-
LOG
-
socket
-
-
Constructor Details
-
BoundSocketMaker
private BoundSocketMaker() -
BoundSocketMaker
-
BoundSocketMaker
-
-
Method Details
-
getPort
-
get
Returns Returns a bound socket; be sure to close when done. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-