/** * Get the absolute path to where the service has registered itself. * This includes the base registry path * Null until the service is registered * @return the service registration path. */ public String getAbsoluteSelfRegistrationPath() { if (selfRegistrationPath == null) { return null; } String root = registryOperations.getConfig().getTrimmed( RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); return RegistryPathUtils.join(root, selfRegistrationPath); }
/** * Delete the children of a path -but not the path itself. * It is not an error if the path does not exist * @param path path to delete * @param recursive flag to request recursive deletes * @throws IOException IO problems */ public void deleteChildren(String path, boolean recursive) throws IOException { List<String> childNames = null; try { childNames = registryOperations.list(path); } catch (PathNotFoundException e) { return; } for (String childName : childNames) { String child = join(path, childName); registryOperations.delete(child, recursive); } }
/** * Create a service classpath * @param user username or "" * @param serviceClass service name * @return a full path */ public static String serviceclassPath(String user, String serviceClass) { String services = join(homePathForUser(user), RegistryConstants.PATH_USER_SERVICES); return join(services, serviceClass); }
/** * Create a service classpath * @param user username or "" * @param serviceClass service name * @return a full path */ public static String serviceclassPath(String user, String serviceClass) { String services = join(homePathForUser(user), RegistryConstants.PATH_USER_SERVICES); return join(services, serviceClass); }
/** * Create a full path from the registry root and the supplied subdir * @param path path of operation * @return an absolute path * @throws InvalidPathnameException if the path is invalid */ public static String createFullPath(String base, String path) throws InvalidPathnameException { Preconditions.checkArgument(path != null, "null path"); Preconditions.checkArgument(base != null, "null path"); return validateZKPath(join(base, path)); }
/** * Create a path for listing components under a service * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String componentListPath(String user, String serviceClass, String serviceName) { return join(servicePath(user, serviceClass, serviceName), RegistryConstants.SUBPATH_COMPONENTS); }
/** * Create a full path from the registry root and the supplied subdir * @param path path of operation * @return an absolute path * @throws InvalidPathnameException if the path is invalid */ public static String createFullPath(String base, String path) throws InvalidPathnameException { Preconditions.checkArgument(path != null, "null path"); Preconditions.checkArgument(base != null, "null path"); return validateZKPath(join(base, path)); }
/** * Create a path for listing components under a service * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String componentListPath(String user, String serviceClass, String serviceName) { return join(servicePath(user, serviceClass, serviceName), RegistryConstants.SUBPATH_COMPONENTS); }
/** * Create a path to a service under a user and service class * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String servicePath(String user, String serviceClass, String serviceName) { return join( serviceclassPath(user, serviceClass), serviceName); }
/** * Create a path to a service under a user and service class * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String servicePath(String user, String serviceClass, String serviceName) { return join( serviceclassPath(user, serviceClass), serviceName); }
/** * Create the path to a service record for a component * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @param componentName unique name/ID of the component * @return a full path */ public static String componentPath(String user, String serviceClass, String serviceName, String componentName) { return join( componentListPath(user, serviceClass, serviceName), componentName); }
/** * Create the path to a service record for a component * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @param componentName unique name/ID of the component * @return a full path */ public static String componentPath(String user, String serviceClass, String serviceName, String componentName) { return join( componentListPath(user, serviceClass, serviceName), componentName); }
/** * Buld the user path -switches to the system path if the user is "". * It also cross-converts the username to ascii via punycode * @param username username or "" * @return the path to the user */ public static String homePathForUser(String username) { Preconditions.checkArgument(username != null, "null user"); // catch recursion if (username.startsWith(RegistryConstants.PATH_USERS)) { return username; } if (username.isEmpty()) { return RegistryConstants.PATH_SYSTEM_SERVICES; } // convert username to registry name String convertedName = convertUsername(username); return RegistryPathUtils.join(RegistryConstants.PATH_USERS, encodeForRegistry(convertedName)); }
/** * Buld the user path -switches to the system path if the user is "". * It also cross-converts the username to ascii via punycode * @param username username or "" * @return the path to the user */ public static String homePathForUser(String username) { Preconditions.checkArgument(username != null, "null user"); // catch recursion if (username.startsWith(RegistryConstants.PATH_USERS)) { return username; } if (username.isEmpty()) { return RegistryConstants.PATH_SYSTEM_SERVICES; } // convert username to registry name String convertedName = convertUsername(username); return RegistryPathUtils.join(RegistryConstants.PATH_USERS, encodeForRegistry(convertedName)); }
/** * Buld the user path -switches to the system path if the user is "". * It also cross-converts the username to ascii via punycode * @param username username or "" * @return the path to the user */ public static String homePathForUser(String username) { Preconditions.checkArgument(username != null, "null user"); // catch recursion if (username.startsWith(RegistryConstants.PATH_USERS)) { return username; } if (username.isEmpty()) { return RegistryConstants.PATH_SYSTEM_SERVICES; } // convert username to registry name String convertedName = convertUsername(username); return RegistryPathUtils.join(RegistryConstants.PATH_USERS, encodeForRegistry(convertedName)); }
/** * Buld the user path -switches to the system path if the user is "". * It also cross-converts the username to ascii via punycode * @param username username or "" * @return the path to the user */ public static String homePathForUser(String username) { Preconditions.checkArgument(username != null, "null user"); // catch recursion if (username.startsWith(RegistryConstants.PATH_USERS)) { return username; } if (username.isEmpty()) { return RegistryConstants.PATH_SYSTEM_SERVICES; } // convert username to registry name String convertedName = convertUsername(username); return RegistryPathUtils.join(RegistryConstants.PATH_USERS, encodeForRegistry(convertedName)); }
/** * Get the absolute path to where the service has registered itself. * This includes the base registry path * Null until the service is registered * @return the service registration path. */ public String getAbsoluteSelfRegistrationPath() { if (selfRegistrationPath == null) { return null; } String root = registryOperations.getConfig().getTrimmed( RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); return RegistryPathUtils.join(root, selfRegistrationPath); }
/** * Get the absolute path to where the service has registered itself. * This includes the base registry path * Null until the service is registered * @return the service registration path. */ public String getAbsoluteSelfRegistrationPath() { if (selfRegistrationPath == null) { return null; } String root = registryOperations.getConfig().getTrimmed( RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); return RegistryPathUtils.join(root, selfRegistrationPath); }
/** * Delete the children of a path -but not the path itself. * It is not an error if the path does not exist * @param path path to delete * @param recursive flag to request recursive deletes * @throws IOException IO problems */ public void deleteChildren(String path, boolean recursive) throws IOException { List<String> childNames = null; try { childNames = registryOperations.list(path); } catch (PathNotFoundException e) { return; } for (String childName : childNames) { String child = join(path, childName); registryOperations.delete(child, recursive); } }
/** * Delete the children of a path -but not the path itself. * It is not an error if the path does not exist * @param path path to delete * @param recursive flag to request recursive deletes * @throws IOException IO problems */ public void deleteChildren(String path, boolean recursive) throws IOException { List<String> childNames = null; try { childNames = registryOperations.list(path); } catch (PathNotFoundException e) { return; } for (String childName : childNames) { String child = join(path, childName); registryOperations.delete(child, recursive); } }