String[] RNAME=({“nsp://127.0.0.1:9000”});
nSessionAttributes nsa=new nSessionAttributes(RNAME);
nServiceFactory factory = new nServiceFactory( nsa
);
nRealmNode realm = new nRealmNode(nsa);
Nirvana namespace
Access to resources on a Nirvana realms, or indeed
objects in a multi Nirvana realm server namespace, is
based on a simple tree structure, where the nRealmNode
is the root of the tree. All nodes within the tree are
subclasses of a base class nNode. From the
root, it is possible to obtain references to all child
nodes. Child nodes may be other realm nodes, containers
(folders containing other realms, channels etc), channels,
queues and
P2P services.
For example, to obtain an enumeration of all child
nodes within a realm node, simply call the following:
Enumeration children = realm.getNodes();
From this enumeration you can then perform operations
on the child nodes. For example, if you have a realm
with 1 channel and 1 queue, and wanted to find the number
of events currently on each, the following code would
do that:
Example: Finding out how many events
are on a channel / queue
while (children.hasMoreElements()) {
nNode child = (nNode)children.nextElement();
if (child instanceof nLeafNode) {
nLeafNode leaf = (nLeafNode)child;
System.out.println("Leaf node contains "+leaf.getCurrentNumberOfEvents());
}
}
The namespace structure is dynamic and is managed asynchronously
for you, so as and when objects are created, deleted
modified, stopped or started, the namespace will manage
those state changes and keep the structure up to date
automatically.
Management / Configuration / Security
As well as the namespace nodes, there are also other
objects that can be obtained from the nodes but which
are not part of the namespace tree structure.
For example, from an nRealmNode it
is possible to obtain the following objects:
nClusterNode - The cluster node
that this realm may be part of, allowing the administration
of Nirvana realm clusters
nACL - The realm
acl object, allowing control of the ACL
permissions
nInterfaceManager - The realm interface
manager, allows me to add, remove, stop, start
interfaces on a realm
nSchedulerManager - the scheduler
manager allows me to control scheduled
tasks on the realm
nConfigGroup - an enumeration of
these corresponds to all
configuration and tuning parameters for a given
realm.
From an nLeafNode which could be a channel or a queue,
the following objects are available:
nACL - The leaf node acl object,
allows me to control acl permissions
for channels and queues
nJoinInfo - all
join information associated with a channel or queue
Monitoring
As well access to the channel resources as described
above, there are also many monitoring tools available
to developers that provide information asynchronously
as and and when events occur on a realm. This can be
extermely useful in ongoing real time management of
one or more Nirvana Realm servers.
For example, for a realm node you can provide listeners
for the following :
Connections - get notified
as new connections to the realm occur, showing
connection information
Creation / Deletions / Stop / Start
- get notified when new
objects are created, deleted, modifed, stopped or
started (for example new channels being created,
acls being changed etc)
State Changes - get notified when
changes occur
to any of the objects in the namespace, such as
events being published / consumed. All updates are
asynchronously received from the realm server and
the API manages those changes for you.
Audit / Logging - when security or
state changes occur, get notifed of audit events,
as well as remotely receiving log file information
from the server.
The following sections in
this guide will work through in more detail, each of
what has been discussed above. |