Rawlings, Bill A
2009-01-19 19:16:46 UTC
Ok guys, I've been working on an application to start, monitor and stop
the River core services (LUS, TM, Space, Class Server).
I'm using an event driven model using Lookup Cache and
ServiceDiscoveryListener.
There is a ServiceDiscoveryManager that is started to set up the
LookupCaches
mgr = new
LookupDiscoveryManager(DiscoveryGroupManagement.ALL_GROUPS,
null, // unicast locators
null); // DiscoveryListener
sdm = new ServiceDiscoveryManager(mgr, new LeaseRenewalManager());
I was having trouble stopping the LUS. I had originally used the SDM
directly with a DiscoveryListener, but kept getting uncatchable
exceptions from the SDM when I killed the LUS. I can't terminate the
SDM in this app (that stops the exception if you do), because I want to
monitor the system as long as the app is running.
So, I tried to use a LookupCache for the ServiceRegistrar...
classes = new Class[] {ServiceRegistrar.class};
template = new ServiceTemplate(null,
classes,
null);
lusCache = sdm.createLookupCache(template, null, lusMonitor);
I use one for the space and one the TM as well.
In the lusMonitor code I have this...
public void serviceAdded(ServiceDiscoveryEvent evt)
{
ServiceItem si = evt.getPostEventServiceItem();
Object service = si.service;
if(service instanceof ServiceRegistrar)
{
sp.setStatusRunning();
}
}
public void serviceRemoved(ServiceDiscoveryEvent
serviceDiscoveryEvent)
{
sp.setStatusStopped();
}
And the code that kills the LUS is in another class...
public void stopLUS()
{
LookupCache cache = csm.getLUSCache();
ServiceItem si = cache.lookup(null);
Object lusProxy = si.service;
if(lusProxy instanceof Administrable)
{
try
{
Object admin = ((Administrable)lusProxy).getAdmin();
DestroyAdmin da = (DestroyAdmin)admin;
cache.discard(si);
da.destroy();
}
catch(Exception ex)
{
System.out.println("Error getting LUS DestroyAdmin");
ex.printStackTrace();
}
}
}
Ok, so, when the LUS starts, the ServiceAdded method in the
ServiceDiscoveryListener (lusMonitor) is quickly invoked.
When the LUS is killed, it takes about 10 minutes for that event to be
fired. The LUS is dead, dead, dead, I assume it has been discarded from
the LookupCache.
This works almost instantly for the space and TM, but it looks like a
lease expiration or something is holding up the discard event for the
LUS.
Any ideas on how to get around this?
BAR
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to ***@java.sun.com
the River core services (LUS, TM, Space, Class Server).
I'm using an event driven model using Lookup Cache and
ServiceDiscoveryListener.
There is a ServiceDiscoveryManager that is started to set up the
LookupCaches
mgr = new
LookupDiscoveryManager(DiscoveryGroupManagement.ALL_GROUPS,
null, // unicast locators
null); // DiscoveryListener
sdm = new ServiceDiscoveryManager(mgr, new LeaseRenewalManager());
I was having trouble stopping the LUS. I had originally used the SDM
directly with a DiscoveryListener, but kept getting uncatchable
exceptions from the SDM when I killed the LUS. I can't terminate the
SDM in this app (that stops the exception if you do), because I want to
monitor the system as long as the app is running.
So, I tried to use a LookupCache for the ServiceRegistrar...
classes = new Class[] {ServiceRegistrar.class};
template = new ServiceTemplate(null,
classes,
null);
lusCache = sdm.createLookupCache(template, null, lusMonitor);
I use one for the space and one the TM as well.
In the lusMonitor code I have this...
public void serviceAdded(ServiceDiscoveryEvent evt)
{
ServiceItem si = evt.getPostEventServiceItem();
Object service = si.service;
if(service instanceof ServiceRegistrar)
{
sp.setStatusRunning();
}
}
public void serviceRemoved(ServiceDiscoveryEvent
serviceDiscoveryEvent)
{
sp.setStatusStopped();
}
And the code that kills the LUS is in another class...
public void stopLUS()
{
LookupCache cache = csm.getLUSCache();
ServiceItem si = cache.lookup(null);
Object lusProxy = si.service;
if(lusProxy instanceof Administrable)
{
try
{
Object admin = ((Administrable)lusProxy).getAdmin();
DestroyAdmin da = (DestroyAdmin)admin;
cache.discard(si);
da.destroy();
}
catch(Exception ex)
{
System.out.println("Error getting LUS DestroyAdmin");
ex.printStackTrace();
}
}
}
Ok, so, when the LUS starts, the ServiceAdded method in the
ServiceDiscoveryListener (lusMonitor) is quickly invoked.
When the LUS is killed, it takes about 10 minutes for that event to be
fired. The LUS is dead, dead, dead, I assume it has been discarded from
the LookupCache.
This works almost instantly for the space and TM, but it looks like a
lease expiration or something is holding up the discard event for the
LUS.
Any ideas on how to get around this?
BAR
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to ***@java.sun.com