From f93045296870cb6938d9b4356a4f3198cbebe3ba Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 29 Feb 2012 19:25:30 +0530 Subject: hdfs/plugin: Fix regex for parsing pathinfo string Change-Id: I3a5d78f39a15c8029cd40225013e9ac40beb9373 BUG: 797116 Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.com/2844 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- .../apache/hadoop/fs/glusterfs/GlusterFSXattr.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'hdfs') diff --git a/hdfs/0.20.2/src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFSXattr.java b/hdfs/0.20.2/src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFSXattr.java index 54946585930..18e9003b43e 100644 --- a/hdfs/0.20.2/src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFSXattr.java +++ b/hdfs/0.20.2/src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFSXattr.java @@ -148,9 +148,18 @@ public class GlusterFSXattr { while ( (s = brInput.readLine()) != null ) cmdOut += s; - Pattern pattern = Pattern.compile("<(.*?):(.*?)>"); + /** + * TODO: Use a single regex for extracting posix paths as well + * as xlator counts for layout matching. + */ + + Pattern pattern = Pattern.compile("<(.*?)[:\\(](.*?)>"); Matcher matcher = pattern.matcher(cmdOut); + Pattern p_px = Pattern.compile(".*?:(.*)"); + Matcher m_px; + String gibberish_path; + s = null; while (matcher.find()) { xlator = matcher.group(1); @@ -169,8 +178,14 @@ public class GlusterFSXattr { if (vol.get(key) == null) vol.put(key, new ArrayList()); - vol.get(key).add(matcher.group(2)); + gibberish_path = matcher.group(2); + + /* extract posix path from the gibberish string */ + m_px = p_px.matcher(gibberish_path); + if (!m_px.find()) + throw new IOException("Cannot extract posix path"); + vol.get(key).add(m_px.group(1)); continue; } -- cgit