From bc372c7de7f83f3006980b22d60a6563b1464af3 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 18 Aug 2009 16:30:11 -0700 Subject: [PATCH] Hadoop: Put guards up to prevent a nasty bug in case of unspecified preferences, and the unlikely case that initialize is called twice. --- src/client/hadoop/ceph/CephFileSystem.java | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index 993416fea198a..a2565d6d309c1 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -110,29 +110,35 @@ public class CephFileSystem extends FileSystem { * Starts up the connection to Ceph, reads in configuraton options, etc. * @param uri The URI for this filesystem. * @param conf The Hadoop Configuration to retrieve properties from. - * @throws IOException if the Ceph client initialization fails. + * @throws IOException if the Ceph client initialization fails + * or necessary properties are unset. */ @Override public void initialize(URI uri, Configuration conf) throws IOException { debug("initialize:enter"); - System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so"); - System.load(conf.get("fs.ceph.libDir")+"/libceph.so"); - super.initialize(uri, conf); - //store.initialize(uri, conf); - setConf(conf); - this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority()); - - fs_default_name = conf.get("fs.default.name"); - monAddr = conf.get("fs.ceph.monAddr"); - cephDebugLevel = conf.get("fs.ceph.debugLevel"); - debug = ("true".equals(conf.get("fs.ceph.debug"))); - // Initializes the client - if (!ceph_initializeClient(cephDebugLevel, monAddr)) { - throw new IOException("Ceph initialization failed!"); - } - initialized = true; - debug("Initialized client. Setting cwd to /"); - ceph_setcwd("/"); + if (!initialized) { + System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so"); + System.load(conf.get("fs.ceph.libDir")+"/libceph.so"); + super.initialize(uri, conf); + //store.initialize(uri, conf); + setConf(conf); + this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority()); + + conf.setIfUnset("fs.ceph.debugLevel", "0"); + conf.setIfUnset("fs.ceph.debug", "false"); + fs_default_name = conf.get("fs.default.name"); + monAddr = conf.get("fs.ceph.monAddr"); + if (monAddr == NULL) throw new IOException("You must specify a Ceph monito address!"); + cephDebugLevel = conf.get("fs.ceph.debugLevel"); + debug = ("true".equals(conf.get("fs.ceph.debug"))); + // Initializes the client + if (!ceph_initializeClient(cephDebugLevel, monAddr)) { + throw new IOException("Ceph initialization failed!"); + } + initialized = true; + debug("Initialized client. Setting cwd to /"); + ceph_setcwd("/"); + } debug("initialize:exit"); } -- 2.39.5