hdfs_library.h

00001 /*
00002 Copyright (C) 2011- The University of Notre Dame
00003 This software is distributed under the GNU General Public License.
00004 See the file COPYING for details.
00005 */
00006 
00007 #ifndef HDFS_LIBRARY_H
00008 #define HDFS_LIBRARY_H
00009 
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012 #include <time.h>
00013 
00014 #include "int_sizes.h"
00015 
00016 #ifndef HDFS_EINTERNAL
00017 #define HDFS_EINTERNAL 255
00018 #endif
00019 
00020 typedef INT32_T tSize;
00021 typedef time_t tTime;
00022 typedef INT64_T tOffset;
00023 typedef UINT16_T tPort;
00024 
00025 typedef enum tObjectKind {
00026         kObjectKindFile = 'F',
00027         kObjectKindDirectory = 'D',
00028 } tObjectKind;
00029 
00030 typedef void *hdfsFS;
00031 typedef void *hdfsFile;
00032 
00033 typedef struct {
00034         tObjectKind mKind;
00035         char *mName;
00036         tTime mLastMod;
00037         tOffset mSize;
00038         short mReplication;
00039         tOffset mBlockSize;
00040         char *mOwner;
00041         char *mGroup;
00042         short mPermissions;
00043         tTime mLastAccess;
00044 } hdfsFileInfo;
00045 
00046 struct hdfs_library {
00047         void    *libjvm_handle;
00048         void    *libhdfs_handle;
00049         hdfsFS  (*connect) (const char *, tPort);
00050         hdfsFS  (*connect_as_user) (const char *, tPort, const char *, const char *[], int);
00051         int     (*disconnect) (hdfsFS);
00052         hdfsFileInfo *  (*listdir) (hdfsFS, const char *, int *);
00053         hdfsFile        (*open) (hdfsFS, const char *, int, int, short, tSize);
00054         int     (*close) (hdfsFS, hdfsFile);
00055         int     (*flush) (hdfsFS, hdfsFile);
00056         tSize   (*read) (hdfsFS, hdfsFile, void *, tSize);
00057         tSize   (*pread) (hdfsFS, hdfsFile, tOffset, void *, tSize);
00058         tSize   (*write) (hdfsFS, hdfsFile, const void *, tSize);
00059         int     (*exists) (hdfsFS, const char *);
00060         int     (*mkdir) (hdfsFS, const char *);
00061         int     (*unlink) (hdfsFS, const char *);
00062         int     (*rename) (hdfsFS, const char *, const char *);
00063         hdfsFileInfo *(*stat) (hdfsFS, const char *);
00064         void    (*free_stat) (hdfsFileInfo *, int);
00065         char    ***(*get_hosts) (hdfsFS, const char *, tOffset, tOffset);
00066         void    (*free_hosts) (char ***);
00067         tOffset (*get_default_block_size) (hdfsFS);
00068         tOffset (*get_capacity) (hdfsFS);
00069         tOffset (*get_used) (hdfsFS);
00070         int     (*chmod) (hdfsFS, const char *, short);
00071         int     (*utime) (hdfsFS, const char *, tTime, tTime);
00072         int     (*chdir) (hdfsFS, const char *);
00073 };
00074 
00075 struct hdfs_library *hdfs_library_open();
00076 void hdfs_library_close( struct hdfs_library *hs );
00077 
00078 #endif

Generated on Mon Apr 11 10:37:25 2011 for cctools by  doxygen 1.4.7