00001
00019 #ifndef LIBHDFS_HDFS_H
00020 #define LIBHDFS_HDFS_H
00021
00022 #include <sys/types.h>
00023 #include <sys/stat.h>
00024
00025 #include <fcntl.h>
00026 #include <stdio.h>
00027 #include <stdint.h>
00028 #include <string.h>
00029 #include <stdlib.h>
00030 #include <time.h>
00031 #include <errno.h>
00032
00033 #include <jni.h>
00034
00035 #ifndef O_RDONLY
00036 #define O_RDONLY 1
00037 #endif
00038
00039 #ifndef O_WRONLY
00040 #define O_WRONLY 2
00041 #endif
00042
00043 #ifndef EINTERNAL
00044 #define EINTERNAL 255
00045 #endif
00046
00047
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052
00057 typedef int32_t tSize;
00058 typedef time_t tTime;
00059 typedef int64_t tOffset;
00060 typedef uint16_t tPort;
00061 typedef enum tObjectKind {
00062 kObjectKindFile = 'F',
00063 kObjectKindDirectory = 'D',
00064 } tObjectKind;
00065
00066
00070 typedef void* hdfsFS;
00071
00072
00076 enum hdfsStreamType
00077 {
00078 UNINITIALIZED = 0,
00079 INPUT = 1,
00080 OUTPUT = 2,
00081 };
00082
00083
00087 struct hdfsFile_internal {
00088 void* file;
00089 enum hdfsStreamType type;
00090 };
00091 typedef struct hdfsFile_internal* hdfsFile;
00092
00093
00107 hdfsFS hdfsConnectAsUser(const char* host, tPort port, const char *user , const char *groups[], int groups_size );
00108
00109
00121 hdfsFS hdfsConnect(const char* host, tPort port);
00122
00123
00130 int hdfsDisconnect(hdfsFS fs);
00131
00132
00147 hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags,
00148 int bufferSize, short replication, tSize blocksize);
00149
00150
00157 int hdfsCloseFile(hdfsFS fs, hdfsFile file);
00158
00159
00166 int hdfsExists(hdfsFS fs, const char *path);
00167
00168
00177 int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos);
00178
00179
00186 tOffset hdfsTell(hdfsFS fs, hdfsFile file);
00187
00188
00198 tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length);
00199
00200
00211 tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position,
00212 void* buffer, tSize length);
00213
00214
00223 tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer,
00224 tSize length);
00225
00226
00233 int hdfsFlush(hdfsFS fs, hdfsFile file);
00234
00235
00243 int hdfsAvailable(hdfsFS fs, hdfsFile file);
00244
00245
00254 int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
00255
00256
00265 int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
00266
00267
00274 int hdfsDelete(hdfsFS fs, const char* path);
00275
00276
00284 int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath);
00285
00286
00295 char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize);
00296
00297
00305 int hdfsSetWorkingDirectory(hdfsFS fs, const char* path);
00306
00307
00315 int hdfsCreateDirectory(hdfsFS fs, const char* path);
00316
00317
00325 int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication);
00326
00327
00331 typedef struct {
00332 tObjectKind mKind;
00333 char *mName;
00334 tTime mLastMod;
00335 tOffset mSize;
00336 short mReplication;
00337 tOffset mBlockSize;
00338 char *mOwner;
00339 char *mGroup;
00340 short mPermissions;
00341 tTime mLastAccess;
00342 } hdfsFileInfo;
00343
00344
00354 hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path,
00355 int *numEntries);
00356
00357
00367 hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path);
00368
00369
00376 void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries);
00377
00378
00391 char*** hdfsGetHosts(hdfsFS fs, const char* path,
00392 tOffset start, tOffset length);
00393
00394
00401 void hdfsFreeHosts(char ***blockHosts);
00402
00403
00409 tOffset hdfsGetDefaultBlockSize(hdfsFS fs);
00410
00411
00417 tOffset hdfsGetCapacity(hdfsFS fs);
00418
00419
00425 tOffset hdfsGetUsed(hdfsFS fs);
00426
00435 int hdfsChown(hdfsFS fs, const char* path, const char *owner, const char *group);
00436
00444 int hdfsChmod(hdfsFS fs, const char* path, short mode);
00445
00454 int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime);
00455
00456 #ifdef __cplusplus
00457 }
00458 #endif
00459
00460 #endif
00461