本文整理汇总了Java中org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.getType方法的典型用法代码示例。如果您正苦于以下问题:Java PathChildrenCacheEvent.getType方法的具体用法?Java PathChildrenCacheEvent.getType怎么用?Java PathChildrenCacheEvent.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent
的用法示例。
在下文中一共展示了PathChildrenCacheEvent.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData data = event.getData();
switch (event.getType()) {
case CHILD_ADDED:
add(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()) ;
break;
case CHILD_REMOVED:
delete(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()); ;
break;
case CHILD_UPDATED:
add(data.getPath().substring(data.getPath().lastIndexOf("/")+1),event.getData().getData()) ;
break;
default:
break;
}
}
示例2: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
final Type eventType = event.getType();
final String path = event.getData().getPath();
final String name = ZKHelper.getNameFromPath(path);
LOGGER.debugMarker("ZoneEventListener", "Receive zookeeper event %s %s", eventType, path);
if (eventType == Type.CHILD_ADDED || eventType == Type.CHILD_UPDATED) {
agentService.report(new AgentPath(zone.getName(), name), AgentStatus.IDLE);
return;
}
if (eventType == Type.CHILD_REMOVED) {
agentService.report(new AgentPath(zone.getName(), name), AgentStatus.OFFLINE);
return;
}
}
示例3: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData childData = event.getData();
switch (event.getType()) {
case CHILD_ADDED:
try {
lockTableByNewNode(childData);
} catch (Exception e) {
LOGGER.info("CHILD_ADDED error", e);
}
break;
case CHILD_UPDATED:
updateMeta(childData);
break;
case CHILD_REMOVED:
deleteNode(childData);
break;
default:
break;
}
}
示例4: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData childData = event.getData();
switch (event.getType()) {
case CHILD_ADDED:
createOrUpdateViewMeta(childData, false);
break;
case CHILD_UPDATED:
createOrUpdateViewMeta(childData, true);
break;
case CHILD_REMOVED:
deleteNode(childData);
break;
default:
break;
}
}
示例5: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData data = event.getData();
switch (event.getType()) {
case CHILD_ADDED:
add(data, false);
break;
case CHILD_UPDATED:
add(data, true);
break;
case CHILD_REMOVED:
delete(data);
break;
default:
break;
}
}
示例6: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
switch (event.getType()) {
case CHILD_ADDED:
case CHILD_UPDATED: {
addProvider(event.getData(), false);
break;
}
case CHILD_REMOVED: {
providers.remove(ZKPaths.getNodeFromPath(event.getData().getPath()));
break;
}
default:
break;
}
}
示例7: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
switch (event.getType()) {
case CHILD_ADDED:
applicationAdded(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
break;
// Event CHILD_REMOVED will be triggered on all config servers if deleteApplication() above is called on one of them
case CHILD_REMOVED:
applicationRemoved(ApplicationId.fromSerializedForm(Path.fromString(event.getData().getPath()).getName()));
break;
case CHILD_UPDATED:
// do nothing, application just got redeployed
break;
default:
break;
}
// We might have lost events and might need to remove applications (new applications are
// not added by listening for events here, they are added when session is added, see RemoteSessionRepo)
removeApplications();
}
示例8: onZkEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
private void onZkEvent(final PathChildrenCacheEvent event) {
// Lock is needed only to support massive load on startup. In all other cases it will be called for
// event type creation/update, so it won't create any additional load.
String invalidatedEventType = null;
rwLock.readLock().lock();
try {
final boolean needInvalidate = event.getType() == PathChildrenCacheEvent.Type.CHILD_UPDATED ||
event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED ||
event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED;
if (needInvalidate) {
final String[] path = event.getData().getPath().split("/");
invalidatedEventType = path[path.length - 1];
eventTypeCache.invalidate(invalidatedEventType);
}
} finally {
rwLock.readLock().unlock();
}
if (null != invalidatedEventType) {
for (final Consumer<String> listener : invalidationListeners) {
listener.accept(invalidatedEventType);
}
}
}
示例9: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
String nodePath = null;
T nodeData = null;
if (event.getData() != null) {
nodePath = event.getData().getPath();
nodeData = parseChildData(event.getData());
}
switch (event.getType()) {
case CHILD_ADDED:
addNode(nodePath, nodeData);
break;
case CHILD_REMOVED:
removeNode(nodePath, nodeData);
break;
case CHILD_UPDATED:
updateNode(nodePath, nodeData);
break;
}
}
示例10: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
throws Exception {
switch ( event.getType() ) {
case CHILD_ADDED:
PathsUpdate newUpdate = new PathsUpdate();
PluginCacheSyncUtil.setUpdateFromChildEvent(event, newUpdate);
metastorePlugin.processCacheNotification(newUpdate);
break;
case INITIALIZED:
case CHILD_UPDATED:
case CHILD_REMOVED:
break;
case CONNECTION_RECONNECTED:
MetastoreAuthzBinding.setSentryCacheOutOfSync(false);
break;
case CONNECTION_SUSPENDED:
case CONNECTION_LOST:
MetastoreAuthzBinding.setSentryCacheOutOfSync(true);
break;
default:
break;
}
}
示例11: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public synchronized void childEvent(CuratorFramework client,
PathChildrenCacheEvent event) throws Exception {
switch ( event.getType() ) {
case CHILD_ADDED:
K newUpdate = (K) baseUpdate.getClass().newInstance();
PluginCacheSyncUtil.setUpdateFromChildEvent(event, newUpdate);
updateForwarder.postNotificationToLog(newUpdate);
break;
case INITIALIZED:
case CHILD_UPDATED:
case CHILD_REMOVED:
break;
case CONNECTION_RECONNECTED:
// resume the node
SentryPlugin.instance.setOutOfSync(false);
break;
case CONNECTION_SUSPENDED:
case CONNECTION_LOST:
// suspend the node
SentryPlugin.instance.setOutOfSync(true);
break;
default:
break;
}
}
示例12: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
logger.debug("Listener parent path: {} currentData {}",
new Object[]{event.getData().getPath(), StringSerializer.deserialize(event.getData().getData())});
switch (event.getType()) {
case CHILD_ADDED:
synchronized (this) {
testGroupMembers.add(event.getData().getPath().substring(
event.getData().getPath().lastIndexOf("/")+1));
}
barrier.await(10, TimeUnit.SECONDS);
break;
case CHILD_REMOVED:
synchronized (this) {
testGroupMembers.remove(event.getData().getPath().substring(
event.getData().getPath().lastIndexOf("/")+1));
}
barrier.await(10, TimeUnit.SECONDS);
break;
}
}
示例13: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData data = event.getData();
if(data==null || data.getData()==null){
return;
}
SlaveNode slaveNode = SlaveNode.parse(JSON.parseObject(data.getData(),JSONObject.class));
if(slaveNode==null){
LOGGER.error("get a null slaveNode with eventType={},path={},data={}",event.getType(),data.getPath(),data.getData());
}else {
switch (event.getType()) {
case CHILD_ADDED:
slaveNodeMap.put(slaveNode.getId(), slaveNode);
LOGGER.info("CHILD_ADDED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
break;
case CHILD_REMOVED:
slaveNodeMap.remove(slaveNode.getId());
LOGGER.info("CHILD_REMOVED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
break;
case CHILD_UPDATED:
slaveNodeMap.replace(slaveNode.getId(), slaveNode);
LOGGER.info("CHILD_UPDATED with path={},data={},current slaveNode size={}", data.getPath(), new String(data.getData(),CharsetUtil.UTF_8),slaveNodeMap.size());
break;
default:
break;
}
}
}
示例14: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
throws Exception {
PathChildrenCacheEvent.Type eventType = event.getType();
switch (eventType) {
case INITIALIZED:
LOG.debug("initailize the service instance list from zookeeper.");
break;
case CHILD_ADDED:
LOG.debug("add new service instance from zookeeper.");
this.addChild(event.getData());
break;
case CHILD_UPDATED:
LOG.debug("update service instance from zookeeper.");
this.addChild(event.getData());
break;
case CONNECTION_RECONNECTED:
this.cache.rebuild();
break;
case CHILD_REMOVED:
case CONNECTION_SUSPENDED:
case CONNECTION_LOST:
LOG.debug("remove service instance from zookeeper.");
this.removeChild(event.getData());
break;
default:
LOG.debug("Ignore PathChildrenCache event : {path:"
+ event.getData().getPath() + " data:"
+ new String(event.getData().getData()) + "}");
}
}
示例15: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework unused, PathChildrenCacheEvent event) throws Exception {
if (event.getType() != PathChildrenCacheEvent.Type.CHILD_ADDED) {
return;
}
final long lastKnownRevision = revisionFromPath(event.getData().getPath());
replayLogs(lastKnownRevision);
oldLogRemover.touch();
}