Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » Remote Services Registration
Remote Services Registration [message #609278] Fri, 24 November 2006 03:04 Go to next message
Paul Woodward is currently offline Paul Woodward
Messages: 11
Registered: July 2009
Junior Member
Hi Guys,

I've been experimenting with the RemoteService example and unit test (0.9.3) and I've hit a snag...

It seems that all of the remote clients have to be created prior to registering any services in order for them to be able to obtain a reference to the service.

Here's how to show it: take all of the unit tests in RemoteServiceTest and amalgamate the funtions, in order into a single test and remote all the old test cases. You should get something similar to:

public void testAll() throws Exception {
IContainer clientOne = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
assertNotNull(clientOne);
System.out.println("TEST clientOne id=" + clientOne.getID());
IContainer clientTwo = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
assertNotNull(clientTwo);
System.out.println("TEST clientTwo id=" + clientTwo.getID());

ID serverID = IDFactory.getDefault().createStringID(GENERIC_SERVER_ID);
Object[] args = new Object[] { serverID };
IContainer server = ContainerFactory.getDefault().createContainer(GENERIC_CONTAI NER_SERVER_NAME, args);
assertNotNull(server);

clientOne.connect(serverID, null);
IRemoteServiceContainerAdapter remoteContainerOne = (IRemoteServiceContainerAdapter) clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
assertNotNull(remoteContainerOne);

clientTwo.connect(serverID, null);


IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
assertNotNull(remoteContainerTwo);

IRemoteServiceRegistration remoteServiceRegistration = remoteContainerOne.registerRemoteService(new String[] { org.eclipse.ecf.tests.remoteservice.IConcat.class.getName() }, new ConcatImpl(), null);
waitTime(2000);
System.out.println(remoteServiceRegistration.getReference(). isActive());


remoteContainerTwo.addRemoteServiceListener(new IRemoteServiceListener() {
public void handleServiceEvent(IRemoteServiceEvent event) {
System.out.println("handleServiceEvent(" + event + ")");
}
});

// THIS TEST ALWAYS BREAKS - WHY?
IRemoteServiceReference[] refsOne = remoteContainerOne.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
assertTrue(refsOne.length > 0);

IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
assertTrue(refs.length > 0);
IRemoteServiceReference remoteServiceReference = refs[0];

IRemoteService remoteService = remoteContainerTwo.getRemoteService(remoteServiceReference);
assertNotNull(remoteService);

IConcat runnable = (IConcat) remoteService.getProxy();
String result = runnable.concat("ECF ", "is cool");
System.out.println("TEST RESULT: " + result);
}

If you move the code for creating remoteContainerTwo below the remoteServiceRegistration then querying it for remote services will yield no results.

Logically this is bizarre - it's like saying all clients of remote services must exist before the remote service does - or am I doing something dumb?

The other bizarre thing is that if you query the remoteContainer in which you registered the service, then it comes back with no results either.

Thanks in advance,

Paul
Re: Remote Services Registration [message #609281 is a reply to message #609278] Fri, 24 November 2006 03:19 Go to previous messageGo to next message
Remy Suen is currently offline Remy Suen
Messages: 462
Registered: July 2009
Senior Member
Hi Paul,

Unfortunately, I'm not familiar with how the remoteservice API is
supposed to work, so I can't really address any of your other questions.

Paul Woodward wrote:
> // THIS TEST ALWAYS BREAKS - WHY?
> IRemoteServiceReference[] refsOne = remoteContainerOne.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
> assertTrue(refsOne.length > 0);

However, with regards to this test failure, can you provide us with some
additional information? Does the assertion just fail and that's it? Does
an exception get thrown? Are you using Java 1.6? The issue may be
identical to what's been reported at bug #161684.

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

Regards,
Rem
Re: Remote Services Registration [message #609283 is a reply to message #609281] Fri, 24 November 2006 04:13 Go to previous messageGo to next message
Paul Woodward is currently offline Paul Woodward
Messages: 11
Registered: July 2009
Junior Member
Hi Rem,

> Paul Woodward wrote:
> > // THIS TEST ALWAYS BREAKS - WHY?
> > IRemoteServiceReference[] refsOne =
> remoteContainerOne.getRemoteServiceReferences(null,
> org.eclipse.ecf.tests.remoteservice.IConcat.class.getN
> ame(), null);
> > assertTrue(refsOne.length > 0);
>
> However, with regards to this test failure, can you
> provide us with some
> additional information? Does the assertion just fail
> and that's it? Does
> an exception get thrown? Are you using Java 1.6? The
> issue may be
> identical to what's been reported at bug #161684.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=161684
>

No exceptions, just the assertion that fails. I'm using Java 1.5.

Cheers, Paul
Re: Remote Services Registration [message #609284 is a reply to message #609283] Fri, 24 November 2006 12:42 Go to previous messageGo to next message
Scott Lewis is currently offline Scott Lewis
Messages: 970
Registered: July 2009
Senior Member
Hi Paul,

Please file this as a bug. The reason is simply that the local access
to locally registered remoteservices (i.e. remoteContainerOne calling
getRemoteServiceReferences for a remoteservice it has registered) is not
yet implemented.

I'll address the other issues in another posting.

Scott


Paul Woodward wrote:
> Hi Rem,
>
> > Paul Woodward wrote:
> > > // THIS TEST ALWAYS BREAKS - WHY?
> > > IRemoteServiceReference[] refsOne =
> > remoteContainerOne.getRemoteServiceReferences(null,
> > org.eclipse.ecf.tests.remoteservice.IConcat.class.getN
> > ame(), null);
> > > assertTrue(refsOne.length > 0);
> >
> > However, with regards to this test failure, can you
> > provide us with some
> > additional information? Does the assertion just fail
> > and that's it? Does
> > an exception get thrown? Are you using Java 1.6? The
> > issue may be
> > identical to what's been reported at bug #161684.
> >
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=161684
> >
>
> No exceptions, just the assertion that fails. I'm using Java 1.5.
>
> Cheers, Paul
Re: Remote Services Registration [message #609286 is a reply to message #609278] Fri, 24 November 2006 12:43 Go to previous messageGo to next message
Scott Lewis is currently offline Scott Lewis
Messages: 970
Registered: July 2009
Senior Member
Hi Paul,

Paul Woodward wrote:
> Hi Guys,
>
> I've been experimenting with the RemoteService example and unit test (0.9.3) and I've hit a snag...
>
> It seems that all of the remote clients have to be created prior to registering any services in order for them to be able to obtain a reference to the service.
>
> Here's how to show it: take all of the unit tests in RemoteServiceTest and amalgamate the funtions, in order into a single test and remote all the old test cases. You should get something similar to:
>
> public void testAll() throws Exception {
> IContainer clientOne = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
> assertNotNull(clientOne);
> System.out.println("TEST clientOne id=" + clientOne.getID());
> IContainer clientTwo = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
> assertNotNull(clientTwo);
> System.out.println("TEST clientTwo id=" + clientTwo.getID());
>
> ID serverID = IDFactory.getDefault().createStringID(GENERIC_SERVER_ID);
> Object[] args = new Object[] { serverID };
> IContainer server = ContainerFactory.getDefault().createContainer(GENERIC_CONTAI NER_SERVER_NAME, args);
> assertNotNull(server);
>
> clientOne.connect(serverID, null);
> IRemoteServiceContainerAdapter remoteContainerOne = (IRemoteServiceContainerAdapter) clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
> assertNotNull(remoteContainerOne);
>
> clientTwo.connect(serverID, null);
>
>
> IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
> assertNotNull(remoteContainerTwo);
>
> IRemoteServiceRegistration remoteServiceRegistration = remoteContainerOne.registerRemoteService(new String[] { org.eclipse.ecf.tests.remoteservice.IConcat.class.getName() }, new ConcatImpl(), null);
> waitTime(2000);
> System.out.println(remoteServiceRegistration.getReference(). isActive());
>
>
> remoteContainerTwo.addRemoteServiceListener(new IRemoteServiceListener() {
> public void handleServiceEvent(IRemoteServiceEvent event) {
> System.out.println("handleServiceEvent(" + event + ")");
> }
> });
>
> // THIS TEST ALWAYS BREAKS - WHY?
> IRemoteServiceReference[] refsOne = remoteContainerOne.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
> assertTrue(refsOne.length > 0);
>
> IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
> assertTrue(refs.length > 0);
> IRemoteServiceReference remoteServiceReference = refs[0];
>
> IRemoteService remoteService = remoteContainerTwo.getRemoteService(remoteServiceReference);
> assertNotNull(remoteService);
>
> IConcat runnable = (IConcat) remoteService.getProxy();
> String result = runnable.concat("ECF ", "is cool");
> System.out.println("TEST RESULT: " + result);
> }
>
> If you move the code for creating remoteContainerTwo below the remoteServiceRegistration then querying it for remote services will yield no results.
>
> Logically this is bizarre - it's like saying all clients of remote services must exist before the remote service does - or am I doing something dumb?
>
> The other bizarre thing is that if you query the remoteContainer in which you registered the service, then it comes back with no results either.
>
> Thanks in advance,
>
> Paul
Re: Remote Services Registration [message #609288 is a reply to message #609278] Fri, 24 November 2006 12:56 Go to previous messageGo to next message
Scott Lewis is currently offline Scott Lewis
Messages: 970
Registered: July 2009
Senior Member
Hi Paul,

Sorry about the empty posting.

Paul Woodward wrote:
> Hi Guys,
>
> I've been experimenting with the RemoteService example and unit test (0.9.3) and I've hit a snag...
>
> It seems that all of the remote clients have to be created prior to registering any services in order for them to be able to obtain a reference to the service.
>
> Here's how to show it: take all of the unit tests in RemoteServiceTest and amalgamate the funtions, in order into a single test and remote all the old test cases. You should get something similar to:
>
> public void testAll() throws Exception {
> IContainer clientOne = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
> assertNotNull(clientOne);
> System.out.println("TEST clientOne id=" + clientOne.getID());
> IContainer clientTwo = ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
> assertNotNull(clientTwo);
> System.out.println("TEST clientTwo id=" + clientTwo.getID());
>
> ID serverID = IDFactory.getDefault().createStringID(GENERIC_SERVER_ID);
> Object[] args = new Object[] { serverID };
> IContainer server = ContainerFactory.getDefault().createContainer(GENERIC_CONTAI NER_SERVER_NAME, args);
> assertNotNull(server);
>
> clientOne.connect(serverID, null);
> IRemoteServiceContainerAdapter remoteContainerOne = (IRemoteServiceContainerAdapter) clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
> assertNotNull(remoteContainerOne);
>
> clientTwo.connect(serverID, null);
>
>
> IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
> assertNotNull(remoteContainerTwo);
>
> IRemoteServiceRegistration remoteServiceRegistration = remoteContainerOne.registerRemoteService(new String[] { org.eclipse.ecf.tests.remoteservice.IConcat.class.getName() }, new ConcatImpl(), null);
> waitTime(2000);
> System.out.println(remoteServiceRegistration.getReference(). isActive());
>
>
> remoteContainerTwo.addRemoteServiceListener(new IRemoteServiceListener() {
> public void handleServiceEvent(IRemoteServiceEvent event) {
> System.out.println("handleServiceEvent(" + event + ")");
> }
> });
>
> // THIS TEST ALWAYS BREAKS - WHY?
> IRemoteServiceReference[] refsOne = remoteContainerOne.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
> assertTrue(refsOne.length > 0);
>
> IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
> assertTrue(refs.length > 0);
> IRemoteServiceReference remoteServiceReference = refs[0];
>
> IRemoteService remoteService = remoteContainerTwo.getRemoteService(remoteServiceReference);
> assertNotNull(remoteService);
>
> IConcat runnable = (IConcat) remoteService.getProxy();
> String result = runnable.concat("ECF ", "is cool");
> System.out.println("TEST RESULT: " + result);
> }
>
> If you move the code for creating remoteContainerTwo below the remoteServiceRegistration then querying it for remote services will yield no results.


I think this is just another bug and should be filed as such. I suspect
the reason is that when container two is connected the remote service
registry *should* be replicated to the newly joined container (two). It
*is* being replicated when the service is registered and the two
containers are already joined, but I think it's not being replicated
properly when a new container joins AFTER the registration has occurred
(the 'late joiner' situation).


>
> Logically this is bizarre - it's like saying all clients of remote services must exist before the remote service does - or am I doing something dumb?
>
> The other bizarre thing is that if you query the remoteContainer in which you registered the service, then it comes back with no results either.

This is the 'not implemented yet' bug mentioned in previous posting.

I'll try to address these bugs this weekend Nov 25 if I have the chance.

Thanks,

Scott


>
> Thanks in advance,
>
> Paul
Re: Remote Services Registration [message #609290 is a reply to message #609284] Fri, 24 November 2006 14:44 Go to previous messageGo to next message
Scott Lewis is currently offline Scott Lewis
Messages: 970
Registered: July 2009
Senior Member
Hi Folks,

I've filed this as a bug and fixed it:

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

Note I have *not* yet filed the other bug from Paul's posting so Paul
please do that.

Also added test:

public void testGetRemoteServiceReferenceLocal() throws Exception {
IRemoteServiceReference[] refs = remoteContainerOne
.getRemoteServiceReferences(null,
org.eclipse.ecf.tests.remoteservice.IConcat.class
.getName(), null);
assertTrue(refs.length > 0);
}

In RemoteServiceTestClass.

Scott



Scott Lewis wrote:
> Hi Paul,
>
> Please file this as a bug. The reason is simply that the local access
> to locally registered remoteservices (i.e. remoteContainerOne calling
> getRemoteServiceReferences for a remoteservice it has registered) is not
> yet implemented.
>
> I'll address the other issues in another posting.
>
> Scott
>
>
> Paul Woodward wrote:
>> Hi Rem,
>>
>> > Paul Woodward wrote:
>> > > // THIS TEST ALWAYS BREAKS - WHY?
>> > > IRemoteServiceReference[] refsOne =
>> > remoteContainerOne.getRemoteServiceReferences(null,
>> > org.eclipse.ecf.tests.remoteservice.IConcat.class.getN
>> > ame(), null);
>> > > assertTrue(refsOne.length > 0);
>> > > However, with regards to this test failure, can you
>> > provide us with some > additional information? Does the
>> assertion just fail
>> > and that's it? Does > an exception get thrown? Are you using
>> Java 1.6? The
>> > issue may be > identical to what's been reported at bug #161684.
>> > > https://bugs.eclipse.org/bugs/show_bug.cgi?id=161684
>> >
>> No exceptions, just the assertion that fails. I'm using Java 1.5.
>>
>> Cheers, Paul
Re: Remote Services Registration [message #609291 is a reply to message #609288] Sat, 25 November 2006 17:45 Go to previous message
Scott Lewis is currently offline Scott Lewis
Messages: 970
Registered: July 2009
Senior Member
Hi Folks,

I filed this as bug:

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

It turns out that this was just a relatively small error in logic for
when to replicate the registry contents...it was doing it in the case of
introducing new service *after* connect, but not doing it properly upon
connection when service registration had already occurred.

Paul, if you would agree, I would ask that you would verify the fix and
then contribute the test case code and I will add it to the test cases
for remote service testing. I'll be adding to these test cases as well
(as with the all test cases), and would appreciate any test cases that
people would be willing to write (for remoteservice or other APIs).

Thanks,

Scott


Scott Lewis wrote:
> Hi Paul,
>
> Sorry about the empty posting.
>
> Paul Woodward wrote:
>> Hi Guys,
>>
>> I've been experimenting with the RemoteService example and unit test
>> (0.9.3) and I've hit a snag...
>>
>> It seems that all of the remote clients have to be created prior to
>> registering any services in order for them to be able to obtain a
>> reference to the service.
>>
>> Here's how to show it: take all of the unit tests in RemoteServiceTest
>> and amalgamate the funtions, in order into a single test and remote
>> all the old test cases. You should get something similar to:
>>
>> public void testAll() throws Exception {
>> IContainer clientOne =
>> ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
>> assertNotNull(clientOne);
>> System.out.println("TEST clientOne id=" + clientOne.getID());
>> IContainer clientTwo =
>> ContainerFactory.getDefault().createContainer(CONTAINER_CLIE NT_NAME);
>> assertNotNull(clientTwo);
>> System.out.println("TEST clientTwo id=" + clientTwo.getID());
>>
>> ID serverID =
>> IDFactory.getDefault().createStringID(GENERIC_SERVER_ID);
>> Object[] args = new Object[] { serverID };
>> IContainer server =
>> ContainerFactory.getDefault().createContainer(GENERIC_CONTAI NER_SERVER_NAME,
>> args);
>> assertNotNull(server);
>>
>> clientOne.connect(serverID, null);
>> IRemoteServiceContainerAdapter remoteContainerOne =
>> (IRemoteServiceContainerAdapter)
>> clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
>> assertNotNull(remoteContainerOne);
>>
>> clientTwo.connect(serverID, null);
>>
>>
>> IRemoteServiceContainerAdapter remoteContainerTwo =
>> (IRemoteServiceContainerAdapter)
>> clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
>> assertNotNull(remoteContainerTwo);
>>
>> IRemoteServiceRegistration remoteServiceRegistration =
>> remoteContainerOne.registerRemoteService(new String[] {
>> org.eclipse.ecf.tests.remoteservice.IConcat.class.getName() }, new
>> ConcatImpl(), null);
>> waitTime(2000);
>>
>> System.out.println(remoteServiceRegistration.getReference(). isActive());
>>
>>
>> remoteContainerTwo.addRemoteServiceListener(new
>> IRemoteServiceListener() {
>> public void handleServiceEvent(IRemoteServiceEvent event) {
>> System.out.println("handleServiceEvent(" + event + ")");
>> }
>> });
>>
>> // THIS TEST ALWAYS BREAKS - WHY?
>> IRemoteServiceReference[] refsOne =
>> remoteContainerOne.getRemoteServiceReferences(null,
>> org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
>> assertTrue(refsOne.length > 0);
>>
>> IRemoteServiceReference[] refs =
>> remoteContainerTwo.getRemoteServiceReferences(null,
>> org.eclipse.ecf.tests.remoteservice.IConcat.class.getName(), null);
>> assertTrue(refs.length > 0);
>> IRemoteServiceReference remoteServiceReference = refs[0];
>>
>> IRemoteService remoteService =
>> remoteContainerTwo.getRemoteService(remoteServiceReference);
>> assertNotNull(remoteService);
>>
>> IConcat runnable = (IConcat) remoteService.getProxy();
>> String result = runnable.concat("ECF ", "is cool");
>> System.out.println("TEST RESULT: " + result);
>> }
>>
>> If you move the code for creating remoteContainerTwo below the
>> remoteServiceRegistration then querying it for remote services will
>> yield no results.
>
>
> I think this is just another bug and should be filed as such. I suspect
> the reason is that when container two is connected the remote service
> registry *should* be replicated to the newly joined container (two). It
> *is* being replicated when the service is registered and the two
> containers are already joined, but I think it's not being replicated
> properly when a new container joins AFTER the registration has occurred
> (the 'late joiner' situation).
>
>
>>
>> Logically this is bizarre - it's like saying all clients of remote
>> services must exist before the remote service does - or am I doing
>> something dumb?
>>
>> The other bizarre thing is that if you query the remoteContainer in
>> which you registered the service, then it comes back with no results
>> either.
>
> This is the 'not implemented yet' bug mentioned in previous posting.
>
> I'll try to address these bugs this weekend Nov 25 if I have the chance.
>
> Thanks,
>
> Scott
>
>
>>
>> Thanks in advance,
>>
>> Paul
Previous Topic:DataShareRMI
Next Topic:Contributing file transfers
Goto Forum:
  


Current Time: Thu Aug 21 20:07:38 EDT 2014

Powered by FUDForum. Page generated in 0.01797 seconds