More odd behaviour
"Rawlings, Bill A" <[email protected]> Mon, 19 Jan 2009 12:16:46 -0700
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--Boundary_(ID_J+3epwMO7AdRJrbmhFcxeQ)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7BIT
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 [email protected]
--Boundary_(ID_J+3epwMO7AdRJrbmhFcxeQ)
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7BIT
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Ok guys, I’ve been working on an application to start,
monitor and stop the River core services (LUS, TM, Space, Class
Server). <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I’m using an event driven model using Lookup Cache and
ServiceDiscoveryListener.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>There is a ServiceDiscoveryManager that is started to set up
the LookupCaches<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> mgr = new LookupDiscoveryManager(DiscoveryGroupManagement.ALL_GROUPS,<o:p></o:p></p>
<p class=MsoNormal>
null, // unicast locators<o:p></o:p></p>
<p class=MsoNormal>
null); // DiscoveryListener<o:p></o:p></p>
<p class=MsoNormal> sdm = new
ServiceDiscoveryManager(mgr, new LeaseRenewalManager());<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>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.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>So, I tried to use a LookupCache for the ServiceRegistrar…<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> classes = new Class[]
{ServiceRegistrar.class};
<o:p></o:p></p>
<p class=MsoNormal> template = new
ServiceTemplate(null, <o:p></o:p></p>
<p class=MsoNormal>
classes, <o:p></o:p></p>
<p class=MsoNormal>
null); <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> lusCache = sdm.createLookupCache(template,
null, lusMonitor);<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I use one for the space and one the TM as well.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>In the lusMonitor code I have this…<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> public void serviceAdded(ServiceDiscoveryEvent evt)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> ServiceItem si =
evt.getPostEventServiceItem();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> Object service = si.service;<o:p></o:p></p>
<p class=MsoNormal> if(service instanceof ServiceRegistrar)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> sp.setStatusRunning();<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> public void serviceRemoved(ServiceDiscoveryEvent
serviceDiscoveryEvent)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> sp.setStatusStopped();<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>And the code that kills the LUS is in another class…<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> public void stopLUS()<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> LookupCache cache = csm.getLUSCache();<o:p></o:p></p>
<p class=MsoNormal> ServiceItem si = cache.lookup(null);<o:p></o:p></p>
<p class=MsoNormal> Object lusProxy = si.service;<o:p></o:p></p>
<p class=MsoNormal> if(lusProxy instanceof Administrable)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> try<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> Object admin =
((Administrable)lusProxy).getAdmin();<o:p></o:p></p>
<p class=MsoNormal> DestroyAdmin da =
(DestroyAdmin)admin;<o:p></o:p></p>
<p class=MsoNormal>
cache.discard(si); <o:p></o:p></p>
<p class=MsoNormal> da.destroy(); <o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> catch(Exception ex)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal>
System.out.println("Error getting LUS DestroyAdmin");<o:p></o:p></p>
<p class=MsoNormal>
ex.printStackTrace();<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Ok, so, when the LUS starts, the ServiceAdded method in the
ServiceDiscoveryListener (lusMonitor) is quickly invoked.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>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.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>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.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Any ideas on how to get around this?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>BAR<o:p></o:p></p>
</div>
</body>
</html>
--------------------------------------------------------------------------
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 [email protected]
--Boundary_(ID_J+3epwMO7AdRJrbmhFcxeQ)--