Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Zoodiscovery"

(How to get ZooDiscovery service?)
Line 17: Line 17:
 
  IContainer container = null;
 
  IContainer container = null;
 
  try {
 
  try {
 +
//"ecf.discovery.zookeeper" is the name our container
 
  container = ContainerFactory.getDefault().createContainer("ecf.discovery.zookeeper");
 
  container = ContainerFactory.getDefault().createContainer("ecf.discovery.zookeeper");
 
  } catch(ContainerCreateException e1){
 
  } catch(ContainerCreateException e1){
Line 22: Line 23:
 
  }  
 
  }  
 
  ID serverId = container.getConnectNamespace().createInstance(  
 
  ID serverId = container.getConnectNamespace().createInstance(  
  new String[] { "discovery.flavor.standalone=172.17.2.219" });
+
//discovery.flavor.standalone=172.17.2.219 designates one or more IP's to connect to
 +
  new String[] { "discovery.flavor.standalone=172.17.2.17''','''172.17.2.19" });
 
  try {
 
  try {
 +
//we then connect to other instance of
 
  container.connect(serverId, null);
 
  container.connect(serverId, null);
 
  } catch (ContainerConnectException e1) {
 
  } catch (ContainerConnectException e1) {
 
  // TODO   
 
  // TODO   
 
  }
 
  }
 
 
  
 
===How to publish/advertise my services===
 
===How to publish/advertise my services===

Revision as of 09:54, 22 March 2010

What is ZooDiscovery?

ZooDiscovery is a discovery mechanism that runs as an OSGi service. It leverage Apache ZooKeeper robustness and implements Eclipse ECF Discovery API.(Hence the name!). ZooDiscovery is flexible and easy to configure.


Download

The concept in some words

ZooDiscovery implements both ECF discovery interfaces: IDiscoveryAdvertiser and IDiscoveryLocator. That is, ZooDiscovery can publish our services and gets us noticed about discovered services. Perfect! But how? A ZooDiscovery instance running at your machine does its job by exchanging data with other ZooDiscovery instance(s) running elsewhere. So each running ZooDiscovety service must know where that other "elsewhere" exactly is. This is why we should first make our ZooDiscovery happy, giving it an IP address to play with.
To keep it smooth, let's take it step by step following these cases:

Learn by asking

How to get ZooDiscovery service?

IContainer container = null;
try {

//"ecf.discovery.zookeeper" is the name our container

container = ContainerFactory.getDefault().createContainer("ecf.discovery.zookeeper");
} catch(ContainerCreateException e1){
// TODO 
} 
ID serverId = container.getConnectNamespace().createInstance( 

//discovery.flavor.standalone=172.17.2.219 designates one or more IP's to connect to

new String[] { "discovery.flavor.standalone=172.17.2.17,172.17.2.19" });
try {

//we then connect to other instance of

container.connect(serverId, null);
} catch (ContainerConnectException e1) {
// TODO  
}

How to publish/advertise my services

I want ZooDiscovery publishing my OSGi services without me interfering

IContainer container = null;
try {
container = ContainerFactory.getDefault().createContainer("ecf.discovery.zookeeper");
} catch(ContainerCreateException e1){
// TODO 
} 
ID serverId = container.getConnectNamespace().createInstance( 
new String[] { "discovery.flavor.standalone=172.17.2.219","discovery.publish.auto=true" });
try {
container.connect(serverId, null);
} catch (ContainerConnectException e1) {
// TODO  
}

Automatically publishing your sevices is as easy as adding this property: "discovery.publish.auto=true".


I want to get notified about discovered servcies

Advanced configuration

Recipes

Back to the top