public class EventManager extends Object implements Runnable
DefaultEventExit
Modifier and Type | Method and Description |
---|---|
void |
addHistoryListener(EventHistoryListener listener)
Adds a listener for history events.
|
void |
dispose()
Requests and waits for termination of the event manager.
|
long |
getEventFileLength()
Gets the current event file length.
|
String |
getEventFileName()
Gets the current event file name.
|
static EventManager |
getEventManager()
Gets the single instance of the event manager.
|
EventMessengerInterface |
getEventMessenger(String messengerName)
Get an eventMessenger.
|
ServerEvent[] |
getHistory()
Gets the history of events.
|
ServerEvent[] |
getHistory(EventHistoryListener listener)
Gets the history of events and adds a listener for history events.
|
static int |
getMaxHistoryCount()
Get the event queue max history count for backlog of events.
|
long |
getMaximumFileSize()
Gets the maximum file size of a trace file.
|
boolean |
loadMessenger(String newEvm,
String oldEvm)
Loads a single event messenger.
|
void |
loadMessengers()
Load eventMessengers specified in the configuration file
(default SERVER.INI).
|
static void |
logEvent(ClientConnectionData clientConnectionData,
int eventID)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(ClientConnectionData clientConnectionData,
int eventID,
int appendedTextID)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(ClientConnectionData clientConnectionData,
int eventID,
String appendedText)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(ClientConnectionData clientConnectionData,
String event,
int eventClass)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(int eventID)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(int eventID,
int appendedTextID)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(int eventID,
String appendedText)
Queues this event for processing by the event manager read thread.
|
static void |
logEvent(String event,
int eventClass)
Queues this event for processing by the event manager read thread.
|
static int |
performEventCommand(String command)
Processes a command either from a command line, (remote) console or
event filter commands in SERVER.INI.
|
static int |
performEventCommand(String eventID,
int include,
long[] clientIDs)
Processes a single eventID specification.
|
void |
removeHistoryListener(EventHistoryListener listener)
Removes a listener for history events.
|
boolean |
rotateInformation()
Rotates the event information if stored in e.g.
|
void |
run()
The thread that reads the event queue.
|
boolean |
setMaximumFileSize(long maxSize)
Sets the maximum file size of a trace file.
|
public static int getMaxHistoryCount()
public static EventManager getEventManager()
public void loadMessengers()
public EventMessengerInterface getEventMessenger(String messengerName)
messengerName
- the messenger ID name.public boolean loadMessenger(String newEvm, String oldEvm)
newEvm
- The name of the event messenger.oldEvm
- The name of an old event messenger to replace with the new one.
Set this parameter to null
if nold event messenger.true
if the event messenger was loaded successfully,
false
otherwise.public boolean rotateInformation()
Note that the methods in this interface can be called from different
threads, so the implementing code may have to be e.g. synchronized
.
true
for success or false
for failure.public String getEventFileName()
public long getEventFileLength()
public boolean setMaximumFileSize(long maxSize)
public long getMaximumFileSize()
public static int performEventCommand(String command) throws ParseException, NumberFormatException
. EventFilter --+--+-- ALL --+-- [INCLUDE:event_id] -- [EXCLUDE:event_id] -- [DEFAULT:event_id] . | | | . | +-- client_id --+ . | | . +----- , -----------+where client_id can be a comma-separated (no spaces in between) list of several client_ids,
and event_id is a comma-separated list (no spaces in between) of eventIDs as defined in SERVER.PHM and/or a range of eventIDs and/or using the '*' wildcard to accept any eventID starting with the text preceeding the '*'.
To specify all events, use the event range string "*-*".
Note that the command "EventFilter ALL DEFAULT:nnn" will never return other values than zero, because the "ALL" indicates the default setting for all clients.
ParseException
- When the command in SERVER.INI are invalid.NumberFormatException
- When a clientID is wrong.public static int performEventCommand(String eventID, int include, long[] clientIDs)
The eventID is an eventID as defined in SERVER.PHM or a range of eventIDs and/or using the '*' wildcard to accept any eventID starting with the text preceding the '*'. The range separator is '-'.
The value "include" must be zero or one for a global filter and can be zero=exclude, one=include, 2=default (use global filter).
public void dispose()
public static void logEvent(int eventID)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
Note: Don't use this method if there is a client connection, only use it for the server daemon.
public static void logEvent(int eventID, int appendedTextID)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
Note: Don't use this method if there is a client connection, only use it for the server daemon.
public static void logEvent(int eventID, String appendedText)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
Note: Avoid using this method if there is a client connection, only use it for the server daemon. The clientConnectionData is retrieved from the thread it is derived from ServerThread.
public static void logEvent(String event, int eventClass)
The event class is 1-4 (see EventID.EVENTCLASS_*).
Note: Don't use this method if there is a client connection, only use it for the server daemon.
public static void logEvent(ClientConnectionData clientConnectionData, int eventID)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
public static void logEvent(ClientConnectionData clientConnectionData, int eventID, int appendedTextID)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
public static void logEvent(ClientConnectionData clientConnectionData, int eventID, String appendedText)
Skips logging the event if this is not required. Uses the system default setting if no ClientConnectionData is not specified or cannot be found from the ServerThread (derived of Thread) instance.
public static void logEvent(ClientConnectionData clientConnectionData, String event, int eventClass)
public void addHistoryListener(EventHistoryListener listener)
listener
- A history listener to register. This listener must implement the
EventHistoryListener
interface.public void removeHistoryListener(EventHistoryListener listener)
listener
- The history listener that should be unregistered.
The listener must implement the EventHistoryListener
interface.public final ServerEvent[] getHistory()
public final ServerEvent[] getHistory(EventHistoryListener listener)
This method can be used when a new history listener should be registered, and at the same time should retrieve all server events in the history list. This is done by the server-admin's event viewer, that will display everything in the history list, and at the same time it should get every new event that occurs.
listener
- A history listener to register. This listener must implement the
EventHistoryListener
interface.public void run()
isDisposed
flag is true and the queue empty.
When the thread is activated, and there are items in the queue, the first event on the queue will be removed, and passed on to the server event user exit.
After that the event will be placed in the history list. If the history list has reached the max count, the oldest item will first be removed.
If there are any registered Event Messengers, the event will be passed on to them.
Finally, if there are no more events in the queue, and the
isDisposed
flag still is not set, then the thread will
wait for the next event.
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.