/** * Returns the DNS name constructed from the YARN container ID. * * @return the container ID name. * @throws TextParseException */ protected Name getContainerIDName() throws TextParseException { String containerID = RegistryPathUtils.lastPathEntry(getPath()); return Name.fromString(String.format("%s.%s", containerID, domain)); }
@Override public void nodeAdded(String path) throws IOException { // get a listing of service records String relativePath = getPathRelativeToRegistryRoot(path); String child = RegistryPathUtils.lastPathEntry(path); Map<String, RegistryPathStatus> map = new HashMap<>(); map.put(child, registryOperations.stat(relativePath)); Map<String, ServiceRecord> records = RegistryUtils.extractServiceRecords(registryOperations, getAdjustedParentPath(path), map); processServiceRecords(records, register); pathToRecordMap.putAll(records); }
/** * Get the service's DNS name for registration. * * @return the service DNS name. * @throws TextParseException */ protected Name getServiceName() throws TextParseException { String user = RegistryPathUtils.getUsername(getPath()); String service = String.format("%s.%s.%s", RegistryPathUtils.lastPathEntry(getPath()), user, domain); return Name.fromString(service); }
@Test public void testLastPathEntry() throws Throwable { assertEquals("",lastPathEntry("/")); assertEquals("",lastPathEntry("//")); assertEquals("c",lastPathEntry("/a/b/c")); assertEquals("c",lastPathEntry("/a/b/c/")); }
@Test public void testLastPathEntry() throws Throwable { assertEquals("",lastPathEntry("/")); assertEquals("",lastPathEntry("//")); assertEquals("c",lastPathEntry("/a/b/c")); assertEquals("c",lastPathEntry("/a/b/c/")); }
@Override public RegistryPathStatus stat(String path) throws IOException { validatePath(path); Stat stat = zkStat(path); String name = RegistryPathUtils.lastPathEntry(path); RegistryPathStatus status = new RegistryPathStatus( name, stat.getCtime(), stat.getDataLength(), stat.getNumChildren()); if (LOG.isDebugEnabled()) { LOG.debug("Stat {} => {}", path, status); } return status; }
@Override public RegistryPathStatus stat(String path) throws IOException { validatePath(path); Stat stat = zkStat(path); String name = RegistryPathUtils.lastPathEntry(path); RegistryPathStatus status = new RegistryPathStatus( name, stat.getCtime(), stat.getDataLength(), stat.getNumChildren()); if (LOG.isDebugEnabled()) { LOG.debug("Stat {} => {}", path, status); } return status; }
/** * Returns the DNS name constructed from the container role/component name. * * @return the DNS naem. * @throws PathNotFoundException * @throws TextParseException */ protected Name getContainerName() throws PathNotFoundException, TextParseException { String service = RegistryPathUtils.lastPathEntry( RegistryPathUtils.parentOf(RegistryPathUtils.parentOf(getPath()))); String description = getRecord().description.toLowerCase(); String user = RegistryPathUtils.getUsername(getPath()); return Name.fromString(MessageFormat.format("{0}.{1}.{2}.{3}", description, service, user, domain)); }
/** * Return the DNS name constructed from the component name. * * @return the DNS naem. * @throws PathNotFoundException * @throws TextParseException */ protected Name getComponentName() throws PathNotFoundException, TextParseException { String service = RegistryPathUtils.lastPathEntry( RegistryPathUtils.parentOf(RegistryPathUtils.parentOf(getPath()))); String component = getRecord().get("yarn:component").toLowerCase(); String user = RegistryPathUtils.getUsername(getPath()); return Name.fromString(MessageFormat.format("{0}.{1}.{2}.{3}", component, service, user, domain)); }
println(json); } else { String filename = RegistryPathUtils.lastPathEntry(name) + ".json"; File jsonFile = new File(destDir, filename); write(jsonFile, File outFile = args.out; if (args.destdir != null) { outFile = new File(args.destdir, RegistryPathUtils.lastPathEntry(path));
println(json); } else { String filename = RegistryPathUtils.lastPathEntry(name) + ".json"; File jsonFile = new File(destDir, filename); write(jsonFile, File outFile = args.out; if (args.destdir != null) { outFile = new File(args.destdir, RegistryPathUtils.lastPathEntry(path));