Skip to main content Skip to complementary content

ZooKeeper usage

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

Procedure

  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
                         admin.enableServer=false
                         admin.serverPort=9090
    • 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.

    • The ZooKeeper AdminServer is disabled by default with admin.enableServer. To enable this feature, set the value to true. For more information on the ZooKeeper AdminServer, see the ZooKeeper AdminServer configuration.

    • The admin.serverPort is the port used when AdminServer is enabled.

  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.

    Example

  4. Start the Container, for details on this please refer to .

Service Locator installation as an OSGi bundle

Procedure

  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 Starting Service Locator and Starting and stopping the Authorization service in the Talend Runtime Container.
  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. The ZooKeeper AdminServer is disabled by default with JVM parameters. To enable this feature, edit <TalendRuntimePath>/bin/setenv or <TalendRuntimePath>/addbin/setenv.bat as follows and set the proper available port.
    -Dzookeeper.admin.enableServer=true Dzookeeper.admin.serverPort=<AVAILABLE PORT>
    For more information on the ZooKeeper AdminServer, see the ZooKeeper AdminServer configuration.
    Information noteNote: If Talend Runtime is installed as a service, the service's wrapper configuration file must be updated to include the JVM Parameters. For example:
    wrapper.java.additional.XX=-Dzookeeper.admin.enableServer=true 
                               wrapper.java.additional.XX=-Dzookeeper.admin.serverPort=9090 
    where "XX" should be the next integer in the series.
  4. Restart the Container.

Service deployment

Before you begin

  • If you installed ZooKeeper in standalone mode, 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/
                         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.

Once all the bundles are installed, the environment is ready to test. Note that locator_client needs to stay stopped for the time being.

About this task

Once the Service Locator has been installed successfully in the Talend Runtime Container, you can deploy the services.

Procedure

  1. After executing bundle:start 157:
    • If you installed ZooKeeper in standalone mode, 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 to list all the installed and started bundles. 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 bundle:start 158 on the 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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!