Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] RemoteServices: first call to getRemoteServiceReferences return nothing

Hi Scott,

I just tested the reordering and I confirm that it works fine.

Thanks a lot your efficient help

Franck

On 9/21/07, Scott Lewis <slewis@xxxxxxxxxxxxx> wrote:
Hi Franck,

I discovered the issue.  For plugin 3 (service client) your code currently has:

            clientTwo.connect(serverID, null);
            final IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
            Thread.sleep(1000);
            final IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, IConcat.class.getName(), null);
...

Because of a bug in org.eclipse.ecf.provider.remoteservices, calling 'clientTwo.getAdapter' *after* the connect call does not work as expected.  The bug assumed that registry updates would be sent to the registry replica of *newly connected* containers, so in contrast to the above, this logic works fine:

            final IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
            clientTwo.connect(serverID, null);
            Thread.sleep(1000);
            final IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, IConcat.class.getName(), null);
...

So if you can reorder these calls to call the getAdapter *before* calling connect the service reference is found and called, as you would expect.

But I consider this a bug in the current approach (requiring that people call the getAdapter before connecting), so I created this bug:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=204329

I built a fix this morning...specifically I added the mechanism/messaging to request a registry update upon the call to clientTwo.getAdapter(IRemoteServiceContainerAdapter.class).  This code was just checked in today (Fri, Sept 21), so it's only available via src code until ECF 1.2 release.  But it does work now with your original ordering (i.e. connect followed by getAdapter).

Thanks for reporting.

Scott


Franck Gasnier wrote:
 
Hi Scott,
 
On 9/20/07, Scott Lewis <slewis@xxxxxxxxxxxxx > wrote:
Hi Franck,


Franck Gasnier wrote:
I have a problem of initialization with the getRemoteServiceReferences.
I am playing with Eclipse 3.3 and ECF 1.1.

Here are my plugins :

- Plugin1 :
   - start the server in a startup extension
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       Object[] args = new Object[] { serverID };
       server = ContainerFactory.getDefault().createContainer(" ecf.generic.server", args);
  - defines the IConcat interface (the interface of the service that will be published

- Plugin2 :
  - depends on Plugin1
  - publishes a service in an action extension
       IContainer clientOne = ContainerFactory.getDefault().createContainer("ecf.generic.client");
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       clientOne.connect(serverID, null);
       IRemoteServiceContainerAdapter remoteContainerOne = (IRemoteServiceContainerAdapter) clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
       IRemoteServiceRegistration remoteServiceRegistration = remoteContainerOne.registerRemoteService(new String[] { IConcat.class.getName() }, new ConcatImpl(), null);

- Plugin3:
  - depends on Plugin1
  - in an action extension, look for the published service and call it
       IContainer clientTwo = ContainerFactory.getDefault().createContainer("ecf.generic.client");
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       clientTwo.connect(serverID, null);
       IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
       Thread.sleep (1000);
       IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, null, null);
       if (refs.length==0) {
           System.out.println("Service not found");
           return;
       }
       IRemoteService remoteService = remoteContainerTwo.getRemoteService(refs[0]);
       IConcat remoteConcat=(IConcat)remoteService.getPoxy();
       String result =  remoteConcat.concat ("Eclipse "," is cool");
       System.out.println("TEST RESULT (asynch): " + result);

If I put these 3 plugins inside 1 Eclipse, everything works fine, I can publish and call the service.

But when I put in 1 Eclipse Plugin1 and 2 and in another Eclipse Plugin1 and 3 then
the first call to the service always returns "service not found", ie getRemoteServiceReferences returns an empty array.
Then following calls works fine.

As a workaround I have added inside Plugin1 startup extension the creation of an useless client :
           ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
           IContainer client = ContainerFactory.getDefault().createContainer("ecf.generic.client");
           client.connect(serverID, null);
           IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) client.getAdapter(IRemoteServiceContainerAdapter.class);
           IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, null, null);
           client.disconnect();

Is there something that I missed ? An "init" method ? Or is it a bug ?

I'm not sure yet. 

You say that in your second client (the 'client' of the service) you make this call:

       IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, null, null);

But the getRemoteServiceReference method requires a non-null value for the second parameter...so it probably should be (and maybe is):

       IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, IConcat.getClass().getName(), null);

Actually, I'm unclear on how a call to getRemoteServiceReferences(null, null, null) could work.  The impl always returns an empty array if the second parameter is null.
 
 
I have tried both and traced the code. And this works fine. I mean if the second parameter is null then it returns all registered services.
But the first time, it is empty.
Anyway you are rigth I am looking for some IConcat services.
 

But assuming that you do have the IConcat class in the code, then your problem is something else.  You say above that the plugin 1 is started via 'startup' extension...is this the ECF startup extension or some other?  Also...you say that plugin 2 and plugin 3 are started via action extension...I assume that you always run the plugin 2 action before plugin 3 in tests.
 
 
By startup, I mean the startup from org.eclipse.ui, not the one from ECF.
This is just to prevent me from launching the server thru an action.
Doing this raizes an Exception when I launch the 2d eclipse, but I don't care for now.
I didn't yet look for a method to test if the server is already running. But that is not the point there.
 
Plugin2 and Plugin3 start when I use the actions and Eclipse stops them when I quit.
I will handle the disconnect later and the registration of the clients container later.
This is just my first cup of ECF.
 

Would you be willing to make these projects available to us? and I'll try running in my workspace to see if we can diagnose the issue further?
 
 
I attached the archive with the 3 plugins.
You just have to import them thru : Import > Existing projects
You will get the 3 plugins I was talking about.
To reproduce the problem :
- launch an eclipse with plugin1 and 2, in the menu ECF test do "publish"
- launch an eclipse with plugin1 and 3, in the menu ECF test do "call"
-> the first time you will get the message "service not found"
-> the 2d time you will get the "Eclipse is cool"
 
To enable my workaround, just uncomment in the Startup class in the earlyStartup() method the call to init().
Then you will not get the "service not found".
 
Thanks
Franck
 

Thanks,

Scott


Thanks for your help
Franck

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/ecf-dev

 

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev



_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/ecf-dev


_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev



Back to the top