* 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("/");
//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,
}
public synchronized long getPos() throws IOException {
- return ceph_getpos();
+ return ceph_getpos(fileHandle);
}
@Override
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;
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.");
throw new IOException("Stream closed");
}
- int result = ceph_close();
+ int result = ceph_close(fileHandle);
if (result != 0) {
throw new IOException("Close failed!");
}
- 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,
public long getPos() throws IOException {
// change to get the position from Ceph client
- return ceph_getpos();
+ return ceph_getpos(fileHandle);
}
// writes a byte
// 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);
}
// 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");
throw new IOException("Stream closed");
}
- int result = ceph_close();
+ int result = ceph_close(fileHandle);
if (result != 0) {
throw new IOException("Close failed!");
}