本文整理了Java中com.alibaba.otter.shared.common.utils.zookeeper.ZkClientx.writeData()
方法的一些代码示例,展示了ZkClientx.writeData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClientx.writeData()
方法的具体详情如下:
包路径:com.alibaba.otter.shared.common.utils.zookeeper.ZkClientx
类名称:ZkClientx
方法名:writeData
暂无
代码示例来源:origin: com.alibaba.otter/shared.common
public void writeData(String path, Object object) {
writeData(path, object, -1);
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
private void updateStatus(Long channelId, ChannelStatus status) {
String path = ManagePathUtils.getChannelByChannelId(channelId);
byte[] data = JsonUtils.marshalToByte(status);// 初始化的数据对象
try {
zookeeper.writeData(path, data);
} catch (ZkException e) {
throw new ArbitrateException("Channel_init", channelId.toString(), e);
}
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* 提供数据接口更新对应的pipeline上的状态
*/
public void single(SyncStatusEventData syncStatus) {
String path = StagePathUtils.getPipeline(syncStatus.getPipelineId());
try {
byte[] bytes = JsonUtils.marshalToByte(syncStatus);
zookeeper.writeData(path, bytes);
logger.info("## single status : " + syncStatus);
} catch (ZkException e) {
throw new ArbitrateException("single_SyncStatus", syncStatus.getPipelineId().toString(), e);
}
}
代码示例来源:origin: com.alibaba.otter/shared.common
/**
* Updates data of an existing znode. The current content of the znode is passed to the {@link DataUpdater} that is
* passed into this method, which returns the new content. The new content is only written back to ZooKeeper if
* nobody has modified the given znode in between. If a concurrent change has been detected the new data of the
* znode is passed to the updater once again until the new contents can be successfully written back to ZooKeeper.
*
* @param <T>
* @param path The path of the znode.
* @param updater Updater that creates the new contents.
*/
public <T extends Object> void updateDataSerialized(String path, DataUpdater<T> updater) {
Stat stat = new Stat();
boolean retry;
do {
retry = false;
try {
T oldData = (T) readData(path, stat);
T newData = updater.update(oldData);
writeData(path, newData, stat.getVersion());
} catch (ZkBadVersionException e) {
retry = true;
}
} while (retry);
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* 手工触发一次主备切换
*/
public void switchWarmup(Long channelId, Long pipelineId) {
String path = ManagePathUtils.getMainStem(channelId, pipelineId);
try {
while (true) {
Stat stat = new Stat();
byte[] bytes = zookeeper.readData(path, stat);
MainStemEventData mainStemData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
mainStemData.setActive(false);
try {
zookeeper.writeData(path, JsonUtils.marshalToByte(mainStemData), stat.getVersion());
logger.warn("relase channelId[{}],pipelineId[{}] mainstem successed! ", channelId, pipelineId);
break;
} catch (ZkBadVersionException e) {
// ignore , retrying
}
}
} catch (ZkNoNodeException e) {
// ignore
} catch (ZkException e) {
throw new ArbitrateException("releaseMainStem", pipelineId.toString(), e);
}
}
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* 更新mainStem的同步状态数据
*/
public void single(MainStemEventData data) {
Assert.notNull(data);
Long nid = ArbitrateConfigUtils.getCurrentNid();
if (!check()) {
return;
}
data.setNid(nid);// 设置当前的nid
String path = StagePathUtils.getMainStem(data.getPipelineId());
byte[] bytes = JsonUtils.marshalToByte(data);// 初始化的数据对象
try {
zookeeper.writeData(path, bytes);
} catch (ZkException e) {
throw new ArbitrateException("mainStem_single", data.toString(), e);
}
activeData = data;
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* 标记一下当前process为已使用
*/
private void markUsed(EtlEventData data) throws ZkNoNodeException, ZkException {
String path = StagePathUtils.getProcess(data.getPipelineId(), data.getProcessId());
// 序列化
ProcessNodeEventData eventData = new ProcessNodeEventData();
Long nid = ArbitrateConfigUtils.getCurrentNid();
eventData.setNid(nid);
eventData.setStatus(ProcessNodeEventData.Status.USED);// 标记为已使用
eventData.setMode(ArbitrateMode.RPC);// 直接声明为rpc模式
byte[] bytes = JsonUtils.marshalToByte(eventData);
zookeeper.writeData(path, bytes);
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* 标记一下当前process为已使用
*/
private void markUsed(EtlEventData data) throws ZkNoNodeException, ZkException {
String path = StagePathUtils.getProcess(data.getPipelineId(), data.getProcessId());
// 序列化
ProcessNodeEventData eventData = new ProcessNodeEventData();
Long nid = ArbitrateConfigUtils.getCurrentNid();
eventData.setNid(nid);
eventData.setStatus(ProcessNodeEventData.Status.USED);// 标记为已使用
eventData.setMode(ArbitrateMode.ZOOKEEPER);// 直接声明为zookeeper模式
byte[] bytes = JsonUtils.marshalToByte(eventData);
zookeeper.writeData(path, bytes);
}
内容来源于网络,如有侵权,请联系作者删除!