public static String getTierListenerPath(String tier) { return ZKPaths.makePath(LookupCoordinatorManager.LOOKUP_LISTEN_ANNOUNCE_KEY, tier); }
ListenerResourceAnnouncer( Announcer announcer, String announceBasePath, HostAndPortWithScheme node ) { this.announcePath = ZKPaths.makePath(announceBasePath, node.toString()); this.announcer = announcer; }
private String makeServedSegmentPath(String zNode) { return ZKPaths.makePath(liveSegmentLocation, StringUtils.format("%s%s", zNode, counter.getAndIncrement())); }
private String defaultIndexerPath(final String subPath) { return ZKPaths.makePath(getBase(), subPath); }
public ListenerResourceAnnouncer( Announcer announcer, ListeningAnnouncerConfig listeningAnnouncerConfig, String listener_key, HostAndPortWithScheme node ) { this( announcer, ZKPaths.makePath(listeningAnnouncerConfig.getListenersPath(), listener_key), node ); }
public String defaultPath(final String subPath) { return ZKPaths.makePath(getBase(), subPath); }
private String makeAnnouncementPath() { return ZKPaths.makePath(config.getAnnouncementsPath(), server.getName()); } }
/** * Build a path for the particular named listener. The first implementation of this is used with zookeeper, but * there is nothing restricting its use in a more general pathing (example: http endpoint proxy for raft) * @param listenerName The key for the listener. * @return A path appropriate for use in zookeeper to discover the listeners with the particular listener name */ public String getAnnouncementPath(String listenerName) { return ZKPaths.makePath( getListenersPath(), Preconditions.checkNotNull( StringUtils.emptyToNullNonDruidDataString(listenerName), "Listener name cannot be null" ) ); } }
private void delete(final String node) throws KeeperException { final ZooKeeperClient client = client("delete"); final String nodePath = ZKPaths.makePath(path, node); if (client.stat(nodePath) != null) { log.debug("deleting node: {}", nodePath); client.delete(nodePath); } }
private void write(final String node, final byte[] data) throws KeeperException { final ZooKeeperClient client = client("write"); final String nodePath = ZKPaths.makePath(path, node); if (client.stat(nodePath) != null) { log.debug("setting node: {}", nodePath); client.setData(nodePath, data); } else { log.debug("creating node: {}", nodePath); client.createAndSetData(nodePath, data); } }
public UsageListing(Exhibitor exhibitor, String startPath, int maxChildren) { if ( startPath.trim().length() == 0 ) { startPath = "/"; } ZKPaths.PathAndNode pathAndNode = ZKPaths.getPathAndNode(startPath); this.exhibitor = exhibitor; this.startPath = ZKPaths.makePath(pathAndNode.getPath(), pathAndNode.getNode()); this.maxChildren = maxChildren; }
public LoadQueuePeon giveMePeon(ImmutableDruidServer server) { if ("http".equalsIgnoreCase(config.getLoadQueuePeonType())) { return new HttpLoadQueuePeon(server.getURL(), jsonMapper, httpClient, config, peonExec, callbackExec); } else { return new CuratorLoadQueuePeon( curator, ZKPaths.makePath(zkPaths.getLoadQueuePath(), server.getName()), jsonMapper, peonExec, callbackExec, config ); } } }
private void recursivelyDelete(String path) throws Exception { List<String> children = context.getExhibitor().getLocalConnection().getChildren().forPath(path); for ( String name : children ) { recursivelyDelete(ZKPaths.makePath(path, name)); } context.getExhibitor().getLocalConnection().delete().forPath(path); context.getExhibitor().getLog().add(ActivityLog.Type.INFO, String.format("deleteNode() deleted node [%s]", path)); }
@Override public void announce(DiscoveryDruidNode discoveryDruidNode) { try { log.info("Announcing [%s].", discoveryDruidNode); String path = ZKPaths.makePath( config.getInternalDiscoveryPath(), discoveryDruidNode.getNodeType().toString(), discoveryDruidNode.getDruidNode().getHostAndPortToUse() ); announcer.announce(path, jsonMapper.writeValueAsBytes(discoveryDruidNode)); log.info("Announced [%s].", discoveryDruidNode); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } }
NodeTypeWatcher( ExecutorService listenerExecutor, CuratorFramework curatorFramework, String basePath, ObjectMapper jsonMapper, NodeType nodeType ) { this.listenerExecutor = listenerExecutor; this.curatorFramework = curatorFramework; this.nodeType = nodeType; this.jsonMapper = jsonMapper; // This is required to be single threaded from Docs in PathChildrenCache; this.cacheExecutor = Execs.singleThreaded(StringUtils.format("NodeTypeWatcher[%s]", nodeType)); this.cache = new PathChildrenCache( curatorFramework, ZKPaths.makePath(basePath, nodeType.toString()), true, true, cacheExecutor ); }
propertyValues.put(StringUtils.format("%s.propertiesPath", configPrefix), ZKPaths.makePath(base, "properties")); propertyValues.put(StringUtils.format("%s.announcementsPath", configPrefix), ZKPaths.makePath(base, "announcements")); propertyValues.put(StringUtils.format("%s.servedSegmentsPath", configPrefix), ZKPaths.makePath(base, "servedSegments")); propertyValues.put(StringUtils.format("%s.liveSegmentsPath", configPrefix), ZKPaths.makePath(base, "segments")); propertyValues.put(StringUtils.format("%s.coordinatorPath", configPrefix), ZKPaths.makePath(base, "coordinator")); propertyValues.put(StringUtils.format("%s.loadQueuePath", configPrefix), ZKPaths.makePath(base, "loadQueue")); propertyValues.put(StringUtils.format("%s.connectorPath", configPrefix), ZKPaths.makePath(base, "connector"));
private void unannounceSegmentForServer(DruidServer druidServer, DataSegment segment) throws Exception { curator .delete() .guaranteed() .forPath(ZKPaths.makePath(inventoryPath, druidServer.getHost(), segment.getId().toString())); }
@Override public void unannounce(DiscoveryDruidNode discoveryDruidNode) { log.info("Unannouncing [%s].", discoveryDruidNode); String path = ZKPaths.makePath( config.getInternalDiscoveryPath(), discoveryDruidNode.getNodeType().toString(), discoveryDruidNode.getDruidNode().getHostAndPortToUse() ); announcer.unannounce(path); log.info("Unannounced [%s].", discoveryDruidNode); } }
protected void unannounceSegmentForServer(DruidServer druidServer, DataSegment segment, ZkPathsConfig zkPathsConfig) throws Exception { String path = ZKPaths.makePath( zkPathsConfig.getLiveSegmentsPath(), druidServer.getHost(), segment.getId().toString() ); curator.delete().guaranteed().forPath(path); }
@Test public void testStartCorrect() { final Announcer announcer = EasyMock.createStrictMock(Announcer.class); final HostAndPortWithScheme node = HostAndPortWithScheme.fromString("some_host"); final ListenerResourceAnnouncer resourceAnnouncer = new ListenerResourceAnnouncer( announcer, listeningAnnouncerConfig, listenerKey, node ) { }; announcer.announce( EasyMock.eq(ZKPaths.makePath(announcePath, StringUtils.format("%s:%s", node.getScheme(), node.getHostText()))), EasyMock.aryEq(resourceAnnouncer.getAnnounceBytes()) ); EasyMock.expectLastCall().once(); EasyMock.replay(announcer); resourceAnnouncer.start(); EasyMock.verify(announcer); } }