Status Information
State Change Events
Logging And Audit
Status Information
The nRealmNode extends nContainer, that extends nNode
which is a subclass of Observable, so when the status
information is received for a realm node, (by default
this is every 5 seconds although it is configurable
by setting the StatusBroadcast property under the Global
Values config group) the nRealmNode will trigger the
update callback on any known Observers. For example,
if you write a class that implements the Observer interface,
it can be added as an observer as follows:
realm.addObserver(this);
Assuming 'this' is the instance of the class implementing
Observer, then the implementation of the update(Observable
obs, Object obj) will be notified that the realm
node has changed.
When regular status events are sent, the Observable
object referenced in the update method will be the realm
node that you added your observer to, and the Object
will be null.
State Change Events
When events occur on a realm node that you have added
an observer to, the Observable/Observer mechanism will
notify you of the details of that event. For example,
the following implentation of the update method of the
Observer interface demonstrates how to detect that a
new channel or queue has been created or deleted. :
public void update(Observable obs, Object obj){
if (obs instanceof nContainer) {
if (obj instanceof nLeafNode) {
nLeafNode leaf = (nLeafNode)obj;
nContainer cont = (nContainer)obs;
if (cont.findNode(leaf) == null) {
// node has been deleted
System.out.println("Node "+leaf.getName()+"
removed");
} else {
// node has been added
System.out.println("Node "+leaf.getName()+"
added");
}
}
}
}
Any changes to the realm ACL will also use the same
notification mechanism. For example, if an ACL entry
was changed for a realm, the update method would be
fired calling with the realm node object and the nACLEntry
that had been modified.
Logging and Audit
An nRealmNode allows you to asynchronously receive
realm log file entries as well as audit file entries
as they occur.
Firstly, for receiving asynchronous log file entries,
there is an interface called nLogListener which your
class must implerment. This interface defines a callback
method called report(String) that will deliver each
new log entry as a string. Once implemented, the following
call will add your log listener to the realm node:
realm.addLogListener(this);
Assuming 'this' is the instance of the class implementing
the nLogListener interface.
The following is an example of the report(String) method
implementation:
public void report(String msg) {
System.out.println("LOG "+msg);
}
Secondly, realm servers provide an audit file that
tracks object creations and deletions, acl changes,
connection attempts and failures. This information can
be very useful for tracking who has created ACL entries
for example and when they were done.
This information, as with log file entries can be asynchronously
received by implementing an interface called nAuditListener.
This interface defines a callback method called audit(nAuditEvent)
that delivers contains the details of the audit entry.
Once implemented, the following call will add your log
listener to the realm node:
realm.addAuditListener(this);
Assuming 'this' is the instance of the class implementing
the nAuditListener.
An example of how to monitor realm server log and audit
files can be found here.
For more information on the Nirvana Administration,
please see the Nirvana
API documentation, and the Nirvana
enterprise manager guide. |