Package org.I0Itec.zkclient

Examples of org.I0Itec.zkclient.IZkDataListener


    final ZkClient client =
        new ZkClient(ZK_ADDR, ZkClient.DEFAULT_SESSION_TIMEOUT,
            ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
    String path = String.format("/%s", clusterName);
    client.createEphemeral(path);
    client.subscribeDataChanges(path, new IZkDataListener() {

      @Override
      public void handleDataDeleted(String dataPath) throws Exception {
      }
View Full Code Here


        takeLeadershipIfNeeded(groupLeadershipSession);
      }
    };

    //Data change call back ; try and get notified on creation of the ephemeral member node
    IZkDataListener dataListener = new IZkDataListener()
    {

      @Override
      public void handleDataChange(String dataPath, Object data) throws Exception
      {
View Full Code Here

    final ZkClient client =
        new ZkClient(_zkaddr, ZkClient.DEFAULT_SESSION_TIMEOUT,
            ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
    String path = String.format("/%s", clusterName);
    client.createEphemeral(path);
    client.subscribeDataChanges(path, new IZkDataListener() {

      @Override
      public void handleDataDeleted(String dataPath) throws Exception {
      }
View Full Code Here

      @Override
      public void added(String name) {
        // nothing todo
      }
    });
    IZkDataListener dataListener = new IZkDataListener() {
      @Override
      public void handleDataDeleted(String arg0) throws Exception {
        checkDeploymentForCompletion();
      }
View Full Code Here

    try {
      createEphemeral(master, zkMasterPath, new MasterMetaData(masterName, System.currentTimeMillis()));
      isMaster = true;
      LOG.info(masterName + " started as master");
    } catch (ZkNodeExistsException e) {
      registerDataListener(master, new IZkDataListener() {
        @Override
        public void handleDataDeleted(final String dataPath) throws KattaException {
          master.handleMasterDisappearedEvent();
        }
View Full Code Here

  public void testUnregisterListenersOnUnregisterComponent() throws Exception {
    ConnectedComponent component = mock(ConnectedComponent.class);
    _protocol.registerComponent(component);

    IAddRemoveListener childListener = mock(IAddRemoveListener.class);
    IZkDataListener dataListener = mock(IZkDataListener.class);
    _protocol.registerChildListener(component, PathDef.NODES_LIVE, childListener);
    _protocol.registerDataListener(component, PathDef.NODES_LIVE, "node1", dataListener);

    _zk.getZkClient().createPersistent(_zk.getZkConf().getZkPath(PathDef.NODES_LIVE, "node1"));
    Thread.sleep(500);
View Full Code Here

  }

  @Test(timeout = 70000)
  public void testDataListener() throws Exception {
    ConnectedComponent component = mock(ConnectedComponent.class);
    IZkDataListener listener = mock(IZkDataListener.class);
    PathDef pathDef = PathDef.INDICES_METADATA;
    String zkPath = _zk.getZkConf().getZkPath(pathDef, "index1");

    Long serializable = new Long(1);
    _zk.getZkClient().createPersistent(zkPath, serializable);
View Full Code Here

    }
  }

  protected void addIndexForWatching(final String indexName) {
    _indicesToWatch.add(indexName);
    _protocol.registerDataListener(this, PathDef.INDICES_METADATA, indexName, new IZkDataListener() {
      @Override
      public void handleDataDeleted(String dataPath) throws Exception {
        // handled through IndexPathListener
      }
View Full Code Here

        this.serverData = serverData;
    }

    public ServerRunningMonitor(){
        // 创建父节点
        dataListener = new IZkDataListener() {

            public void handleDataChange(String dataPath, Object data) throws Exception {
                MDC.put("destination", destination);
                ServerRunningData runningData = JsonUtils.unmarshalFromByte((byte[]) data, ServerRunningData.class);
                if (!isMine(runningData.getAddress())) {
View Full Code Here

    store.setProperty("child0", new ZNRecord("child0"));

    ZNRecord record2 = store.getProperty("child0"); // will put the record in cache
    String child0Path = propertyStoreRoot + "/child0";
    _gZkClient.subscribeDataChanges(child0Path, new IZkDataListener()
    {
      @Override
      public void handleDataDeleted(String dataPath) throws Exception
      {
        // TODO Auto-generated method stub
View Full Code Here

TOP

Related Classes of org.I0Itec.zkclient.IZkDataListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.