java.lang.Object
net.i2p.app.ClientAppManagerImpl
net.i2p.router.startup.RouterAppManager
- All Implemented Interfaces:
ClientAppManager
Notify the router of events, and provide methods for client apps to find each other.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassShutdown task for router applications.Field Summary
FieldsFields inherited from class ClientAppManagerImpl
_registeredModifier and TypeFieldDescriptionprotected final ConcurrentHashMap<String, ClientApp> Registered name to client.Constructor Summary
ConstructorsConstructorDescriptionOpens the client map and registers a shutdown task.Method Summary
Modifier and TypeMethodDescriptionbooleanaddAndStart(ClientApp app, String[] args) Add and start a client application.Merge the tracked and registered app maps into one row set of {state, name, class, args}, sorted by name.(package private) static StringMap an app state to its status dot colour: green running, yellow in transition, red failed, grey stopped or never started.getClientApp(String className, String[] args) First known ClientApp with this class name and exact arguments.int[]Debug overview counts as {tracked, running, registered}.voidnotify(ClientApp app, ClientAppState state, String message, Exception e) Must be called on all state transitions except from UNINITIALIZED to INITIALIZED.booleanRegister with the manager under the given name, so that other clients may find it.voidrenderStatusHTML(Writer out) Table of registered and running router apps with state dots.voidshutdown()Shut down all running client applications.voidunregister(ClientApp app) Unregister with the manager.Methods inherited from class ClientAppManagerImpl
getRegisteredApp
Field Details
_log
Logger for this class._clients
Client apps to the arguments they were started with. This assumes the clients do not override equals().
Constructor Details
RouterAppManager
Opens the client map and registers a shutdown task.- Parameters:
ctx- router context supplying the log manager and shutdown task registration
Method Details
addAndStart
Add and start a client application.- Parameters:
app- the client application to track and startargs- the args that were used to instantiate the app, non-null, may be zero-length- Returns:
- true if the app started; false if startup() threw, in which case it is dropped again
- Throws:
IllegalArgumentException- if already added
getClientApp
First known ClientApp with this class name and exact arguments. Caller may then retrieve or control the state of the returned client. A client will generally be found only if it is running or transitioning; after it is stopped it will not be tracked by the manager.- Parameters:
className- fully qualified class name of the client application to findargs- non-null, may be zero-length- Returns:
- client app or null
notify
Must be called on all state transitions except from UNINITIALIZED to INITIALIZED.- Specified by:
notifyin interfaceClientAppManager- Overrides:
notifyin classClientAppManagerImpl- Parameters:
app- non-nullstate- non-nullmessage- may be nulle- may be null
register
Register with the manager under the given name, so that other clients may find it. Only required for apps used by other apps.- Specified by:
registerin interfaceClientAppManager- Overrides:
registerin classClientAppManagerImpl- Parameters:
app- non-null- Returns:
- true if successful, false if duplicate name
unregister
Unregister with the manager. Name must be the same as that fromregister(ClientApp). Only required for apps used by other apps.- Specified by:
unregisterin interfaceClientAppManager- Overrides:
unregisterin classClientAppManagerImpl- Parameters:
app- non-null
shutdown
public void shutdown()Shut down all running client applications.getDebugCounts
public int[] getDebugCounts()Debug overview counts as {tracked, running, registered}.- Returns:
- the counts, never null
renderStatusHTML
Table of registered and running router apps with state dots.- Parameters:
out- writer to write HTML output to- Throws:
IOException- if writing to output fails
buildRows
static List<String[]> buildRows(Map<ClientApp, String[]> clients, Map<String, ClientApp> registered) Merge the tracked and registered app maps into one row set of {state, name, class, args}, sorted by name. Tracked apps report their live state and launch args; registered apps that were never tracked report "Registered" with no args. Pure, for unit tests.- Parameters:
clients- tracked apps to their launch argsregistered- all registered apps by name- Returns:
- one row per app, never null
dotClass