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