From cd8e36996641f1dee8dc56685bf6746e1e2c09eb Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 30 Oct 2009 13:50:30 -0700 Subject: [PATCH] Hadoop: Various changes to CephFaker; not completed. --- src/client/hadoop/ceph/CephFaker.java | 76 ++++++++++++++++++++------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/src/client/hadoop/ceph/CephFaker.java b/src/client/hadoop/ceph/CephFaker.java index eff0a94cd175a..5ebd7cf260ef0 100644 --- a/src/client/hadoop/ceph/CephFaker.java +++ b/src/client/hadoop/ceph/CephFaker.java @@ -20,6 +20,7 @@ package org.apache.hadoop.fs.ceph; +import java.net.URI; import java.util.Hashtable; import java.io.FileNotFoundException; import java.io.IOException; @@ -44,6 +45,7 @@ class CephFaker extends CephFS { Hashtable files; Hashtable filenames; int fileCount = 0; + boolean initialized = false; public CephFaker(Configuration con, Log log) { super(con, log); @@ -53,19 +55,34 @@ class CephFaker extends CephFS { } protected boolean ceph_initializeClient(String args, int block_size) { - //let's remember the default block_size - blockSize = block_size; - /* for a real Ceph deployment, this starts up the client, - * sets debugging levels, etc. We just need to get the - * local FileSystem to use, and we'll ignore any - * command-line arguments. */ - try { - localFS = FileSystem.getLocal(conf); - localPrefix = conf.get("hadoop.tmp.dir", "/tmp"); - localFS.setWorkingDirectory(new Path(localPrefix)); - } - catch (IOException e) { - return false; + if (!initialized) { + //let's remember the default block_size + blockSize = block_size; + /* for a real Ceph deployment, this starts up the client, + * sets debugging levels, etc. We just need to get the + * local FileSystem to use, and we'll ignore any + * command-line arguments. */ + try { + localFS = FileSystem.getLocal(conf); + localFS.initialize(URI.create("file://localhost"), conf); + String userpath = "/user/" + System.getProperty("user.name"); + localPrefix = localFS.getWorkingDirectory().toString(); + int userpathinworkingdir = localPrefix.indexOf(userpath); + if (-1 == userpathinworkingdir) + userpathinworkingdir = localPrefix.length(); + localPrefix = localPrefix.substring(0, userpathinworkingdir); + + localFS.setWorkingDirectory(new Path(localPrefix + +"/user/" + + System.getProperty("user.name"))); + //I don't know why, but the unit tests expect the default + //working dir to be /user/username, so satisfy them! + debug("localPrefix is " + localPrefix, INFO); + } + catch (IOException e) { + return false; + } + initialized = true; } return true; } @@ -173,8 +190,10 @@ class CephFaker extends CephFS { try { FileStatus[] stats = localFS.listStatus(new Path(path)); String[] names = new String[stats.length]; + String name; for (int i=0; i