本文整理汇总了Java中org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.getData方法的典型用法代码示例。如果您正苦于以下问题:Java PathChildrenCacheEvent.getData方法的具体用法?Java PathChildrenCacheEvent.getData怎么用?Java PathChildrenCacheEvent.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent
的用法示例。
在下文中一共展示了PathChildrenCacheEvent.getData方法的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 {
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;
}
}
示例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:
createOrUpdateViewMeta(childData, false);
break;
case CHILD_UPDATED:
createOrUpdateViewMeta(childData, true);
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 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;
}
}
示例5: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public synchronized void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception {
AssertHelper.isTrue(isJoined(), "illegal state .");
boolean hasLeadership = leaderSelector != null && leaderSelector.hasLeadership();
if (!hasLeadership) {
return;
}
if (!EventHelper.isChildModifyEvent(event)) {
return;
}
StandbyJobData standbyJobData = new StandbyJobData(event.getData());
if (StringHelper.isEmpty(standbyJobData.getData().getJobOperation())) {
return;
}
StandbyJobData.Data data = standbyJobData.getData();
if (data.isUnknownOperation()) {
return;
}
StandbyNodeData.Data nodeData = standbyApiFactory.nodeApi().getNode(nodePath).getData();
executeOperation(nodeData, data);
}
示例6: 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;
}
}
示例7: 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;
}
}
}
示例8: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
if (event.getData() != null) {
listener.onEvent(
IDataListener.EventType.NODE_UPDATED,
event.getData().getPath(),
event.getData().getData(),
event.getData().getStat().getVersion()); // TODO: coupled to Zookeeper. Need to decouple
} else if (event.getType() == PathChildrenCacheEvent.Type.INITIALIZED) {
listener.onEvent(IDataListener.EventType.INITIALIZED, null, null);
} else {
log.error("Null data is coming to zkNode cache - {}", "Change NamespacedList");
}
}
示例9: 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:
break;
case CHILD_UPDATED:
break;
case CHILD_REMOVED:
deleteNode(childData);
break;
default:
break;
}
}
示例10: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent)
throws Exception {
ChildData data = pathChildrenCacheEvent.getData();
if (data == null) {
log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
return;
} else if (data.getData() == null) {
log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
return;
} else if (nodePath != null && nodePath.equals(data.getPath())) {
log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
return;
}
ServerInstance instance;
try {
instance = new ServerInstance(ServerInfo.parseFrom(data.getData()));
} catch (IOException e) {
log.error("Failed to decode server instance for node {}", data.getPath(), e);
throw e;
}
log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(),
instance.getPort());
switch (pathChildrenCacheEvent.getType()) {
case CHILD_ADDED:
listeners.forEach(listener -> listener.onServerAdded(instance));
break;
case CHILD_UPDATED:
listeners.forEach(listener -> listener.onServerUpdated(instance));
break;
case CHILD_REMOVED:
listeners.forEach(listener -> listener.onServerRemoved(instance));
break;
}
}
示例11: childEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
ChildData data = pathChildrenCacheEvent.getData();
if (data == null) {
log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
return;
} else if (data.getData() == null) {
log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
return;
} else if (nodePath != null && nodePath.equals(data.getPath())) {
log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
return;
}
ServerInstance instance;
try {
instance = new ServerInstance(ServerInfo.parseFrom(data.getData()));
} catch (IOException e) {
log.error("Failed to decode server instance for node {}", data.getPath(), e);
throw e;
}
log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(), instance.getPort());
switch (pathChildrenCacheEvent.getType()) {
case CHILD_ADDED:
listeners.forEach(listener -> listener.onServerAdded(instance));
break;
case CHILD_UPDATED:
listeners.forEach(listener -> listener.onServerUpdated(instance));
break;
case CHILD_REMOVED:
listeners.forEach(listener -> listener.onServerRemoved(instance));
break;
default:
break;
}
}
示例12: handleChildUpdated
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildUpdated(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
ChildData childData = event.getData();
String nodeName = safeGetNodeNameFromEvent(event);
if(Arrays.asList(configProfiles).contains(nodeName) || canApplyForLocalMachine(nodeName)) {
T newConfig = createConfig(childData.getData(), getObject());
BeanUtils.copyProperties(newConfig, getObject());
getObject().reload();
}
}
示例13: handleChildUpdated
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildUpdated(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
String nodeName = safeGetNodeNameFromEvent(event);
Object configObj = configHolder.get(nodeName);
if( configObj instanceof CloudResourceConfig) {
CloudResourceConfig resourceConfig = (CloudResourceConfig)configObj;
ChildData childData = event.getData();
Object newConfig = createConfig(childData.getData(), getObject());
BeanUtils.copyProperties(newConfig, resourceConfig);
resourceConfig.reload();
}
}
示例14: safeGetNodeNameFromEvent
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
protected String safeGetNodeNameFromEvent(PathChildrenCacheEvent event) {
return event.getData() != null ?
ZKPaths.getNodeFromPath(event.getData().getPath()) : "";
}
示例15: handleChildAdded
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; //导入方法依赖的package包/类
@Override
protected void handleChildAdded(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
String nodeName = event.getData()!=null ?
ZKPaths.getNodeFromPath(event.getData().getPath()) : "";
buildResourceConfig(nodeName);
}