T
- the type of the Server
U
- the type of the Server.start(T)
method options@ThreadSafe public class Registry<T extends Server<U>,U> extends Object
Server
s that run within an Alluxio process. The intended
use of this class is for the Alluxio process to register the individual Server
s using an
instance of this class. The registry is passed as an argument to constructors of individual
Server
s who are expected to add themselves to the registry.
The reason for using an instance as opposed to a static class is to enable dependency
injection in tests.Constructor and Description |
---|
Registry()
Creates a new instance of
Registry . |
Modifier and Type | Method and Description |
---|---|
<W extends T> |
add(Class<W> clazz,
T server)
Registers a canonical mapping of the type to the server instance.
|
<W extends T> |
addAlias(Class<W> clazz,
T server)
Registers a server instance under an alias type.
|
void |
close()
Closes all
Server s in reverse dependency order. |
<W extends T> |
get(Class<W> clazz)
Convenience method for calling
get(Class, int) with a default timeout. |
<W extends T> |
get(Class<W> clazz,
int timeoutMs)
Attempts to look up the
Server for the given class. |
<W extends T> |
getCanonical(Class<W> type)
Convenience method for
getCanonical(Class, int) with default timeout. |
<W extends T> |
getCanonical(Class<W> type,
int timeoutMs)
Gets the server registered with the canonical type.
|
List<T> |
getServers() |
void |
start(U options)
Starts all
Server s in dependency order. |
void |
stop()
Stops all
Server s in reverse dependency order. |
public Registry()
Registry
.public <W extends T> W get(Class<W> clazz)
get(Class, int)
with a default timeout.public <W extends T> W get(Class<W> clazz, int timeoutMs)
Server
for the given class. Because Server
s can be
looked up and added to the registry in parallel, the lookup is retried until the given timeout
period has elapsed.W
- the type of the Server
to getclazz
- the class of the Server
to gettimeoutMs
- timeout for looking up the serverServer
instanceif alias mappings should be ignored
public <W extends T> W getCanonical(Class<W> type)
getCanonical(Class, int)
with default timeout.W
- server typetype
- canonical typepublic <W extends T> W getCanonical(Class<W> type, int timeoutMs)
addAlias(Class, Server)
are not considered.W
- the typetype
- the canonical typetimeoutMs
- time before giving up the lookupget(Class, int)
public <W extends T> void add(Class<W> clazz, T server)
W
- the type of the Server
to addclazz
- the class of the Server
to addserver
- the Server
to addaddAlias(Class, Server)
public <W extends T> void addAlias(Class<W> clazz, T server)
W
- the type of the serverclazz
- the alias typeserver
- the Server
to addIllegalArgumentException
- when the server has not yet been registered under a canonical
name with add(Class, Server)
, or a canonical mapping already exists for the same typeadd(Class, Server)
public List<T> getServers()
Server
s, order by dependency relationpublic void start(U options) throws IOException
Server
s in dependency order. If A depends on B, A is started before B.
If a Server
fails to start, already-started Server
s will be stopped.options
- the start optionsIOException
public void stop() throws IOException
Server
s in reverse dependency order. If A depends on B, A is stopped
before B.IOException
public void close() throws IOException
Server
s in reverse dependency order. If A depends on B, A is closed
before B.IOException
Copyright © 2023. All Rights Reserved.