ZooKeeper usage

Talend ESB Development Guide

EnrichVersion
6.2
EnrichProdName
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Talend Data Fabric
Talend ESB
Talend MDM Platform
Talend Data Services Platform
task
Design and Development
EnrichPlatform
Talend ESB

You can use Service Locator either by using the standalone Zookeeper provided in the Talend ESB product, or by using its OSGi Bundles equivalent already installed in the Talend Runtime container.

Service Locator standalone installation

  1. Go into <TalendRuntimePath>/zookeeper.

  2. Before starting Zookeeper, you need to provide a configuration file. Two configuration files are provided: <TalendRuntimePath>/zookeeper/conf/zoo.cfg, the default one, and zoo_sample.cfg. For a testing purpose, if you do not want to edit the default file, you can just rename the zoo_sample.cfg to zoo.cfg.

    Edit it and change the settings as follows:

    tickTime=2000 
    dataDir=./var/locator 
    clientPort=2181
    • The tickTime refers to the basic unit of time measurement used by ZooKeeper, used for later configuration of timeouts and other parameters.

    • The dataDir holds database snapshots and transaction logs. Check the ZooKeeper Administration Manual for information on all possible parameters.

    • The clientPort number should be same as the endpointPrefix defined in LocatorFeature above.

  3. Once the zoo.cfg file configured, you can start or stop the zooKeeper by running:

    • <TalendRuntimePath>/zookeeper/bin/zkServer.cmd start/stop on Windows.

    • <TalendRuntimePath>/zookeeper/bin/zkServer.sh start/stop on Linux.

  4. Start the Container, for details on this please refer to Talend ESB (OSGi).

Service Locator installation as an OSGi bundle

  1. You first need to start the Talend Runtime container and start the Service Locator feature via the tesb:start-locator. For more information on how to start them, see the Talend ESB Infrastructure Services Configuration Guide.

  2. Once the Service Locator feature started, a container/etc/org.talend.esb.locator.server.cfg configuration file is created. It is the Talend ESB equivalent to the Zookeeper zoo.cfg configuration file.

    Edit it and change the settings as follows:

    tickTime=2000 
    dataDir=./var/locator 
    clientPort=2181
    • The tickTime refers to the basic unit of time measurement used by ZooKeeper, used for later configuration of timeouts and other parameters.

    • The dataDir holds database snapshots and transaction logs. Check the ZooKeeper Administration Manual for information on all possible parameters.

    • The clientPort number should be same as the endpointPrefix defined in LocatorFeature above.

  3. Restart the Container.

Service deployment

Now that the Service Locator has been installed successfully in the Talend Runtime container, you will deploy the services.

    • If you installed Zookeeper in standalone, you first need to install and start two bundles: "org.talend.esb.locator" and "org.apache.zookeeper.zookeeper" that activate the Service Locator feature in the Talend Runtime container. And then, you can deploy the three bundles you previously created and start them. To do so, execute the following commands sequentially:

      karaf@trun> bundle:install mvn:org.apache.zookeeper/zookeeper/3.3.3
      karaf@trun> bundle:install mvn:org.talend.esb/locator/6.2.2
      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_common/1.0.0
      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_service/1.0.0
      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_client/1.0.0
      karaf@trun> bundle:start 154
      karaf@trun> bundle:start 155
      karaf@trun> bundle:start 156
      karaf@trun> bundle:start 157
    • If you installed Zookeeper as an OSGi bundle, you will only need to deploy the three bundles you previously created and start them:

      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_common/1.0.0
      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_service/1.0.0
      karaf@trun> bundle:install mvn:org.talend.esb.examples.locator/locator_client/1.0.0
      karaf@trun> bundle:start 156
      karaf@trun> bundle:start 157

    The bundle numbers returned for each bundle:install command will probably be different from those used in this sample; use those numbers instead.

    Then, all bundles will be installed and the environment is ready to test. Except "locator_client", we need to keep it stopped for the time being.

  1. After executing bundle:start 157:

    • If you installed Zookeeper in standalone, change to the ZooKeeper console, and you will see some log messages like:

      2011-06-02 16:17:02,031 - INFO  
      [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - 
      Accepted socket connection from /127.0.0.1:1102
      2011-06-02 16:17:02,031 - INFO  
      [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@777] - Client 
      attempting to establish new session at /127.0.0.1:1102
      2011-06-02 16:17:02,046 - INFO  
      [SyncThread:0:NIOServerCnxn@1580] - Established session 0x1304f61dba10001 
      with negotiated timeout 5000 for client /127.0.0.1:1102
    • If you installed Zookeeper as an OSGi bundle, execute the console command list and all the installed and started bundles should be listed and to check that the services are working, go to: http://localhost:8040/services/.

  2. After installation has been done either in standalone or as an OSGi bundle and the service started and working, execute bundle:start 158 on the Container console, you should get some output message in the console:

    karaf@trun> bundle:start 158
    Executing operation greetMe
    Message received: MyName
    
    Hello MyName

    If you get a message like this, then you did the right thing.

  3. Turn to zooKeeper console (if you are using it as standalone), you can see the connection message like below:

    2011-06-02 16:24:19,671 - INFO  
    [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - 
    Accepted socket connection from /127.0.0.1:1126
    2011-06-02 16:24:19,671 - INFO  
    [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@777] - Client 
    attempting to establish new session at /127.0.0.1:1126
    2011-06-02 16:24:19,703 - INFO  
    [SyncThread:0:NIOServerCnxn@1580] - Established session 0x1304f61dba10002 
    with negotiated timeout 5000 for client /127.0.0.1:1126
  4. For more test, execute bundle:stop 158 and the bundle:start 158 on OSGi Container console, you will have the same result as described above.

    So far, you saw how to use Service Locator. In the next section, you will look into Service Activity Monitoring.