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
00105 hdfsFS hdfsConnect(const char* host, tPort port);
00106
00107
00114 int hdfsDisconnect(hdfsFS fs);
00115
00116
00130 hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags,
00131 int bufferSize, short replication, tSize blocksize);
00132
00133
00140 int hdfsCloseFile(hdfsFS fs, hdfsFile file);
00141
00142
00149 int hdfsExists(hdfsFS fs, const char *path);
00150
00151
00160 int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos);
00161
00162
00169 tOffset hdfsTell(hdfsFS fs, hdfsFile file);
00170
00171
00181 tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length);
00182
00183
00194 tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position,
00195 void* buffer, tSize length);
00196
00197
00206 tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer,
00207 tSize length);
00208
00209
00216 int hdfsFlush(hdfsFS fs, hdfsFile file);
00217
00218
00226 int hdfsAvailable(hdfsFS fs, hdfsFile file);
00227
00228
00237 int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
00238
00239
00248 int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
00249
00250
00257 int hdfsDelete(hdfsFS fs, const char* path);
00258
00259
00267 int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath);
00268
00269
00278 char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize);
00279
00280
00288 int hdfsSetWorkingDirectory(hdfsFS fs, const char* path);
00289
00290
00298 int hdfsCreateDirectory(hdfsFS fs, const char* path);
00299
00300
00308 int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication);
00309
00310
00314 typedef struct {
00315 tObjectKind mKind;
00316 char *mName;
00317 tTime mLastMod;
00318 tOffset mSize;
00319 short mReplication;
00320 tOffset mBlockSize;
00321 } hdfsFileInfo;
00322
00323
00333 hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path,
00334 int *numEntries);
00335
00336
00346 hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path);
00347
00348
00355 void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries);
00356
00357
00370 char*** hdfsGetHosts(hdfsFS fs, const char* path,
00371 tOffset start, tOffset length);
00372
00373
00380 void hdfsFreeHosts(char ***blockHosts);
00381
00382
00388 tOffset hdfsGetDefaultBlockSize(hdfsFS fs);
00389
00390
00396 tOffset hdfsGetCapacity(hdfsFS fs);
00397
00398
00404 tOffset hdfsGetUsed(hdfsFS fs);
00405
00406 #ifdef __cplusplus
00407 }
00408 #endif
00409
00410 #endif
00411