*/
abstract protected boolean ceph_stat(String path, CephFileSystem.Stat fill);
- /*
- * Statfs a filesystem in a custom format defined in CephFileSystem.
- * Inputs:
- * String path: A path on the filesystem that you wish to stat.
- * CephStat fill: The CephStat object to fill.
- * Returns: 0 if successful and the CephStat is filled; a negative
- * error code otherwise.
- */
- abstract protected int ceph_statfs(String path, CephFileSystem.CephStat fill);
-
/*
* Check how many times a file should be replicated. If it is,
* degraded it may not actually be replicated this often.
* int fh: a file descriptor
* Returns: an int containing the number of times replicated.
*/
- abstract protected int ceph_replication(int fh);
+ abstract protected int ceph_replication(String path);
/*
* Find the IP address of the primary OSD for a given file and offset.
import org.apache.commons.logging.Log;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.FsStatus;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
if (localFS.mkdirs(new Path(path), new FsPermission((short) mode))) {
return 0;
}
- } catch (FileAlreadyExistsException fe) {
- return ENOTDIR;
} catch (IOException e) {}
- if (ceph_isdirectory(path)) {
+ if (ceph_isdirectory(path)) { // apparently it already existed
return -EEXIST;
- } // apparently it already existed
+ } else if (ceph_isfile(path)) {
+ return -ENOTDIR;
+ }
return -1;
}
return ret;
}
- protected int ceph_statfs(String pth, CephFileSystem.CephStat fill) {
- pth = prepare_path(pth);
- try {
- FsStatus stat = localFS.getStatus();
-
- fill.capacity = stat.getCapacity();
- fill.used = stat.getUsed();
- fill.remaining = stat.getRemaining();
- return 0;
- } catch (Exception e) {}
- return -1; // failure;
- }
-
protected int ceph_replication(String path) {
path = prepare_path(path);
int ret = -1; // -1 for failure
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.util.Progressable;
import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FsStatus;
-import org.apache.hadoop.fs.CreateFlag;
/**
"mkdirs: make directory " + abs_path + "Failing with result " + result,
ceph.WARN);
if (ceph.ENOTDIR == result) {
- throw new FileAlreadyExistsException("Parent path is not a directory");
+ throw new IOException("Parent path is not a directory");
}
return false;
} else {
* Create a new file and open an FSDataOutputStream that's connected to it.
* @param path The file to create.
* @param permission The permissions to apply to the file.
- * @param flag If CreateFlag.OVERWRITE, overwrite any existing
- * file with this name; otherwise don't.
+ * @param overwrite If true, overwrite any existing file with
+ * this name; otherwise don't.
* @param bufferSize Ceph does internal buffering, but you can buffer
* in the Java code too if you like.
* @param replication Ignored by Ceph. This can be
public FSDataOutputStream create(Path path,
FsPermission permission,
boolean overwrite,
- // boolean overwrite,
int bufferSize,
short replication,
long blockSize,
return locations;
}
- /**
- * Get usage statistics on the Ceph filesystem.
- * @param path A path to the partition you're interested in.
- * Ceph doesn't partition, so this is ignored.
- * @return FsStatus reporting capacity, usage, and remaining space.
- * @throws IOException if initialize() hasn't been called, or the
- * stat somehow fails.
- */
- @Override
- public FsStatus getStatus(Path path) throws IOException {
- if (!initialized) {
- throw new IOException(
- "You have to initialize the "
- + "CephFileSystem before calling other methods.");
- }
- ceph.debug("getStatus:enter with path " + path, ceph.DEBUG);
- Path abs_path = makeAbsolute(path);
-
- // currently(Ceph .16) Ceph actually ignores the path
- // but we still pass it in; if Ceph stops ignoring we may need more
- // error-checking code.
- CephStat ceph_stat = new CephStat();
-
- ceph.debug("getStatus:calling ceph_statfs from Java", ceph.TRACE);
- int result = ceph.ceph_statfs(abs_path.toString(), ceph_stat);
-
- if (result != 0) {
- throw new IOException(
- "Somehow failed to statfs the Ceph filesystem. Error code: " + result);
- }
- ceph.debug("getStatus:exit successfully", ceph.DEBUG);
- return new FsStatus(ceph_stat.capacity, ceph_stat.used, ceph_stat.remaining);
- }
+ public boolean delete(Path path) throws IOException {
+ return delete(path, false);
+ }
/**
* Delete the given path, and optionally its children.
public Stat() {}
}
-
-
- static class CephStat {
- public long capacity;
- public long used;
- public long remaining;
-
- public CephStat() {}
- }
}
// we write a constructor so we can load the libraries
public CephTalker(Configuration conf, Log log) {
super(conf, log);
- System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so");
+ System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
cluster = 0;
}
protected native boolean ceph_stat(String path, CephFileSystem.Stat fill);
- protected native int ceph_statfs(String Path, CephFileSystem.CephStat fill);
-
- protected native int ceph_replication(int fh);
+ protected native int ceph_replication(String Path);
protected native String ceph_hosts(int fh, long offset);