当前位置: 首页>>代码示例>>Java>>正文


Java EventType类代码示例

本文整理汇总了Java中org.apache.zookeeper.Watcher.Event.EventType的典型用法代码示例。如果您正苦于以下问题:Java EventType类的具体用法?Java EventType怎么用?Java EventType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventType类属于org.apache.zookeeper.Watcher.Event包,在下文中一共展示了EventType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processDataOrChildChange

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
private void processDataOrChildChange(WatchedEvent event) {
    final String path = event.getPath();

    if (event.getType() == EventType.NodeChildrenChanged || event.getType() == EventType.NodeCreated || event.getType() == EventType.NodeDeleted) {
        Set<IZkChildListener> childListeners = _childListener.get(path);
        if (childListeners != null && !childListeners.isEmpty()) {
            fireChildChangedEvents(path, childListeners);
        }
    }

    if (event.getType() == EventType.NodeDataChanged || event.getType() == EventType.NodeDeleted || event.getType() == EventType.NodeCreated) {
        Set<IZkDataListener> listeners = _dataListener.get(path);
        if (listeners != null && !listeners.isEmpty()) {
            fireDataChangedEvents(event.getPath(), listeners);
        }
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:18,代码来源:ZkClient.java

示例2: setData

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:26,代码来源:DataTree.java

示例3: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
@Override
public void process(WatchedEvent event) {
	ZooKeeper zkClient = zookeeperConnManager.getZkClient();
	try {
		/* 重新注册节点 */
		zkClient.exists(nodePath, this);
		EventType eventType = event.getType();
		switch (eventType) {
		case NodeDeleted:
			election();
			break;
		default:
			break;
		}
	} catch (Exception e) {
		log.error("error", e);
	}
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:19,代码来源:MasterElection.java

示例4: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
@Override
public void process(WatchedEvent event) {
	ZooKeeper zkClient = zookeeperConnManager.getZkClient();
	try {
		/* 重新注册节点 */
		List<String> childrens = zkClient.getChildren(nodePath, this);
		EventType eventType = event.getType();
		switch (eventType) {
		case NodeChildrenChanged:
			log.info("当前注册中心内的成功注册的agent数量-->"
					+ childrens.stream().filter(children -> children.startsWith("agent")).count());
			break;
		default:
			break;
		}
	} catch (Exception e) {
		log.error("error", e);
	}
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:20,代码来源:WatchAgents.java

示例5: testNodeCreated

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
@Test
public void testNodeCreated() throws Exception {
    QuorumUtil qu = new QuorumUtil(1);
    qu.startAll();

    EventsWatcher watcher = new EventsWatcher();
    ZooKeeper zk1 = createClient(qu, 1, watcher);
    ZooKeeper zk2 = createClient(qu, 2);

    String path = "/test1-created";

    zk1.exists(path, watcher);
    qu.shutdown(1);
    zk2.create(path, new byte[2], ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    qu.start(1);
    watcher.waitForConnected(TIMEOUT * 1000L);
    watcher.assertEvent(TIMEOUT, EventType.NodeCreated);

    qu.shutdownAll();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:22,代码来源:WatchEventWhenAutoReset.java

示例6: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
public void process(WatchedEvent event) {
    if (event.getState() == KeeperState.SyncConnected) {
        if (latch != null) {
            latch.countDown();
        }
    }

    if (event.getType() == EventType.None) {
        return;
    }
    try {
        events.put(event);
    } catch (InterruptedException e) {
        Assert.assertTrue("interruption unexpected", false);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:WatcherFuncTest.java

示例7: testNodeChildrenChanged

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
@Test
public void testNodeChildrenChanged() throws Exception {
    QuorumUtil qu = new QuorumUtil(1);
    qu.startAll();

    EventsWatcher watcher = new EventsWatcher();
    ZooKeeper zk1 = createClient(qu, 1, watcher);
    ZooKeeper zk2 = createClient(qu, 2);

    String path = "/test-children-changed";

    zk1.create(path, new byte[1], ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    zk1.getChildren(path, watcher);
    qu.shutdown(1);
    zk2.create(path + "/children-1", new byte[2],
            ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    qu.start(1);
    watcher.waitForConnected(TIMEOUT * 1000L);
    watcher.assertEvent(TIMEOUT, EventType.NodeChildrenChanged);

    qu.shutdownAll();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:WatchEventWhenAutoReset.java

示例8: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
public void process(WatchedEvent event) {
    if (!closed) {
        try {
            if (event.getType() != EventType.NodeDeleted) {

                Stat s = zooKeeper.exists(nodePath, this);
                if (s != null) {
                    zookeeper.getChildren(nodePath, this);
                }
            }
        } catch (Exception e) {
            LoggerFactory.getLogger().error(
                    "Error occured re-adding node watcherfor node "
                            + nodePath, e);
        }
        nodeListener.processEvent(event.getPath(), event.getType()
                .name(), null);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:20,代码来源:ZooInspectorManagerImpl.java

示例9: processDataOrChildChange

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
private void processDataOrChildChange(WatchedEvent event) {
    final String path = event.getPath();

    if (event.getType() == EventType.NodeChildrenChanged || event.getType() == EventType.NodeCreated
        || event.getType() == EventType.NodeDeleted) {
        Set<IZkChildListener> childListeners = _childListener.get(path);
        if (childListeners != null && !childListeners.isEmpty()) {
            fireChildChangedEvents(path, childListeners);
        }
    }

    if (event.getType() == EventType.NodeDataChanged || event.getType() == EventType.NodeDeleted
        || event.getType() == EventType.NodeCreated) {
        Set<IZkDataListener> listeners = _dataListener.get(path);
        if (listeners != null && !listeners.isEmpty()) {
            fireDataChangedEvents(event.getPath(), listeners);
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:ZkClientx.java

示例10: queueEvent

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
private void queueEvent(WatchedEvent event,
        Set<Watcher> materializedWatchers) {
    if (event.getType() == EventType.None
            && sessionState == event.getState()) {
        return;
    }
    sessionState = event.getState();
    final Set<Watcher> watchers;
    if (materializedWatchers == null) {
        // materialize the watchers based on the event
        watchers = watcher.materialize(event.getState(),
                event.getType(), event.getPath());
    } else {
        watchers = new HashSet<Watcher>();
        watchers.addAll(materializedWatchers);
    }
    WatcherSetEventPair pair = new WatcherSetEventPair(watchers, event);
    // queue the pair (watch set & event) for later processing
    waitingEvents.add(pair);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ClientCnxn.java

示例11: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
public void process(WatchedEvent event) {
    if (!closed) {
        try {
            if (event.getType() != EventType.NodeDeleted) {

                Stat s = zooKeeper.exists(nodePath, this);
                if (s != null) {
                    zookeeper.getChildren(nodePath, this);
                }
            }
        } catch (Exception e) {
            LoggerFactory.getLogger().error(
                    "Error occurred re-adding node watcherfor node "
                            + nodePath, e);
        }
        nodeListener.processEvent(event.getPath(), event.getType()
                .name(), null);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:20,代码来源:ZooInspectorManagerImpl.java

示例12: testRemoveNodeChildrenChangedWatches

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
/**
 * Test verifies deletion of NodeChildrenChanged watches
 */
@Test(timeout = 30000)
public void testRemoveNodeChildrenChangedWatches() throws Exception {
    List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>();
    expectedEvents.add(EventType.ChildWatchRemoved);
    MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1);

    zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    LOG.info("Adding child changed watcher");
    zk.getChildren("/testnode1", myWatcher);

    String cmdstring = "removewatches /testnode1 -c";
    LOG.info("Remove watchers using shell command : {}", cmdstring);
    zkMain.cl.parseCommand(cmdstring);
    Assert.assertTrue("Removewatches cmd fails to remove child watches",
            zkMain.processZKCmd(zkMain.cl));
    myWatcher.matches();
    Assert.assertEquals(
            "Failed to remove child watches : " + zk.getChildWatches(), 0,
            zk.getChildWatches().size());
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:25,代码来源:RemoveWatchesCmdTest.java

示例13: processDataOrChildChange

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
private void processDataOrChildChange(WatchedEvent event) {
	final String path = event.getPath();

	if (event.getType() == EventType.NodeChildrenChanged
			|| event.getType() == EventType.NodeCreated
			|| event.getType() == EventType.NodeDeleted) {
		Set<IZkChildListener> childListeners = _childListener.get(path);
		if (childListeners != null && !childListeners.isEmpty()) {
			fireChildChangedEvents(path, childListeners);
		}
	}

	if (event.getType() == EventType.NodeDataChanged
			|| event.getType() == EventType.NodeDeleted
			|| event.getType() == EventType.NodeCreated) {
		Set<IZkDataListener> listeners = _dataListener.get(path);
		if (listeners != null && !listeners.isEmpty()) {
			fireDataChangedEvents(event.getPath(), listeners);
		}
	}
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:22,代码来源:ZkClient.java

示例14: setData

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNodeV1 n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:18,代码来源:DataTreeV1.java

示例15: process

import org.apache.zookeeper.Watcher.Event.EventType; //导入依赖的package包/类
@Override
public void process(WatchedEvent event) {
    if (event.getType() == EventType.NodeDataChanged) {
        synchronized(this) {
            changed = true;
            notifyAll();
        }
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:10,代码来源:Zab1_0Test.java


注:本文中的org.apache.zookeeper.Watcher.Event.EventType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。