本文整理匯總了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();
}