cz.cuni.amis.pogamut.base.utils.logging
Class NetworkLogManager

Package class diagram package NetworkLogManager
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.logging.NetworkLogManager

public class NetworkLogManager
extends Object

A class used for network logging of agents.

It is a singleton which accepts logs from agents of one JVM and publishes them on certain port, where clients may accept them.

Author:
Pyroh, Jimmy

Field Summary
static long NETWORK_FLUSH_PERIOD_MILLIS
          How often the logs are flushed to the socket (value < 100 results in unacceptable throughput).
static long NETWORK_LOG_MANAGER_SOCKET_TIMEOUT_MILLIS
          How long do we wait for the agent-id before we drop the connection.
protected  cz.cuni.amis.pogamut.base.utils.logging.NetworkLogManager.ServerWorker serverWorker
           
protected  Thread serverWorkerThread
          Thread of the server worker.
static Charset USED_CHARSET
          Charset that is used by the NetworkLogManager to send logs over the socket.
 
Method Summary
 void addAgent(cz.cuni.amis.utils.token.IToken agent)
          Initializes logging for the 'agent'.
static LogCategory getLog()
          Returns a logger that the NetworkLogManager is using.
 String getLoggerHost()
           
 int getLoggerPort()
           
static NetworkLogManager getNetworkLogManager()
           
 boolean isRunning()
          Whether this instance is active, i.e., it was not NetworkLogManager#shutdown().
 void kill()
          Method called from DefaultPogamutPlatform.close() to shutdown the network logging, terminating its thread to let JVM die gracefully.
 void processLog(NetworkLogEnvelope record, cz.cuni.amis.utils.token.IToken agent)
          A method called from NetworkLogPublisher when a log is to be published.
 void removeAgent(cz.cuni.amis.utils.token.IToken agent)
          Removes an agent from the manager - stops accepting its logs, closes sockets where its logs are being sent etc...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USED_CHARSET

public static final Charset USED_CHARSET
Charset that is used by the NetworkLogManager to send logs over the socket.

Initialized to "UTF-8" as default.


NETWORK_FLUSH_PERIOD_MILLIS

public static final long NETWORK_FLUSH_PERIOD_MILLIS
How often the logs are flushed to the socket (value < 100 results in unacceptable throughput).

Initialized to 200 millis;

See Also:
Constant Field Values

NETWORK_LOG_MANAGER_SOCKET_TIMEOUT_MILLIS

public static final long NETWORK_LOG_MANAGER_SOCKET_TIMEOUT_MILLIS
How long do we wait for the agent-id before we drop the connection.

Initialized to 1000 millis.

See Also:
Constant Field Values

serverWorker

protected cz.cuni.amis.pogamut.base.utils.logging.NetworkLogManager.ServerWorker serverWorker

serverWorkerThread

protected Thread serverWorkerThread
Thread of the server worker.

Method Detail

getNetworkLogManager

public static NetworkLogManager getNetworkLogManager()
Returns:
instance of NetworkLogManager, if called for the first time, creates an instance, before returning it.

isRunning

public boolean isRunning()
Whether this instance is active, i.e., it was not NetworkLogManager#shutdown().

Returns:
whether the manager is running, i.e., accepting new connections and publishing logs

kill

public void kill()
Method called from DefaultPogamutPlatform.close() to shutdown the network logging, terminating its thread to let JVM die gracefully.

YOU DO NOT PROBABLY WANT TO CALL THIS METHOD MANUALLY!!!

But if you do, it will shutdown all sockets and the worker, but it will start it up again if there is any agent will wish to log something again. Therefore it is a good idea to call the shutdown after all Pogamut's agents are stopped/killed (i.e., dead).


getLoggerPort

public int getLoggerPort()
Returns:
port on which the serverSocket is listening or -1 if the socket is not initialized (i.e., there is no logging agent registered inside the manager).

getLoggerHost

public String getLoggerHost()
Returns:
host where we're listening for logging client or null if the socket is not initialized (i.e., there is no logging agent regist9ered inside the manager).

addAgent

public void addAgent(cz.cuni.amis.utils.token.IToken agent)
Initializes logging for the 'agent'.

Parameters:
agent -

removeAgent

public void removeAgent(cz.cuni.amis.utils.token.IToken agent)
Removes an agent from the manager - stops accepting its logs, closes sockets where its logs are being sent etc...

Parameters:
agent - The agent whose logging is to be stopped.

processLog

public void processLog(NetworkLogEnvelope record,
                       cz.cuni.amis.utils.token.IToken agent)
A method called from NetworkLogPublisher when a log is to be published.

Parameters:
record - The envelope containing informations to be published
id - Who has sent the log.

getLog

public static LogCategory getLog()
Returns a logger that the NetworkLogManager is using.

Returns:


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.