public ZooKeeperQueue(ZkClient zkClient, String rootPath, boolean isBlocking) { _zkClient = zkClient; _rootPath = rootPath; _isBlocking = isBlocking; _elementsPath = rootPath + "/queue"; if (!_zkClient.exists(rootPath)) { _zkClient.createPersistent(rootPath, true); _zkClient.createPersistent(_elementsPath, true); } }
public void executeAttempt(String attemptID, ScheduleConf conf, ScheduleStatus status) { String schedulePath = JarExecutor.SCHEDULE_PATH + "/" + attemptID; String scheduleNewPath = JarExecutor.SCHEDULE_NEW_PATH + "/" + attemptID; String scheduleConfPath = schedulePath + "/" + JarExecutor.CONF; String scheduleStatusPath = schedulePath + "/" + JarExecutor.STATUS; zkClient.createPersistent(schedulePath, true); zkClient.createPersistent(scheduleConfPath); zkClient.createPersistent(scheduleStatusPath); zkClient.writeData(scheduleConfPath, conf); zkClient.writeData(scheduleStatusPath, status); zkClient.createPersistent(scheduleNewPath, true); }
@Override public void createPersistent(String path, Object data) { try { client.createPersistent(path, data); } catch (ZkNodeExistsException e) { } }
public static void createIfNotExist(String path) { try { zkClient.createPersistent(path, true); } catch (Exception e) { // } }
public boolean offer(T element) throws Exception { String nodeFullPath = root.concat("/").concat(Node_NAME); try { zkClient.createPersistentSequential(nodeFullPath, element); } catch (ZkNoNodeException e) { zkClient.createPersistent(root); offer(element); } catch (Exception e) { throw ExceptionUtil.convertToRuntimeException(e); } return true; }
public ZookeeprTickCondition(String workPath, ZkClient zkClient) { this.zkClient = zkClient; this.workPath = ZookeeperConstant.ROOT + "/" + workPath; zkClient.createPersistent(this.workPath, true); zkClient.subscribeChildChanges( this.workPath, new IZkChildListener() { @Override public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception { if (currentChilds != null && !currentChilds.isEmpty()) { return; } tryOccupy(); } }); }
public void createPersistent(String path) { try { client.createPersistent(path, true); } catch (ZkNodeExistsException e) { } }