Example usage for org.apache.zookeeper WatchedEvent toString

List of usage examples for org.apache.zookeeper WatchedEvent toString

Introduction

In this page you can find the example usage for org.apache.zookeeper WatchedEvent toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.apache.giraph.yarn.TestYarnJob.java

License:Apache License

/**
 * Logging this stuff will help you debug integration test issues.
 * @param zkEvent incoming event for our current test ZK's znode tree.
 *///from   ww  w  . j  a  v a  2s.  c o  m
@Override
public void process(WatchedEvent zkEvent) {
    String event = zkEvent == null ? "NULL" : zkEvent.toString();
    LOG.info("TestYarnJob observed ZK event: " + event + " for a total of " + (++zkEventCount) + " so far.");
}

From source file:org.apache.hama.bsp.sync.ZKSyncEventListener.java

License:Apache License

/**
 * //from   ww w  .ja v a2  s  . c o m
 */
@Override
public void process(WatchedEvent event) {

    client.registerListener(event.getPath(), ZKSyncEventFactory.getValueChangeEvent(), this);
    // if(LOG.isDebugEnabled()){
    LOG.debug(event.toString());
    // }

    if (event.getType().equals(EventType.NodeChildrenChanged)) {
        LOG.debug("Node children changed - " + event.getPath());
        onChildKeySetChange();
    } else if (event.getType().equals(EventType.NodeDeleted)) {
        LOG.debug("Node children deleted - " + event.getPath());
        onDelete();
    } else if (event.getType().equals(EventType.NodeDataChanged)) {
        LOG.debug("Node children changed - " + event.getPath());

        onChange();
    }

}

From source file:org.deploymentobjects.core.infrastructure.persistence.zookeeper.ZookeeperPersistence.java

License:Open Source License

@Override
public void process(WatchedEvent event) {
    // TODO handle connection/disconnection
    System.err.println(event.toString());
}

From source file:org.jc.zk.dpw.TimeDataMonitor.java

@Override
public void process(WatchedEvent event) {
    System.out.print(event.toString());
    switch (event.getType()) {
    case NodeCreated:
        if (event.getPath().equals(this.znodeForTimeListeners)) {
            this.listener.timeListenersZnodeCreated();
        } else if (event.getPath().equals(this.timeZnodeRemovedFlagZnode)) {
            this.listener.notificationZnodeCreated();
        }/*ww  w  .ja  va  2  s .  c o m*/
        break;
    case NodeDeleted:
        if (event.getPath().equals(this.timeZnode)) {
            this.listener.timeZnodeDeleted();
        } else if (event.getPath().equals(this.znodeForTimeListeners)) {
            this.listener.timeListenersZnodeDeleted();
        } else if (event.getPath().equals(this.timeZnodeRemovedFlagZnode)) {
            this.listener.notificationZnodeRemoved();
        }
        break;
    case NodeDataChanged:
        if (event.getPath().equals(this.timeZnode)) {
            this.listener.timeZnodeChanged();
            //this.zk.getData(this.timeZnode, null, this, this.ctx);
        } else if (event.getPath().equals(this.znodeForTimeListeners)) {
            this.listener.timeListenersZnodeChanged();
        } else if (event.getPath().equals(this.requestAMWKillZnode)) {
            this.listener.requestAMWKillZnodeChanged();
        }
        break;
    case None:
        if (event.getState() == Event.KeeperState.SyncConnected) {
            this.listener.connected();
        } else if (event.getState() == Event.KeeperState.Disconnected
                || event.getState() == Event.KeeperState.Expired) {
            this.listener.disconnected(KeeperException.Code.CONNECTIONLOSS.intValue());
        }
        break;
    }
}

From source file:org.wso2.carbon.coordination.core.services.impl.ZKCoordinationService.java

License:Open Source License

@Override
public void process(WatchedEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("At ZKCoordinationService#process: " + event.toString());
    }/*from  www  .  ja v  a2  s  .  c o  m*/
}

From source file:voldemort.store.metadata.MetadataStore.java

License:Apache License

/**
 * Called from ZooKeeper when a watched event is triggered.
 *
 * @param event//from w w  w  .  j av  a  2s . c  om
 */

@Override
public void process(WatchedEvent event) {
    logger.info(String.format("Got event from ZooKeeper: %s", event.toString()));
    try {
        for (String key : MetadataStore.REQUIRED_KEYS) {
            if (key.equals(event.getPath()) || event.getPath().contains(key)) {
                logger.info("ZK event with path matches key: " + key + ", updating metadatacache");

                writeLock.lock();
                try {
                    // get new version of the object and re sets watch flag if appropriate for the key
                    Versioned<String> versioned = innerStore.get(key, null).get(0);

                    Versioned<Object> vObject = convertStringToObject(key, versioned);

                    metadataCache.put(key, vObject);

                    if (key.equals(CLUSTER_KEY)) {
                        updateRoutingStrategies((Cluster) vObject.getValue(), getStoreDefList());
                    } else if (key.equals(STORES_KEY)) {
                        updateRoutingStrategies(getCluster(), (List<StoreDefinition>) vObject.getValue());
                    } else if (SYSTEM_STORES_KEY.equals(key)) {
                        throw new VoldemortException("Cannot overwrite system store definitions");
                    }

                } finally {
                    writeLock.unlock();
                }
            }
        }
    } catch (VoldemortException e) {
        logger.info("failed watching/processing key: " + event.getPath());
        throw new VoldemortException("failed watching/processing event key: " + event.getPath(), e);
    }
}