return env->NewStringUTF(address.c_str());
}
+/*
+ * Class: org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method: ceph_setTimes
+ * Signature: (Ljava/lang/String;JJ)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1setTimes
+(JNIEnv * env, jobject obj, jstring j_path, jlong mtime, jlong atime) {
+ const char *c_path = env->GetStringUTFChars(j_path, 0);
+ if(c_path == NULL) return -ENOMEM;
+
+ //build the mask for ceph_setattr
+ int mask = 0;
+ if (mtime!=-1) mask = CEPH_SETATTR_MTIME;
+ if (atime!=-1) mask |= CEPH_SETTATTR_ATIME;
+ //build a struct stat and fill it in!
+ struct stat attr;
+ attr.st_mtime = mtime;
+ attr.st_atime = atime;
+ //may need to fill in uid and gid here later on...
+ ceph_setattr(c_path, &attr, mask);
+}
+
/*
* Class: org_apache_hadoop_fs_ceph_CephInputStream
* Method: ceph_read
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1hosts
(JNIEnv *, jobject, jint, jlong);
+/*
+ * Class: org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method: ceph_setTimes
+ * Signature: (Ljava/lang/String;JJ)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1setTimes
+ (JNIEnv *, jobject, jstring, jlong, jlong);
+
/*
* Class: org_apache_hadoop_fs_ceph_CephInputStream
* Method: ceph_read
private native boolean ceph_stat(String path, Stat fill);
private native int ceph_replication(String path);
private native String ceph_hosts(int fh, long offset);
+ private native int ceph_setTimes(String path, long mtime, long atime);
public CephFileSystem() {
debug("CephFileSystem:enter");
ceph_setPermission(abs_path.toString(), permission.toShort());
}
+ /**
+ * Set access/modification times of a file.
+ * @param p The path
+ * @param mtime Set modification time in number of millis since Jan 1, 1970.
+ * @param atime Set access time in number of millis since Jan 1, 1970.
+ */
+@Override
+ public void setTimes(Path p, long mtime, long atime) throws IOException {
+ if (!initialized) throw new IOException ("You have to initialize the"
+ +"CephFileSystem before calling other methods.");
+ Path abs_path = makeAbsolute(p);
+ //libhadoopcephfs respects the -1 "don't set" meanings, but we
+ //need to convert these times in millis to times in seconds here
+ if (mtime != -1) mtime /= 1000;
+ if (atime != -1) atime /= 1000;
+ int r = ceph_setTimes(abs_path.toString(), mtime, atime);
+ if (r<0) throw new IOException ("Failed to set times on path "
+ + abs_path.toString() + " Error code: " + r);
+}
+
/**
* In order to run this with Hadoop .20, I had to revert back to using
* a boolean instead of the CreateFlag.
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
(JNIEnv *, jobject, jstring, jstring);
-/*
- * Class: org_apache_hadoop_fs_ceph_CephFileSystem
- * Method: ceph_copyFromLocalFile
- * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1copyFromLocalFile
- (JNIEnv *, jobject, jstring, jstring);
-
-/*
- * Class: org_apache_hadoop_fs_ceph_CephFileSystem
- * Method: ceph_copyToLocalFile
- * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1copyToLocalFile
- (JNIEnv *, jobject, jstring, jstring);
-
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem
* Method: ceph_getcwd
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1hosts
(JNIEnv *, jobject, jint, jlong);
+/*
+ * Class: org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method: ceph_setTimes
+ * Signature: (Ljava/lang/String;JJ)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1setTimes
+ (JNIEnv *, jobject, jstring, jlong, jlong);
+
#ifdef __cplusplus
}
#endif