/** * 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 testGetUserFromPath() throws Exception { assertEquals("bob", RegistryPathUtils .getUsername("/registry/users/bob/services/yarn-service/test1/")); assertEquals("bob-dev", RegistryPathUtils .getUsername("/registry/users/bob-dev/services/yarn-service/test1")); assertEquals("bob.dev", RegistryPathUtils .getUsername("/registry/users/bob.dev/services/yarn-service/test1")); }
/** * 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)); }