public enum TCPRegistry extends Enum<TCPRegistry>
The reason we offer this functionality is quite often in unit tests you wish to start a test via loopback, followed often by another test via loopback, if the first test does not shut down correctly it can impact on the second test. Giving each test a unique port is one solution, but then managing those ports can become a problem in its self. So we created the TCPRegistry which manages those ports for you, when you come to clean up at the end of each test, all you have to do it call TCPRegistry.reset() and it will ensure that any remaining ports that are open will be closed.
| Modifier and Type | Field and Description |
|---|---|
static String |
TCP_REGISTRY_LOOKUP_TABLE_IMPLEMENTATION_PROPERTY |
| Modifier and Type | Method and Description |
|---|---|
static ChronicleServerSocketChannel |
acquireServerSocketChannel(@NotNull String description) |
static Set<String> |
aliases() |
static void |
assertAllServersStopped() |
static void |
assertAllServersStopped(long timeout,
TimeUnit unit) |
static @NotNull InetSocketAddress |
createInetSocketAddress(@NotNull String hostname,
int port) |
static ChronicleServerSocketChannel |
createServerSocketChannelFor(boolean isNative,
String... descriptions) |
static void |
createServerSocketChannelFor(String... descriptions) |
static ChronicleServerSocketChannel |
createServerSocketChannelFor(@NotNull String descriptions)
Creates and returns a new ChronicleServerSocketChannel.
|
static ChronicleSocketChannel |
createSocketChannel(boolean isNative,
@NotNull String description) |
static ChronicleSocketChannel |
createSocketChannel(@NotNull String description) |
static void |
dumpAllSocketChannels() |
static InetSocketAddress |
lookup(@NotNull String description) |
static void |
reset() |
static void |
setAlias(String name,
@NotNull String hostname,
int port) |
static void |
useCrossProcessRegistry()
Configure the system property to use the cross-process lookup table, this won't come into effect until the next reset
|
static void |
useInMemoryRegistry()
Configure the system property to use the in-memory lookup table, this won't come into effect until the next reset
|
static TCPRegistry |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TCPRegistry[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final String TCP_REGISTRY_LOOKUP_TABLE_IMPLEMENTATION_PROPERTY
public static TCPRegistry[] values()
for (TCPRegistry c : TCPRegistry.values()) System.out.println(c);
public static TCPRegistry valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static void useCrossProcessRegistry()
public static void useInMemoryRegistry()
public static void reset()
public static void assertAllServersStopped()
public static ChronicleServerSocketChannel createServerSocketChannelFor(@NotNull @NotNull String descriptions) throws IOException
descriptions - each string is the name to a reference of a host and port, or if correctly formed this example host and port are used
insteadIOException - if the socket cannot be createdpublic static void createServerSocketChannelFor(@NotNull
String... descriptions)
throws IOException
IOExceptionpublic static ChronicleServerSocketChannel createServerSocketChannelFor(boolean isNative, @NotNull String... descriptions) throws IOException
IOExceptionpublic static ChronicleServerSocketChannel acquireServerSocketChannel(@NotNull @NotNull String description) throws IOException
IOExceptionpublic static InetSocketAddress lookup(@NotNull @NotNull String description)
@NotNull public static @NotNull InetSocketAddress createInetSocketAddress(@NotNull @NotNull String hostname, int port)
public static ChronicleSocketChannel createSocketChannel(@NotNull @NotNull String description) throws IOException
IOExceptionpublic static ChronicleSocketChannel createSocketChannel(boolean isNative, @NotNull @NotNull String description) throws IOException
IOExceptionpublic static void dumpAllSocketChannels()
public static void assertAllServersStopped(long timeout,
TimeUnit unit)
Copyright © 2023. All rights reserved.