|
|
|
|||||
|
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 |
|
|||||
|
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 |
|
|||||
|
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. |
|
||||||
|
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);
|
|
|||||
|
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 |
|
||||||
|
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 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |