From adf047763e184d317b817da5f71d725c4e6acba6 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 22 Jul 2009 14:56:47 -0700 Subject: [PATCH] Hadoop: Remove the silly clientPointer convention from the Java. Since we're using libceph now it's unneeded and a waste of space. --- src/client/hadoop/ceph/CephFileSystem.java | 67 ++++++-------------- src/client/hadoop/ceph/CephInputStream.java | 22 +++---- src/client/hadoop/ceph/CephOutputStream.java | 27 +++----- 3 files changed, 35 insertions(+), 81 deletions(-) diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index e1079bdf89f8f..8ac56537ecfa5 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -55,55 +55,26 @@ public class CephFileSystem extends FileSystem { * include wrapper functions to automatically add the parameter. */ - private boolean ceph_copyFromLocalFile(String localPath, String cephPath) - { return ceph_copyFromLocalFile(clientPointer, localPath, cephPath); } - private boolean ceph_copyToLocalFile(String cephPath, String localPath) - { return ceph_copyToLocalFile(clientPointer, cephPath, localPath); } - private String ceph_getcwd() { return ceph_getcwd(clientPointer); } - private boolean ceph_setcwd(String path) { return ceph_setcwd(clientPointer, path); } - private boolean ceph_rmdir(String path) { return ceph_rmdir(clientPointer, path); } - private boolean ceph_mkdir(String path) { return ceph_mkdir(clientPointer, path); } - private boolean ceph_unlink(String path) { return ceph_unlink(clientPointer, path); } - private boolean ceph_rename(String old_path, String new_path) { return ceph_rename(clientPointer, old_path, new_path); } - private boolean ceph_exists(String path) { return ceph_exists(clientPointer, path); } - private long ceph_getblocksize(String path) { return ceph_getblocksize(clientPointer, path); } - private long ceph_getfilesize(String path) { return ceph_getfilesize(clientPointer, path); } - private boolean ceph_isdirectory(String path) { return ceph_isdirectory(clientPointer, path); } - private boolean ceph_isfile(String path) { return ceph_isfile(clientPointer, path); } - private String[] ceph_getdir(String path) { return ceph_getdir(clientPointer, path); } - private int ceph_mkdirs(String path, int mode) { return ceph_mkdirs(clientPointer, path, mode); } - private int ceph_open_for_append(String path) { return ceph_open_for_append(clientPointer, path); } - private int ceph_open_for_read(String path) { return ceph_open_for_read(clientPointer, path); } - private int ceph_open_for_overwrite(String path, int mode) { return ceph_open_for_overwrite(clientPointer, path, mode); } - - private boolean ceph_kill_client() { - System.out.println("Killing Ceph client with pointer " + clientPointer); - return ceph_kill_client(clientPointer); - } - private native long ceph_initializeClient(); - private native boolean ceph_copyFromLocalFile (long client, String localPath, String cephPath); - private native boolean ceph_copyToLocalFile (long client, String cephPath, String localPath); - private native String ceph_getcwd (long client); - private native boolean ceph_setcwd (long client, String path); - private native boolean ceph_rmdir (long client, String path); - private native boolean ceph_mkdir (long client, String path); - private native boolean ceph_unlink (long client, String path); - private native boolean ceph_rename (long client, String old_path, String new_path); - private native boolean ceph_exists (long client, String path); - private native long ceph_getblocksize (long client, String path); - private native long ceph_getfilesize (long client, String path); - private native boolean ceph_isdirectory (long client, String path); - private native boolean ceph_isfile (long client, String path); - private native String[]ceph_getdir (long client, String path); - private native int ceph_mkdirs (long client, String path, int mode); - private native int ceph_open_for_append (long client, String path); - private native int ceph_open_for_read (long client, String path); - private native int ceph_open_for_overwrite(long client, String path, int mode); - private native boolean ceph_kill_client (long client); - - - + private native boolean ceph_copyFromLocalFile(String localPath, String cephPath); + private native boolean ceph_copyToLocalFile(String cephPath, String localPath); + private native String ceph_getcwd(); + private native boolean ceph_setcwd(String path); + private native boolean ceph_rmdir(String path); + private native boolean ceph_mkdir(String path); + private native boolean ceph_unlink(String path); + private native boolean ceph_rename(String old_path, String new_path); + private native boolean ceph_exists(String path); + private native long ceph_getblocksize(String path); + private native long ceph_getfilesize(String path); + private native boolean ceph_isdirectory(String path); + private native boolean ceph_isfile(String path); + private native String[] ceph_getdir(String path); + private native int ceph_mkdirs(String path, int mode); + private native int ceph_open_for_append(String path); + private native int ceph_open_for_read(String path); + private native int ceph_open_for_overwrite(String path, int mode); + private native boolean ceph_kill_client(); public CephFileSystem() { root = new Path("/"); diff --git a/src/client/hadoop/ceph/CephInputStream.java b/src/client/hadoop/ceph/CephInputStream.java index 71b09e16e843b..cd5823baf9496 100644 --- a/src/client/hadoop/ceph/CephInputStream.java +++ b/src/client/hadoop/ceph/CephInputStream.java @@ -38,16 +38,10 @@ class CephInputStream extends FSInputStream { //private long blockEnd = -1; - private native int ceph_read(long client, int fh, byte[] buffer, int buffer_offset, int length); - private native long ceph_seek_from_start(long client, int fh, long pos); - private native long ceph_getpos(long client, int fh); - private native int ceph_close(long client, int fh); - - private int ceph_read(byte[] buffer, int buffer_offset, int length) - { return ceph_read(clientPointer, fileHandle, buffer, buffer_offset, length); } - private long ceph_seek_from_start(long pos) { return ceph_seek_from_start(clientPointer, fileHandle, pos); } - private long ceph_getpos() { return ceph_getpos(clientPointer, fileHandle); } - private int ceph_close() { return ceph_close(clientPointer, fileHandle); } + private native int ceph_read(int fh, byte[] buffer, int buffer_offset, int length); + private native long ceph_seek_from_start(int fh, long pos); + private native long ceph_getpos(int fh); + private native int ceph_close(int fh); /* public S3InputStream(Configuration conf, FileSystemStore store, @@ -78,7 +72,7 @@ class CephInputStream extends FSInputStream { } public synchronized long getPos() throws IOException { - return ceph_getpos(); + return ceph_getpos(fileHandle); } @Override @@ -93,7 +87,7 @@ class CephInputStream extends FSInputStream { throw new IOException("CephInputStream.seek: failed seeking to position " + targetPos + " on fd " + fileHandle + ": Cannot seek after EOF " + fileLength); } - ceph_seek_from_start(targetPos); + ceph_seek_from_start(fileHandle, targetPos); } //failovers are handled by the Ceph code at a very low level; @@ -146,7 +140,7 @@ class CephInputStream extends FSInputStream { return -1; } // actually do the read - int result = ceph_read(buf, off, len); + int result = ceph_read(fileHandle, buf, off, len); if (result < 0) System.out.println("CephInputStream.read: Reading " + len + " bytes from fd " + fileHandle + " failed."); @@ -166,7 +160,7 @@ class CephInputStream extends FSInputStream { throw new IOException("Stream closed"); } - int result = ceph_close(); + int result = ceph_close(fileHandle); if (result != 0) { throw new IOException("Close failed!"); } diff --git a/src/client/hadoop/ceph/CephOutputStream.java b/src/client/hadoop/ceph/CephOutputStream.java index 254c83830b4bc..916d1c1925120 100644 --- a/src/client/hadoop/ceph/CephOutputStream.java +++ b/src/client/hadoop/ceph/CephOutputStream.java @@ -54,21 +54,10 @@ class CephOutputStream extends OutputStream { - private long ceph_seek_from_start(long pos) { - return ceph_seek_from_start(clientPointer, fileHandle, pos); - } - private long ceph_getpos() { - return ceph_getpos(clientPointer, fileHandle); - } - private int ceph_close() { return ceph_close(clientPointer, fileHandle); } - private int ceph_write(byte[] buffer, int buffer_offset, int length) - { return ceph_write(clientPointer, fileHandle, buffer, buffer_offset, length); } - - - private native long ceph_seek_from_start(long client, int fh, long pos); - private native long ceph_getpos(long client, int fh); - private native int ceph_close(long client, int fh); - private native int ceph_write(long client, int fh, byte[] buffer, int buffer_offset, int length); + private native long ceph_seek_from_start(int fh, long pos); + private native long ceph_getpos(int fh); + private native int ceph_close(int fh); + private native int ceph_write(int fh, byte[] buffer, int buffer_offset, int length); /* public CephOutputStream(Configuration conf, FileSystemStore store, @@ -110,7 +99,7 @@ class CephOutputStream extends OutputStream { public long getPos() throws IOException { // change to get the position from Ceph client - return ceph_getpos(); + return ceph_getpos(fileHandle); } // writes a byte @@ -125,7 +114,7 @@ class CephOutputStream extends OutputStream { // Stick the byte in a buffer and write it byte buf[] = new byte[1]; buf[0] = (byte) b; - int result = ceph_write(buf, 0, 1); + int result = ceph_write(fileHandle, buf, 0, 1); if (1 != result) System.out.println("CephOutputStream.write: failed writing a single byte to fd " + fileHandle + ": Ceph write() result = " + result); @@ -157,7 +146,7 @@ class CephOutputStream extends OutputStream { } // write! - int result = ceph_write(buf, off, len); + int result = ceph_write(fileHandle, buf, off, len); if (result < 0) { throw new IOException("CephOutputStream.write: Write of " + len + "bytes to fd " + fileHandle + " failed"); @@ -184,7 +173,7 @@ class CephOutputStream extends OutputStream { throw new IOException("Stream closed"); } - int result = ceph_close(); + int result = ceph_close(fileHandle); if (result != 0) { throw new IOException("Close failed!"); } -- 2.39.5