本文整理汇总了Java中org.I0Itec.zkclient.exception.ZkException类的典型用法代码示例。如果您正苦于以下问题:Java ZkException类的具体用法?Java ZkException怎么用?Java ZkException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZkException类属于org.I0Itec.zkclient.exception包,在下文中一共展示了ZkException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: recovery
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 尝试载入一下上一次未使用的processId,可能发生mainstem切换,新的S模块需要感知前S模块已创建但未使用的process,不然就是一个死锁。而针对已经使用的processId会由e/t/l节点进行处理
*/
private void recovery(Long pipelineId) {
List<Long> currentProcessIds = processMonitor.getCurrentProcessIds(false);
for (Long processId : currentProcessIds) {
String path = StagePathUtils.getProcess(pipelineId, processId);
try {
byte[] bytes = zookeeper.readData(path);
ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
if (nodeData.getStatus().isUnUsed()) {// 加入未使用的processId
addReply(processId);
}
} catch (ZkException e) {
logger.error("recovery error!", e);
}
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:19,代码来源:SelectProcessListener.java
示例2: recovery
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 尝试载入一下上一次未使用的processId,可能发生mainstem切换,新的S模块需要感知前S模块已创建但未使用的process,不然就是一个死锁。而针对已经使用的processId会由e/t/l节点进行处理
*/
private void recovery(Long pipelineId) {
List<Long> currentProcessIds = stageMonitor.getCurrentProcessIds(false);
for (Long processId : currentProcessIds) {
String path = StagePathUtils.getProcess(pipelineId, processId);
try {
byte[] bytes = zookeeper.readData(path);
ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
if (nodeData.getStatus().isUnUsed()) {// 加入未使用的processId
addReply(processId);
}
} catch (ZkException e) {
logger.error("SelectStageListener", e);
}
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:19,代码来源:SelectStageListener.java
示例3: fetch
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 提供数据接口获取对应pipeline上的状态
*/
public SyncStatusEventData fetch(Long pipelineId) {
String path = StagePathUtils.getPipeline(pipelineId);
try {
byte[] bytes = zookeeper.readData(path);
if (bytes == null || bytes.length == 0) {
SyncStatusEventData evnetData = new SyncStatusEventData();
evnetData.setPipelineId(pipelineId);
return evnetData;
} else {
return JsonUtils.unmarshalFromByte(bytes, SyncStatusEventData.class);
}
} catch (ZkException e) {
// 没有节点返回空
throw new ArbitrateException("fetch_SyncStatus", pipelineId.toString(), e);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:ToolArbitrateEvent.java
示例4: listRemedyIndexs
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 查询当前的remedy index记录
*/
public List<RemedyIndexEventData> listRemedyIndexs(Long pipelineId) {
String path = StagePathUtils.getRemedyRoot(pipelineId);
List<RemedyIndexEventData> datas = new ArrayList<RemedyIndexEventData>();
try {
List<String> nodes = zookeeper.getChildren(path);
for (String node : nodes) {
RemedyIndexEventData data = RemedyIndexEventData.parseNodeName(node);
data.setPipelineId(pipelineId);
datas.add(data);
}
} catch (ZkException e) {
throw new ArbitrateException("listRemedyIndexs", pipelineId.toString(), e);
}
Collections.sort(datas, new RemedyIndexComparator()); // 做一下排序
return datas;
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:21,代码来源:ToolArbitrateEvent.java
示例5: single
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 更新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;
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:21,代码来源:MainstemMonitor.java
示例6: createPersistentSequential
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* Create a persistent Sequential node.
*
* @param path
* @param data
* @param createParents if true all parent dirs are created as well and no {@link ZkNodeExistsException} is thrown
* in case the path already exists
* @throws ZkInterruptedException if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException if called from anything except the ZooKeeper event thread
* @throws ZkException if any ZooKeeper exception occurred
* @throws RuntimeException if any other exception occurs
*/
public String createPersistentSequential(String path, Object data, boolean createParents)
throws ZkInterruptedException,
IllegalArgumentException,
ZkException,
RuntimeException {
try {
return create(path, data, CreateMode.PERSISTENT_SEQUENTIAL);
} catch (ZkNoNodeException e) {
if (!createParents) {
throw e;
}
String parentDir = path.substring(0, path.lastIndexOf('/'));
createPersistent(parentDir, createParents);
return createPersistentSequential(path, data, createParents);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:ZkClientx.java
示例7: create
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* Create a node.
*
* @param path
* @param data
* @param mode
* @return create node's path
* @throws ZkInterruptedException if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException if called from anything except the ZooKeeper event thread
* @throws ZkException if any ZooKeeper exception occurred
* @throws RuntimeException if any other exception occurs
*/
public String create(final String path, Object data, final CreateMode mode) throws ZkInterruptedException,
IllegalArgumentException, ZkException,
RuntimeException {
if (path == null) {
throw new NullPointerException("path must not be null.");
}
final byte[] bytes = data == null ? null : serialize(data);
return retryUntilConnected(new Callable<String>() {
@Override
public String call() throws Exception {
return _connection.create(path, bytes, mode);
}
});
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:ZkClientx.java
示例8: connect
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
@Override
public void connect(Watcher watcher) {
ReflectionUtils.makeAccessible(zookeeperLockField);
ReflectionUtils.makeAccessible(zookeeperFiled);
Lock _zookeeperLock = (ReentrantLock) ReflectionUtils.getField(zookeeperLockField, this);
ZooKeeper _zk = (ZooKeeper) ReflectionUtils.getField(zookeeperFiled, this);
_zookeeperLock.lock();
try {
if (_zk != null) {
throw new IllegalStateException("zk client has already been started");
}
String zkServers = _serversList.get(0);
try {
logger.debug("Creating new ZookKeeper instance to connect to " + zkServers + ".");
_zk = new ZooKeeper(zkServers, _sessionTimeOut, watcher);
configMutliCluster(_zk);
ReflectionUtils.setField(zookeeperFiled, this, _zk);
} catch (IOException e) {
throw new ZkException("Unable to connect to " + zkServers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
开发者ID:alibaba,项目名称:otter,代码行数:27,代码来源:ZooKeeperx.java
示例9: createPersistentSequential
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* Create a persistent Sequential node.
*
* @param path
* @param data
* @param createParents if true all parent dirs are created as well and no
* {@link ZkNodeExistsException} is thrown in case the path already exists
* @throws ZkInterruptedException if operation was interrupted, or a
* required reconnection got interrupted
* @throws IllegalArgumentException if called from anything except the
* ZooKeeper event thread
* @throws ZkException if any ZooKeeper exception occurred
* @throws RuntimeException if any other exception occurs
*/
public String createPersistentSequential(String path, Object data, boolean createParents)
throws ZkInterruptedException,
IllegalArgumentException,
ZkException,
RuntimeException {
try {
return create(path, data, CreateMode.PERSISTENT_SEQUENTIAL);
} catch (ZkNoNodeException e) {
if (!createParents) {
throw e;
}
String parentDir = path.substring(0, path.lastIndexOf('/'));
createPersistent(parentDir, createParents);
return createPersistentSequential(path, data, createParents);
}
}
开发者ID:alibaba,项目名称:canal,代码行数:31,代码来源:ZkClientx.java
示例10: mainstemData
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
public MainStemEventData mainstemData(Long channelId, Long pipelineId) {
String path = ManagePathUtils.getMainStem(channelId, pipelineId);
try {
byte[] bytes = zookeeper.readData(path);
return JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
} catch (ZkException e) {
return null;
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:10,代码来源:ArbitrateViewServiceImpl.java
示例11: markUsed
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 标记一下当前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);
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:15,代码来源:SelectRpcArbitrateEvent.java
示例12: processChain
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
public void processChain(TerminEventData data) {
// 关闭对应的服务
Long pipelineId = data.getPipelineId();
// 清理对应的process
String processRoot = StagePathUtils.getProcessRoot(pipelineId);
try {
List<String> processNodes = zookeeper.getChildren(processRoot);
// 3. 循环处理每个process
List<Long> processIds = new ArrayList<Long>();
for (String process : processNodes) {
processIds.add(StagePathUtils.getProcessId(process));
}
Collections.sort(processIds); // 排序一下
Long processId = data.getProcessId();
if (processId != null) {// 可能为空
normalTerminProcess.process(data);
}
for (Long currProcessId : processIds) {
if (processId != null && currProcessId <= processId) {
continue;
}
// 发送给最小的一个process的termin信号,进行链式的触发
data.setProcessId(currProcessId);
processChain(data); // 处理异常信息
break;
}
} catch (ZkException e) {
throw new ArbitrateException("Termin_process", e);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:36,代码来源:ErrorTerminProcess.java
示例13: markUsed
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 标记一下当前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);
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:15,代码来源:SelectZooKeeperArbitrateEvent.java
示例14: single
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 提供数据接口更新对应的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);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:14,代码来源:ToolArbitrateEvent.java
示例15: init
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 创建相应的node节点,说明:node节点的生命周期为EPHEMERAL
*
* <pre>
* 1. 是个同步调用
* </pre>
*/
public void init(Long nid) {
String path = ManagePathUtils.getNode(nid);
try {
zookeeper.create(path, new byte[0], CreateMode.EPHEMERAL);// 创建为临时节点
} catch (ZkException e) {
throw new ArbitrateException("Node_init", nid.toString(), e);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:17,代码来源:NodeArbitrateEvent.java
示例16: liveNodes
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
/**
* 获取当前存活的节点列表
*/
public List<Long> liveNodes() {
String path = ArbitrateConstants.NODE_NID_ROOT;
try {
List<String> nids = zookeeper.getChildren(path);
List<Long> result = new ArrayList<Long>();
for (String nid : nids) {
result.add(Long.valueOf(nid));
}
return result;
} catch (ZkException e) {
throw new ArbitrateException("liveNodes", e);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:18,代码来源:NodeArbitrateEvent.java
示例17: updateStatus
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
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);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:10,代码来源:ChannelArbitrateEvent.java
示例18: configMutliCluster
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
public void configMutliCluster(ZooKeeper zk) {
if (_servers.size() == 1) {
return;
}
String cluster1 = _servers.get(0);
try {
if (_servers.size() > 1) {
// 强制的声明accessible
ReflectionUtils.makeAccessible(clientCnxnField);
ReflectionUtils.makeAccessible(hostProviderField);
ReflectionUtils.makeAccessible(serverAddressesField);
// 添加第二组集群列表
for (int i = 1; i < _servers.size(); i++) {
String cluster = _servers.get(i);
// 强制获取zk中的地址信息
ClientCnxn cnxn = (ClientCnxn) ReflectionUtils.getField(clientCnxnField, zk);
HostProvider hostProvider = (HostProvider) ReflectionUtils.getField(hostProviderField, cnxn);
List<InetSocketAddress> serverAddrs = (List<InetSocketAddress>) ReflectionUtils.getField(serverAddressesField,
hostProvider);
// 添加第二组集群列表
serverAddrs.addAll(new ConnectStringParser(cluster).getServerAddresses());
}
}
} catch (Exception e) {
try {
if (zk != null) {
zk.close();
}
} catch (InterruptedException ie) {
// ignore interrupt
}
throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:37,代码来源:ZooKeeperx.java
示例19: createRegistry
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
@Override
protected Registry createRegistry(URL registryUrl) {
try {
int timeout = registryUrl.getIntParameter(URLParam.registryConnectTimeout.getName(), URLParam.registryConnectTimeout.getIntValue());
int sessionTimeout =
registryUrl.getIntParameter(URLParam.registrySessionTimeout.getName(),
URLParam.registrySessionTimeout.getIntValue());
ZkClient zkClient = new ZkClient(registryUrl.getParameter(URLParam.registryAddress.getName()), sessionTimeout, timeout);
return new ZookeeperRegistry(registryUrl, zkClient);
} catch (ZkException e) {
throw e;
}
}
开发者ID:TFdream,项目名称:mango,代码行数:14,代码来源:ZookeeperRegistryFactory.java
示例20: createTopic
import org.I0Itec.zkclient.exception.ZkException; //导入依赖的package包/类
@PostConstruct
public void createTopic() {
if (kafkaProducer != null) {
ZkClient zkClient = null;
String brokerURI = null;
try {
topic = serviceConfigProvider.getKafkaTopicName();
Integer partitions = serviceConfigProvider.getKafkaPartitionsFactor();
Integer replicationFactor = serviceConfigProvider.getKafkaReplicationFactor();
Integer timeoutInMs = serviceConfigProvider.getKafkaTimeoutInMs();
brokerURI = serviceConfigProvider.getZookeeperUri();
zkClient = new ZkClient(brokerURI, timeoutInMs, timeoutInMs, ZKStringSerializer$.MODULE$);
if (!AdminUtils.topicExists(zkClient, topic)) {
logger.info("Topic: {} does not exist. Creating...", topic);
AdminUtils.createTopic(zkClient, topic, partitions, replicationFactor, new Properties());
} else {
logger.info("Topic: {} exist and will be use for pushing messages", topic);
}
} catch (ZkException | VcapEnvironmentException e) {
logger.error("error during topic creation! Topic: {}, Broker URI: {}. KafkaSenderService will be unavailable!",
topic, brokerURI, e);
kafkaProducer = null;
} finally {
if (zkClient != null) {
zkClient.close();
}
}
}
}
开发者ID:enableiot,项目名称:iotanalytics-backend,代码行数:31,代码来源:KafkaSenderService.java
注:本文中的org.I0Itec.zkclient.exception.ZkException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论