From: Greg Farnum Date: Thu, 29 Oct 2009 01:36:22 +0000 (-0700) Subject: Hadoop: Update constructor/initialize usage a bit X-Git-Tag: v0.18~128^2~50 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=95d7e5f3c2d92cd29d0ba5bb52becc23aeeb6dc8;p=ceph.git Hadoop: Update constructor/initialize usage a bit --- diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index 6d05e8ff80c8..a14d9a74fd1d 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -79,6 +79,17 @@ public class CephFileSystem extends FileSystem { root = new Path("/"); } + /** + * Used for testing purposes, this constructor + * sets the given CephFS instead of defaulting to a + * CephTalker (with its assumed real Ceph instance to talk to). + */ + public CephFileSystem(CephFS ceph_fs, String default_path) { + root = new Path("/"); + ceph = ceph_fs; + fs_default_name = default_path; + } + /** * Lets you get the URI of this CephFileSystem. * @return the URI. @@ -109,8 +120,9 @@ public class CephFileSystem extends FileSystem { if (ceph == null) { ceph = new CephTalker(conf, LOG); } - - fs_default_name = conf.get("fs.default.name"); + if (null == fs_default_name) { + fs_default_name = conf.get("fs.default.name"); + } //build up the arguments for Ceph String arguments = "CephFSInterface"; arguments += conf.get("fs.ceph.commandLine", ""); @@ -149,17 +161,6 @@ public class CephFileSystem extends FileSystem { ceph.debug("initialize:exit", ceph.DEBUG); } - /** - * Used for testing purposes, this version of initialize - * sets the given CephFS instead of defaulting to a - * CephTalker (with its assumed real Ceph instance to talk to). - */ - protected void initialize(URI uri, Configuration conf, CephFS ceph_fs) - throws IOException{ - ceph = ceph_fs; - initialize(uri, conf); - } - /** * Close down the CephFileSystem. Runs the base-class close method * and then kills the Ceph client itself. diff --git a/src/client/hadoop/ceph/TestCeph.java b/src/client/hadoop/ceph/TestCeph.java index d740a6df481a..eaafab0ba196 100644 --- a/src/client/hadoop/ceph/TestCeph.java +++ b/src/client/hadoop/ceph/TestCeph.java @@ -25,15 +25,18 @@ import java.io.IOException; import java.net.URI; import org.apache.hadoop.fs.FileSystemContractBaseTest; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; public class TestCeph extends FileSystemContractBaseTest { @Override protected void setUp() throws IOException { Configuration conf = new Configuration(); - CephFileSystem cephfs = new CephFileSystem(); - CephFaker cephfaker = new CephFaker(conf, cephfs.LOG); - cephfs.initialize(URI.create("ceph://null"), conf, cephfaker); + CephFaker cephfaker = new CephFaker(conf, FileSystem.LOG); + CephFileSystem cephfs = new CephFileSystem(cephfaker, "ceph://null"); + cephfs.initialize(URI.create("ceph://null"), conf); fs = cephfs; + cephfs.setWorkingDirectory(new Path(getDefaultWorkingDirectory())); } }