pathChildrenCache.getListenable().addListener( (client, event) -> { if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { DataSegment segment = dataSegments .entrySet() pathChildrenCacheCold.getListenable().addListener( (client, event) -> { if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { DataSegment segment = dataSegments .entrySet()
throws Exception if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { final Task task = jsonMapper.readValue( cf.getData().forPath(pathChildrenCacheEvent.getData().getPath()),
@Override public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { if (isValid()) { // guard against events with null data or path String path; ChildData childData = event.getData(); if (childData != null) { path = childData.getPath(); } else { path = null; } byte[] data = null; if (childData != null) { data = childData.getData(); } PathChildrenCacheEvent.Type type = event.getType(); switch (type) { case CHILD_ADDED: case CHILD_REMOVED: case CHILD_UPDATED: case INITIALIZED: if (shouldRunCallbacks(type, path) && !path.contains("password")) { String s = data != null ? new String(data, "UTF-8") : ""; LOGGER.info("Event {} detected on {} with data {}. Sending notification.", type.name(), path, s); fireChangeNotifications(); } break; } } }
if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) {
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { try { if (isConnected() && (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED))) { synchronized (this) { Participant participant = leaderLatch.getLeader(); if (isLeader(participant) && !leaderLatch.hasLeadership()) { // in case current instance becomes leader, we want to know who came before it. currentLeader = participant; } } } } catch (InterruptedException e) { log.warn("Oracle leadership watcher has been interrupted unexpectedly"); } } }
/** * It's possible an Oracle has gone into a bad state. Upon the leader being changed, we want to * update our state */ @Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) { Participant participant = leaderLatch.getLeader(); synchronized (this) { if (isLeader(participant)) { currentLeader = leaderLatch.getLeader(); } else { currentLeader = null; } } } }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { try { if (isConnected() && (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event .getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED))) { synchronized (this) { Participant participant = leaderSelector.getLeader(); if (isLeader(participant) && !leaderSelector.hasLeadership()) { // in case current instance becomes leader, we want to know who came before it. currentLeader = participant; } } } } catch (InterruptedException e) { log.warn("Oracle leadership watcher has been interrupted unexpectedly"); } }
/** * It's possible an Oracle has gone into a bad state. Upon the leader being changed, we want to * update our state */ @Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) { Participant participant = leaderSelector.getLeader(); synchronized (this) { if (isLeader(participant)) { currentLeader = leaderSelector.getLeader(); } else { currentLeader = null; } } } }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { try { if (isConnected() && (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED))) { synchronized (this) { Participant participant = leaderSelector.getLeader(); if (isLeader(participant) && !leaderSelector.hasLeadership()) { // in case current instance becomes leader, we want to know who came before it. currentLeader = participant; } } } } catch (InterruptedException e) { log.warn("Oracle leadership watcher has been interrupted unexpectedly"); } }
/** * It's possible an Oracle has gone into a bad state. Upon the leader being changed, we want to * update our state */ @Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) { Participant participant = leaderSelector.getLeader(); synchronized (this) { if (isLeader(participant)) { currentLeader = leaderSelector.getLeader(); } else { currentLeader = null; } } } }
/** * Checks if the container should react to a change in the specified path. */ private boolean shouldRunCallbacks(PathChildrenCacheEvent.Type type, String path) { if (path == null) { return false; } String runtimeIdentity = runtimeProperties.get().getRuntimeIdentity(); String currentVersion = getContainerVersion(runtimeIdentity); return (path.startsWith(ZkPath.CONTAINERS.getPath()) && type.equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) || path.equals(ZkPath.CONFIG_ENSEMBLES.getPath()) || path.equals(ZkPath.CONFIG_ENSEMBLE_URL.getPath()) || path.equals(ZkPath.CONFIG_ENSEMBLE_PASSWORD.getPath()) || path.equals(ZkPath.CONFIG_CONTAINER.getPath(runtimeIdentity)) || (currentVersion != null && path.equals(ZkPath.CONFIG_VERSIONS_CONTAINER.getPath(currentVersion, runtimeIdentity))); }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception { if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { final Task task = jsonMapper.readValue( cf.getData().forPath(pathChildrenCacheEvent.getData().getPath()), Task.class ); notices.add(new RunNotice(task)); } } }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception { if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { final Task task = jsonMapper.readValue( cf.getData().forPath(pathChildrenCacheEvent.getData().getPath()), Task.class ); assignTask(task); } } }
if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.INITIALIZED)) { srcCountdown.countDown(); } else if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.INITIALIZED)) { destCountdown.countDown(); } else if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) {
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) { if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { if (assignSegmentLatch.getCount() > 0) { //Coordinator should try to assign segment to druidServer historical //Simulate historical loading segment druidServer.addDataSegment(dataSegment); assignSegmentLatch.countDown(); } else { Assert.fail("The same segment is assigned to the same server multiple times"); } } } }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception { if (pathChildrenCacheEvent.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED)) { final Task task = jsonMapper.readValue( cf.getData().forPath(pathChildrenCacheEvent.getData().getPath()), Task.class ); assignTask(task); } } }