From 9298535fda76c6da3758c5d5d57d2c41fc1b3eed Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 22 Oct 2009 13:58:01 -0700 Subject: [PATCH] hadoop: minor cleanup edits --- src/client/hadoop/ceph/CephFS.java | 16 ++++++++++------ src/client/hadoop/ceph/CephFileSystem.java | 7 ++----- src/client/hadoop/ceph/CephTalker.java | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/client/hadoop/ceph/CephFS.java b/src/client/hadoop/ceph/CephFS.java index 544cb93faf2ef..0111ebd7f6df0 100644 --- a/src/client/hadoop/ceph/CephFS.java +++ b/src/client/hadoop/ceph/CephFS.java @@ -34,6 +34,9 @@ abstract class CephFS { protected static final int TRACE = 5; protected static final int NOLOG = 6; + protected static final int EEXIST = 17; + protected static final int ENOENT = 2; + private boolean debug = false; private Log LOG; @@ -165,7 +168,7 @@ abstract class CephFS { */ abstract protected boolean ceph_kill_client(); /* - * Get the statistics on a path returned in a custom format defined below. + * Get the statistics on a path returned in a custom format. * Inputs: * String path: The path to stat. * Stat fill: The stat object to fill. @@ -177,9 +180,10 @@ abstract class CephFS { * Inputs: * String path: A path on the filesystem that you wish to stat. * CephStat fill: The CephStat object to fill. - * Returns: true if successful and the CephStat is filled; false otherwise. + * Returns: 0 if successful and the CephStat is filled; a negative + * error code otherwise. */ - abstract protected int ceph_statfs(String Path, CephFileSystem.CephStat fill); + abstract protected int ceph_statfs(String path, CephFileSystem.CephStat fill); /* * Check how many times a path should be replicated (if it is * degraded it may not actually be replicated this often). @@ -189,7 +193,7 @@ abstract class CephFS { */ abstract protected int ceph_replication(String path); /* - * Find the IP:port addresses of the primary OSD for a given file and offset. + * Find the IP address of the primary OSD for a given file and offset. * Inputs: * int fh: The filehandle for the file. * long offset: The offset to get the location of. @@ -234,7 +238,7 @@ abstract class CephFS { * the data from the given offset! * Returns: the number of bytes read on success (as an int), * or an error code otherwise. */ - protected native int ceph_read(int fh, byte[] buffer, int buffer_offset, int length); + abstract protected int ceph_read(int fh, byte[] buffer, int buffer_offset, int length); /* * Seeks to the given position in the given file. * Inputs: @@ -242,7 +246,7 @@ abstract class CephFS { * long pos: The position to seek to. * Returns: the new position (as a long) of the filehandle on success, * or a negative error code on failure. */ - protected native long ceph_seek_from_start(int fh, long pos); + abstract protected long ceph_seek_from_start(int fh, long pos); protected void debug(String statement, int priority) { if (debug) System.err.println(statement); diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index 8760f3837ed44..4aea7a2467132 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -63,9 +63,6 @@ import org.apache.hadoop.fs.CreateFlag; */ public class CephFileSystem extends FileSystem { - protected static final int EEXIST = 17; - protected static final int ENOENT = 2; - private URI uri; private final Path root; @@ -491,7 +488,7 @@ public class CephFileSystem extends FileSystem { Path parent = abs_path.getParent(); if (parent != null) { // if parent is root, we're done int r = ceph.ceph_mkdirs(parent.toString(), permission.toShort()); - if (!(r==0 || r==-EEXIST)) + if (!(r==0 || r==-ceph.EEXIST)) throw new IOException ("Error creating parent directory; code: " + r); } if (progress!=null) progress.progress(); @@ -528,7 +525,7 @@ public class CephFileSystem extends FileSystem { int fh = ceph.ceph_open_for_read(abs_path.toString()); if (fh < 0) { //uh-oh, something's bad! - if (fh == -ENOENT) //well that was a stupid open + if (fh == -ceph.ENOENT) //well that was a stupid open throw new IOException("open: absolute path \"" + abs_path.toString() + "\" does not exist"); else //hrm...the file exists but we can't open it :( diff --git a/src/client/hadoop/ceph/CephTalker.java b/src/client/hadoop/ceph/CephTalker.java index 0e6ee502ef21b..20b494b7342ed 100644 --- a/src/client/hadoop/ceph/CephTalker.java +++ b/src/client/hadoop/ceph/CephTalker.java @@ -54,4 +54,6 @@ class CephTalker extends CephFS { protected native int ceph_setTimes(String path, long mtime, long atime); protected native long ceph_getpos(int fh); protected native int ceph_write(int fh, byte[] buffer, int buffer_offset, int length); + protected native int ceph_read(int fh, byte[] buffer, int buffer_offset, int length); + protected native long ceph_seek_from_start(int fh, long pos); } -- 2.39.5