org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type Java Examples
The following examples show how to use
org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AgentServiceImpl.java From flow-platform-x with Apache License 2.0 | 6 votes |
private void initAgentsFromZk() { for (Agent agent : agentDao.findAll()) { String zkPath = getPath(agent); String zkLockPath = getLockPath(agent); // set to offline if zk node not exist if (!zk.exist(zkPath)) { agent.setStatus(Status.OFFLINE); agentDao.save(agent); zk.delete(zkLockPath, false); continue; } // sync status and lock node Status status = getStatusFromZk(agent); agent.setStatus(status); agentDao.save(agent); syncLockNode(agent, Type.CHILD_ADDED); } }
Example #2
Source File: AgentServiceImpl.java From flow-platform-x with Apache License 2.0 | 6 votes |
private void initAgentsFromZk() { for (Agent agent : agentDao.findAll()) { String zkPath = getPath(agent); String zkLockPath = getLockPath(agent); // set to offline if zk node not exist if (!zk.exist(zkPath)) { agent.setStatus(Status.OFFLINE); agentDao.save(agent); zk.delete(zkLockPath, false); continue; } // sync status and lock node Status status = getStatusFromZk(agent); agent.setStatus(status); agentDao.save(agent); syncLockNode(agent, Type.CHILD_ADDED); } }
Example #3
Source File: AgentServiceImpl.java From flow-platform-x with Apache License 2.0 | 5 votes |
private void handleAgentStatusChange(PathChildrenCacheEvent event) { String path = event.getData().getPath(); // do not handle event from lock node if (path.endsWith(LockPathSuffix)) { log.debug("Lock node '{}' event '{}' received", path, event.getType()); return; } String agentId = getAgentIdFromPath(path); Agent agent = get(agentId); if (event.getType() == Type.CHILD_ADDED) { syncLockNode(agent, Type.CHILD_ADDED); updateAgentStatus(agent, Status.IDLE); log.debug("Event '{}' of agent '{}' with status '{}'", event.getType(), agent.getName(), Status.IDLE); return; } if (event.getType() == Type.CHILD_REMOVED) { syncLockNode(agent, Type.CHILD_REMOVED); updateAgentStatus(agent, Status.OFFLINE); log.debug("Event '{}' of agent '{}' with status '{}'", event.getType(), agent.getName(), Status.OFFLINE); return; } if (event.getType() == Type.CONNECTION_RECONNECTED) { Status status = getStatusFromZk(agent); updateAgentStatus(agent, status); log.debug("Event '{}' of agent '{}' with status '{}'", event.getType(), agent.getName(), status); } }
Example #4
Source File: CuratorMaster.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED) { /* * Obtain just the worker's name */ try{ getAbsentWorkerTasks(event.getData().getPath().replaceFirst("/workers/", "")); } catch (Exception e) { LOG.error("Exception while trying to re-assign tasks", e); } } }
Example #5
Source File: CuratorMaster.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED) { try{ assignTask(event.getData().getPath().replaceFirst("/tasks/", ""), event.getData().getData()); } catch (Exception e) { LOG.error("Exception when assigning task.", e); } } }
Example #6
Source File: CuratorMasterLatch.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED) { /* * Obtain just the worker's name */ try{ getAbsentWorkerTasks(event.getData().getPath().replaceFirst("/workers/", "")); } catch (Exception e) { LOG.error("Exception while trying to re-assign tasks", e); } } }
Example #7
Source File: CuratorMasterLatch.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED) { try{ assignTask(event.getData().getPath().replaceFirst("/tasks/", ""), event.getData().getData()); } catch (Exception e) { LOG.error("Exception when assigning task.", e); } } }
Example #8
Source File: CuratorMasterSelector.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED) { /* * Obtain just the worker's name */ try{ getAbsentWorkerTasks(event.getData().getPath().replaceFirst("/workers/", "")); } catch (Exception e) { LOG.error("Exception while trying to re-assign tasks", e); } } }
Example #9
Source File: CuratorMasterSelector.java From zookeeper-book-example with Apache License 2.0 | 5 votes |
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) { if(event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED) { try{ assignTask(event.getData().getPath().replaceFirst("/tasks/", ""), event.getData().getData()); } catch (Exception e) { LOG.error("Exception when assigning task.", e); } } }