Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » Problems with ZooDiscovery(ZooKeeper discovery never returns the registered service info)
Problems with ZooDiscovery [message #1513458] Tue, 16 December 2014 15:04 Go to next message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
I managed to use the ECF generic server to run an OSGi remote service. This works fine, even when client and server are located on different machines.

Now I want to use ZooKeeper as a centralized service registry as described in wiki.eclipse.org/Zoodiscovery

My problem is now, that the IDiscoveryLocator on the client side never returns any services. I debugged the code and found the following situation:

ZooDiscovery runs on the client in a separate thread and gets the services from ZooKeeper. This is done in org.eclipse.ecf.provider.zookeeper.node.internal.NodeReader.processResult(); also a log is written. The service info is stored in org.eclipse.ecf.provider.zookeeper.node.internal.ReadRoot.discoverdServices

The IDiscoveryLocator (implemented by org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainer) delegates to org.eclipse.ecf.provider.zookeeper.node.internal.WatchManager.getAllKnownServices(), but this map is always empty.

My questions is: how are WatchManager and ReadRoot connected?

I attached logs for ZooKeeper, server and client.
In the client log you can see a line with "Service Discovered" in it; this shows that the client thread got the service information from ZooKeeper.

I'm using Luna Service Release 1 (4.4.1) with Java 8 and ECF 3.9.0

Thank you!
  • Attachment: client.log
    (Size: 3.90KB, Downloaded 313 times)
  • Attachment: server.log
    (Size: 3.53KB, Downloaded 351 times)
  • Attachment: zookeeper.log
    (Size: 5.79KB, Downloaded 364 times)
Re: Problems with ZooDiscovery [message #1513475 is a reply to message #1513458] Tue, 16 December 2014 15:17 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Robert,

What is not working? It looks like the service is discovered and published in the local registry. All you have to do is to consume it. What do you want to do with the IDiscoveryLocator? You don't have to mess around with the internals of ECF. It should all be transparent.

Make sure the ecf distribution bundle is started in both runtimes.

Cheers,

Wim
Re: Problems with ZooDiscovery [message #1513508 is a reply to message #1513475] Tue, 16 December 2014 15:53 Go to previous messageGo to next message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
Hello Wim!

I'm following the Zoodiscovery wiki.
It looks like, that the IDiscoveryAdvertiser works as described.

Do you know an easier way to use ZooKeeper? Or some example code?
BTW I'm not using DS.

Yours, Robert

Re: Problems with ZooDiscovery [message #1513572 is a reply to message #1513475] Tue, 16 December 2014 17:03 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hello Robert,

I should totally revisit that page!! At least we should make clear that the "inner concepts" are for people that want to tinker with the gory details from the past. This is not you.

This is how you must use ECF remote services with zoodiscovery

1. You start your server runtime with -Dzookeeper.autoStart (or use our public server, see below)
2. Start your client runtime with -Dzookeeper.autoStart and -Dzoodiscovery.flavor=zoodiscovery.flavor.centralized=SET.ZOODISCOVERY.SERVER.IP.HERE
3. You register a service with the correct remoting properties [2]

That should be it. Everything else is done automatically by ECF.

We have got a public zoodiscovery server running here:

-Dzoodiscovery.flavor=zoodiscovery.flavor.centralized=disco.ecf-project.org
-Dzoodiscovery.clientPort=2181

If you get serious then you should run your own dedicated zookeeper server [1]

Cheers,

Wim

[1] https://github.com/ECF/ZooServer

[2] The remoting properties are very important. For the generic server they are:
pinProps.put("service.exported.interfaces", "*"); // picked up by ECF as a service to be remoted
pinProps.put("service.exported.configs", "ecf.generic.server");
pinProps.put("ecf.generic.server.port", "3288"); // The port where the generic server can be reached (FIREWALL!!!)
pinProps.put("ecf.generic.server.hostname", InetAddress.getLocalHost().getHostAddress()); // this is where the server can be reached from other hosts (NOT 127.0.0.1 !!!)

Re: Problems with ZooDiscovery [message #1513578 is a reply to message #1513572] Tue, 16 December 2014 17:07 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Example to publish a service without DS and the properties mentioned above.

https://github.com/wimjongman/eggclient/blob/master/com.remainsoftware.egg.core/src/com/remainsoftware/egg/core/OSGiUtil.java
Re: Problems with ZooDiscovery [message #1514343 is a reply to message #1513572] Wed, 17 December 2014 08:07 Go to previous messageGo to next message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
Thank you for the quick answer!

It still doesn't work. It looks like that no communication to the ZooKeeper sever is running.

My client a is a RCP application with dependencies to org.eclipse.ecf.server.generic and org.eclipse.ecf.provider.zookeeper. I set all Java properties in the launch configuration as described by you. All applications run on my local machine and I hardcoded my machine name everywhere Razz

Do I need some startup code for the ZooKeeper provider?

Is there a way to find out if "ecf.generic.server" and ZooDiscovery are up and running?

[Updated on: Wed, 17 December 2014 15:51]

Report message to a moderator

Re: Problems with ZooDiscovery [message #1515735 is a reply to message #1514343] Thu, 18 December 2014 10:21 Go to previous messageGo to next message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
I figured out that the bundles org.eclipse.ecf.remoteservice and org.eclipse.ecf.server.generic are not started, when running as a RCP application. So I added the following lines to the activator of my applications:
Platform.getBundle("org.eclipse.ecf.remoteservice").start();
Platform.getBundle("org.eclipse.ecf.server.generic").start();
Platform.getBundle("org.eclipse.ecf.provider.zookeeper").start();

Now the bundles are started (checked with a breakpoint in its activators), but still the generic server is not running (checked by trying to connect to it).

I use the following code to register my service:
Dictionary<String, String> props = new Hashtable<>();
props.put("service.exported.interfaces", "*");
props.put("service.exported.configs", "ecf.generic.server");
props.put("ecf.generic.server.hostname", "hostname_of_my_local_machine");
props.put("ecf.generic.server.port", "3282");
props.put("ecf.generic.server.path ", "/server");
ServiceRegistration<MyService> reg = bundleContext.registerService(
    MyService.class, new MyServiceImpl(), props);


The ECF generic server works in a RCP application (without manually starting any bundles), if I manually create a ServiceTracker, a IContainer and a IRemoteServiceContainerAdapter (see github.com/ECF/ECF-Examples/tree/master/org.eclipse.ecf.examples.remoteservices.generic.host).
But I was not able to use ZooKeeper with that approach.

Any ideas?
Re: Problems with ZooDiscovery [message #1517305 is a reply to message #1515735] Fri, 19 December 2014 12:03 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Robert,

With discovery there is no need to do this manual stuff.

did you add:

-Dzookeeper.autoStart
-Dzoodiscovery.flavor=zoodiscovery.flavor.centralized=SET.ZOODISCOVERY.SERVER.IP.HERE

Please disable both firewalls to see if this is the issue.

I need to see your console logs to tell you anything. You should see that zookeeper is started and connected to the server and that is sees and publish services. Is the ECF distribution bundle started?


Cheers,

Wim
Re: Problems with ZooDiscovery [message #1517329 is a reply to message #1517305] Fri, 19 December 2014 12:23 Go to previous messageGo to next message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
The properties are set.
No ZooKeeper or ECF logs, no connection to the ZooKeeper server.
No firewall.

I know that neither the ECF generic server, nor the ZooKeeper client is working. This is why I tried to start them by starting the bundles by hand. The bundles are running, but not the "real" service stuff.

Did you try this ever with a RCP application?
All examples I found are using DS or are working with ServiceTracker, IContainer and IRemoteServiceContainerAdapter directly. This is also what I'm doing now and it works, but without ZooKeeper.

If this gets too complicated, I will use ECF generic server "by hand" and find some solution for getting the right URI for my services.

Re: Problems with ZooDiscovery [message #1517633 is a reply to message #1517329] Fri, 19 December 2014 16:43 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Yes I have used this with an RCP applications. Can you post your code?
Re: Problems with ZooDiscovery [message #1519422 is a reply to message #1517633] Sat, 20 December 2014 17:12 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Here is an example of an RCP application using ECF and Zoodiscovery [1]

Cheers,

Wim

[1] https://github.com/ECF/Chat
Re: Problems with ZooDiscovery [message #1520714 is a reply to message #1519422] Sun, 21 December 2014 10:42 Go to previous message
Robert Lechner is currently offline Robert LechnerFriend
Messages: 7
Registered: December 2014
Junior Member
Hello Wim,

thank you for your example code. I'll take a look at it after my vacation.

I wish you and the whole ECF team a Merry Christmas and a Happy New Year.

Yours, Robert

Previous Topic:Use of remote service client API with non OSGI-services
Next Topic:ECF 3.9.2 released
Goto Forum:
  


Current Time: Mon Dec 02 14:25:27 GMT 2024

Powered by FUDForum. Page generated in 0.04091 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top