1
// -*- mode:Java; tab-width:2; c-basic-offset:2; indent-tabs-mode:t -*-
5
* Licensed under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* permissions and limitations under the License.
18
* Wraps a number of native function calls to communicate with the Ceph
21
package org.apache.hadoop.fs.ceph;
24
import org.apache.hadoop.conf.Configuration;
25
import org.apache.commons.logging.Log;
28
class CephTalker extends CephFS {
29
// JNI doesn't give us any way to store pointers, so use a long.
30
// Here we're assuming pointers aren't longer than 8 bytes.
33
// we write a constructor so we can load the libraries
34
public CephTalker(Configuration conf, Log log) {
35
System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so");
36
System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
40
protected native boolean ceph_initializeClient(String arguments, int block_size);
42
protected native String ceph_getcwd();
44
protected native boolean ceph_setcwd(String path);
46
protected native boolean ceph_rmdir(String path);
48
protected native boolean ceph_unlink(String path);
50
protected native boolean ceph_rename(String old_path, String new_path);
52
protected native boolean ceph_exists(String path);
54
protected native long ceph_getblocksize(String path);
56
protected native boolean ceph_isdirectory(String path);
58
protected native boolean ceph_isfile(String path);
60
protected native String[] ceph_getdir(String path);
62
protected native int ceph_mkdirs(String path, int mode);
64
protected native int ceph_open_for_append(String path);
66
protected native int ceph_open_for_read(String path);
68
protected native int ceph_open_for_overwrite(String path, int mode);
70
protected native int ceph_close(int filehandle);
72
protected native boolean ceph_setPermission(String path, int mode);
74
protected native boolean ceph_kill_client();
76
protected native boolean ceph_stat(String path, CephFileSystem.Stat fill);
78
protected native int ceph_replication(String Path);
80
protected native String[] ceph_hosts(int fh, long offset);
82
protected native int ceph_setTimes(String path, long mtime, long atime);
84
protected native long ceph_getpos(int fh);
86
protected native int ceph_write(int fh, byte[] buffer, int buffer_offset, int length);
88
protected native int ceph_read(int fh, byte[] buffer, int buffer_offset, int length);
90
protected native long ceph_seek_from_start(int fh, long pos);