Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-25-2004
moatas moatas is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 7
Registry and Querying

I have been trying to write an example of querying for objects based on type. I have an icepackregistry running allowing dynamic registration. I can successfully register servers with an AdapterId, and have clients connect via the adapterid using indirect binding.

But when I do the following:

query = QueryPrxHelper.checkedCast(communicator.stringToPr oxy("IcePack/Query"));

query object is good

but

query.findObjectByType("::Ice::Object");

always throws the following:

query = IcePack.QueryPrxHelper@b7d3ed4a
IcePack.ObjectNotExistException
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at IceInternal.BasicStream$DynamicUserExceptionFactor y.createAndThrow(BasicStream.java:1770)
at IceInternal.BasicStream.throwException(BasicStream .java:1404)
at IcePack._QueryDelM.findObjectByType(_QueryDelM.jav a:122)
at IcePack.QueryPrxHelper.findObjectByType(QueryPrxHe lper.java:99)
at IcePack.QueryPrxHelper.findObjectByType(QueryPrxHe lper.java:84)
at playground.ServiceLookup.getServiceByType(ServiceL ookup.java:51)
at playground.ServiceLookup.main(ServiceLookup.java:5 6)

I switched gears and deployed the IcePack demo to an IcePack node. Contacting this registry actually works.

So my question is this. To successfully query a registry, does the service have to be published to an Icepack node? Can you not just have a registry running, have the services add themselves othe registry, then use a client to lookup the service by type?

Thanks!

James Birchfield
Reply With Quote
  #2 (permalink)  
Old 10-25-2004
vsonnathi vsonnathi is offline
Registered User
 
Name: Venkat Ramana
Organization: Amazon.com
Project: Prototype
 
Join Date: May 2004
Posts: 39
Hi,

The type here refers to the type in the Identity (id, type) and not that of the Object.

thanks,
--Venkat.
Reply With Quote
  #3 (permalink)  
Old 10-25-2004
moatas moatas is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 7
Understood. The code works fine after I use the admin tool to either deploy an application, or add an object with the appropriate endpoints. So this leads me to believe that the query functionality only works when things have been deployed using the admin interface, and services that register adapterids do not automatically qualify.

Birch
Reply With Quote
  #4 (permalink)  
Old 10-25-2004
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Welcome to the forum!

The findObjectById and findObjectByType query operations can only be used to find objects that were explicitly registered with the registry. This usually occurs when you've deployed an application that advertises well-known objects, but it could also be done by calling addObject directly on the IcePack::Admin interface.

In addition, the findObjectByType operation is not polymporphic. In other words, passing "::Ice::Object" as the type would only return an object that was explicitly registered with that type id. IcePack does not ask each object whether it implements the given id.

Take care,
- Mark
Reply With Quote
  #5 (permalink)  
Old 10-25-2004
moatas moatas is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 7
Thanks. That is what I needed to know.

Given that, how would I go about doing this in a programmatic way if I did not want to deploy the service as an IcePack application like the demo?

Taking the hello demo into acount, can you show how this would get deployed?

Ice.Object hello = new HelloI();
Ice.Identity id = Ice.Util.stringToIdentity("hello");
adapter.add(hello, id);
adapter.activate();

I fI get an AdminPrx handle, I cannot just do admin.addObject(hello) because it is not an ObjectPrx. Do you happen to have an example of this type of functionality? Or am I going about it all wrong?

Thanks!

Followup: I did get the admin interface to work if i did this:

admin.addObject(communicator.stringToProxy("hello: tcp -h 192.168.0.200 -p 11000"));

after I call activate on the adapter that created the object.

Last edited by moatas : 10-25-2004 at 05:34 PM.
Reply With Quote
  #6 (permalink)  
Old 10-25-2004
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
The call to ObjectAdapter::add returns a proxy, so that is the easiest way to get one. Your example would change like this:
Code:
IcePack.AdminPrx adminPrx = ...
Ice.Object hello = new HelloI();
Ice.Identity id = Ice.Util.stringToIdentity("hello");
Ice.ObjectPrx proxy = adapter.add(hello, id);
adapter.activate();
adminPrx.addObject(proxy);
- Mark
Reply With Quote
  #7 (permalink)  
Old 10-25-2004
moatas moatas is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 7
Doh! Was just about to post that discovery!!! Thanks for the help.

Now to the next phase of this problem. I am trying to determine the best approach for scaling up the number of objects available. If I write a number adding server and want to deploy 10 of them to different machines, how do I register them?

My hope was I would register them all with he same adapter info. If that were the case, then I was hoping the registry would return me the next available one in a round robin type fashion. But I suspect i would get an ObjectExistsException on the second one. Would I just assign unique id to them to keep them from clashing? I get this working initially by doing this.

Can you provide any insight on the best way to acheive this scenario?

Thanks!

Birch
Reply With Quote
  #8 (permalink)  
Old 10-25-2004
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
IcePack doesn't currently support replication, but this is something we're considering for a future release.

If you want a randomized result, you could register several objects with the same type (each with unique ids) and then call Admin::findObjectByType. If IcePack finds multiple matches, it returns a randomly-selected one.

Hope that helps,
- Mark
Reply With Quote
  #9 (permalink)  
Old 10-25-2004
moatas moatas is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 7
This is what i will do for now.

Thanks for all he help!

Birch
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ice Registry blocking on restart Steffen Help Center 14 03-31-2006 10:17 AM
icepack registry redundancy gminorcoles Help Center 3 07-12-2005 05:27 AM
Querying the Object Adapter endpoints aroan Help Center 6 12-27-2004 01:46 PM
Querying Frozen Objects felixcollins Help Center 0 10-28-2004 11:27 PM
icepack registry problems wolfram Help Center 4 09-01-2004 09:45 AM


All times are GMT -4. The time now is 05:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.