public static List<ConfigKeyPath> getConfigKeyPath(List<String> input) { List<ConfigKeyPath> result = new ArrayList<>(); for (String s : input) { result.add(getConfigKeyPath(s)); } return result; }
/** * * @param configKeyURI - URI provided by client , which could missing authority/store root directory * @param cs - ConfigStore corresponding to the input URI. Require input URI's scheme/authority name * match ConfigStore's scheme/authority * @return - {@link ConfigKeyPath} for the relative path */ public static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs) { checkMatchingSchemeAndAuthority(configKeyURI, cs); // Example store root is etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest URI relative = cs.getStoreURI().relativize(configKeyURI); return getConfigKeyPath(relative.getPath()); }
/** * Utility method to check whether one URI is the ancestor of the other * * return true iff both URI's scheme/authority name match and ancestor's path is the prefix of the descendant's path * @param descendant: the descendant URI to check * @param ancestor : the ancestor URI to check * @return */ public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }
public static List<ConfigKeyPath> getConfigKeyPath(List<String> input) { List<ConfigKeyPath> result = new ArrayList<>(); for (String s : input) { result.add(getConfigKeyPath(s)); } return result; }
/** * * @param configKeyURI - URI provided by client , which could missing authority/store root directory * @param cs - ConfigStore corresponding to the input URI. Require input URI's scheme/authority name * match ConfigStore's scheme/authority * @return - {@link ConfigKeyPath} for the relative path */ public static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs) { checkMatchingSchemeAndAuthority(configKeyURI, cs); // Example store root is etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest URI relative = cs.getStoreURI().relativize(configKeyURI); return getConfigKeyPath(relative.getPath()); }
/** * Utility method to check whether one URI is the ancestor of the other * * return true iff both URI's scheme/authority name match and ancestor's path is the prefix of the descendant's path * @param descendant: the descendant URI to check * @param ancestor : the ancestor URI to check * @return */ public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }