You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2015/10/08 23:17:17 UTC

[06/35] hadoop git commit: HDFS-9170. Move libhdfs / fuse-dfs / libwebhdfs to hdfs-client. Contributed by Haohui Mai.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/vecsum.c
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/vecsum.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/vecsum.c
deleted file mode 100644
index 80a64b4..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/vecsum.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#ifdef __MACH__ // OS X does not have clock_gettime
-#include <mach/clock.h>
-#include <mach/mach.h>
-#include <mach/mach_time.h>
-#endif
-
-#include "config.h"
-#include "hdfs.h"
-
-#define VECSUM_CHUNK_SIZE (8 * 1024 * 1024)
-#define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8)
-#define NORMAL_READ_CHUNK_SIZE (8 * 1024 * 1024)
-#define DOUBLES_PER_LOOP_ITER 16
-
-static double timespec_to_double(const struct timespec *ts)
-{
-    double sec = ts->tv_sec;
-    double nsec = ts->tv_nsec;
-    return sec + (nsec / 1000000000L);
-}
-
-struct stopwatch {
-    struct timespec start;
-    struct timespec stop;
-};
-
-
-#ifdef __MACH__
-static int clock_gettime_mono(struct timespec * ts) {
-    static mach_timebase_info_data_t tb;
-    static uint64_t timestart = 0;
-    uint64_t t = 0;
-    if (timestart == 0) {
-        mach_timebase_info(&tb);
-        timestart = mach_absolute_time();
-    }
-    t = mach_absolute_time() - timestart;
-    t *= tb.numer;
-    t /= tb.denom;
-    ts->tv_sec = t / 1000000000ULL;
-    ts->tv_nsec = t - (ts->tv_sec * 1000000000ULL);
-    return 0;
-}
-#else
-static int clock_gettime_mono(struct timespec * ts) {
-    return clock_gettime(CLOCK_MONOTONIC, ts);
-}
-#endif
-
-static struct stopwatch *stopwatch_create(void)
-{
-    struct stopwatch *watch;
-
-    watch = calloc(1, sizeof(struct stopwatch));
-    if (!watch) {
-        fprintf(stderr, "failed to allocate memory for stopwatch\n");
-        goto error;
-    }
-    if (clock_gettime_mono(&watch->start)) {
-        int err = errno;
-        fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed with "
-            "error %d (%s)\n", err, strerror(err));
-        goto error;
-    }
-    return watch;
-
-error:
-    free(watch);
-    return NULL;
-}
-
-static void stopwatch_stop(struct stopwatch *watch,
-        long long bytes_read)
-{
-    double elapsed, rate;
-
-    if (clock_gettime_mono(&watch->stop)) {
-        int err = errno;
-        fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed with "
-            "error %d (%s)\n", err, strerror(err));
-        goto done;
-    }
-    elapsed = timespec_to_double(&watch->stop) -
-        timespec_to_double(&watch->start);
-    rate = (bytes_read / elapsed) / (1024 * 1024 * 1024);
-    printf("stopwatch: took %.5g seconds to read %lld bytes, "
-        "for %.5g GB/s\n", elapsed, bytes_read, rate);
-    printf("stopwatch:  %.5g seconds\n", elapsed);
-done:
-    free(watch);
-}
-
-enum vecsum_type {
-    VECSUM_LOCAL = 0,
-    VECSUM_LIBHDFS,
-    VECSUM_ZCR,
-};
-
-#define VECSUM_TYPE_VALID_VALUES "libhdfs, zcr, or local"
-
-int parse_vecsum_type(const char *str)
-{
-    if (strcasecmp(str, "local") == 0)
-        return VECSUM_LOCAL;
-    else if (strcasecmp(str, "libhdfs") == 0)
-        return VECSUM_LIBHDFS;
-    else if (strcasecmp(str, "zcr") == 0)
-        return VECSUM_ZCR;
-    else
-        return -1;
-}
-
-struct options {
-    // The path to read.
-    const char *path;
-
-    // Length of the file.
-    long long length;
-
-    // The number of times to read the path.
-    int passes;
-
-    // Type of vecsum to do
-    enum vecsum_type ty;
-
-    // RPC address to use for HDFS
-    const char *rpc_address;
-};
-
-static struct options *options_create(void)
-{
-    struct options *opts = NULL;
-    const char *pass_str;
-    const char *ty_str;
-    const char *length_str;
-    int ty;
-
-    opts = calloc(1, sizeof(struct options));
-    if (!opts) {
-        fprintf(stderr, "failed to calloc options\n");
-        goto error;
-    }
-    opts->path = getenv("VECSUM_PATH");
-    if (!opts->path) {
-        fprintf(stderr, "You must set the VECSUM_PATH environment "
-            "variable to the path of the file to read.\n");
-        goto error;
-    }
-    length_str = getenv("VECSUM_LENGTH");
-    if (!length_str) {
-        length_str = "2147483648";
-    }
-    opts->length = atoll(length_str);
-    if (!opts->length) {
-        fprintf(stderr, "Can't parse VECSUM_LENGTH of '%s'.\n",
-                length_str);
-        goto error;
-    }
-    if (opts->length % VECSUM_CHUNK_SIZE) {
-        fprintf(stderr, "VECSUM_LENGTH must be a multiple of '%lld'.  The "
-                "currently specified length of '%lld' is not.\n",
-                (long long)VECSUM_CHUNK_SIZE, (long long)opts->length);
-        goto error;
-    }
-    pass_str = getenv("VECSUM_PASSES");
-    if (!pass_str) {
-        fprintf(stderr, "You must set the VECSUM_PASSES environment "
-            "variable to the number of passes to make.\n");
-        goto error;
-    }
-    opts->passes = atoi(pass_str);
-    if (opts->passes <= 0) {
-        fprintf(stderr, "Invalid value for the VECSUM_PASSES "
-            "environment variable.  You must set this to a "
-            "number greater than 0.\n");
-        goto error;
-    }
-    ty_str = getenv("VECSUM_TYPE");
-    if (!ty_str) {
-        fprintf(stderr, "You must set the VECSUM_TYPE environment "
-            "variable to " VECSUM_TYPE_VALID_VALUES "\n");
-        goto error;
-    }
-    ty = parse_vecsum_type(ty_str);
-    if (ty < 0) {
-        fprintf(stderr, "Invalid VECSUM_TYPE environment variable.  "
-            "Valid values are " VECSUM_TYPE_VALID_VALUES "\n");
-        goto error;
-    }
-    opts->ty = ty;
-    opts->rpc_address = getenv("VECSUM_RPC_ADDRESS");
-    if (!opts->rpc_address) {
-        opts->rpc_address = "default";
-    }
-    return opts;
-error:
-    free(opts);
-    return NULL;
-}
-
-static int test_file_chunk_setup(double **chunk)
-{
-    int i;
-    double *c, val;
-
-    c = malloc(VECSUM_CHUNK_SIZE);
-    if (!c) {
-        fprintf(stderr, "test_file_create: failed to malloc "
-                "a buffer of size '%lld'\n",
-                (long long) VECSUM_CHUNK_SIZE);
-        return EIO;
-    }
-    val = 0.0;
-    for (i = 0; i < VECSUM_CHUNK_SIZE / sizeof(double); i++) {
-        c[i] = val;
-        val += 0.5;
-    }
-    *chunk = c;
-    return 0;
-}
-
-static void options_free(struct options *opts)
-{
-    free(opts);
-}
-
-struct local_data {
-    int fd;
-    double *mmap;
-    long long length;
-};
-
-static int local_data_create_file(struct local_data *cdata,
-                                  const struct options *opts)
-{
-    int ret = EIO;
-    int dup_fd = -1;
-    FILE *fp = NULL;
-    double *chunk = NULL;
-    long long offset = 0;
-
-    dup_fd = dup(cdata->fd);
-    if (dup_fd < 0) {
-        ret = errno;
-        fprintf(stderr, "local_data_create_file: dup failed: %s (%d)\n",
-                strerror(ret), ret);
-        goto done;
-    }
-    fp = fdopen(dup_fd, "w");
-    if (!fp) {
-        ret = errno;
-        fprintf(stderr, "local_data_create_file: fdopen failed: %s (%d)\n",
-                strerror(ret), ret);
-        goto done;
-    }
-    ret = test_file_chunk_setup(&chunk);
-    if (ret)
-        goto done;
-    while (offset < opts->length) {
-        if (fwrite(chunk, VECSUM_CHUNK_SIZE, 1, fp) != 1) {
-            fprintf(stderr, "local_data_create_file: failed to write to "
-                    "the local file '%s' at offset %lld\n",
-                    opts->path, offset);
-            ret = EIO;
-            goto done;
-        }
-        offset += VECSUM_CHUNK_SIZE;
-    }
-    fprintf(stderr, "local_data_create_file: successfully re-wrote %s as "
-            "a file of length %lld\n", opts->path, opts->length);
-    ret = 0;
-
-done:
-    if (dup_fd >= 0) {
-        close(dup_fd);
-    }
-    if (fp) {
-        fclose(fp);
-    }
-    free(chunk);
-    return ret;
-}
-
-static struct local_data *local_data_create(const struct options *opts)
-{
-    struct local_data *cdata = NULL;
-    struct stat st_buf;
-
-    cdata = malloc(sizeof(*cdata));
-    if (!cdata) {
-        fprintf(stderr, "Failed to allocate local test data.\n");
-        goto error;
-    }
-    cdata->fd = -1;
-    cdata->mmap = MAP_FAILED;
-    cdata->length = opts->length;
-
-    cdata->fd = open(opts->path, O_RDWR | O_CREAT, 0777);
-    if (cdata->fd < 0) {
-        int err = errno;
-        fprintf(stderr, "local_data_create: failed to open %s "
-            "for read/write: error %d (%s)\n", opts->path, err, strerror(err));
-        goto error;
-    }
-    if (fstat(cdata->fd, &st_buf)) {
-        int err = errno;
-        fprintf(stderr, "local_data_create: fstat(%s) failed: "
-            "error %d (%s)\n", opts->path, err, strerror(err));
-        goto error;
-    }
-    if (st_buf.st_size != opts->length) {
-        int err;
-        fprintf(stderr, "local_data_create: current size of %s is %lld, but "
-                "we want %lld.  Re-writing the file.\n",
-                opts->path, (long long)st_buf.st_size,
-                (long long)opts->length);
-        err = local_data_create_file(cdata, opts);
-        if (err)
-            goto error;
-    }
-    cdata->mmap = mmap(NULL, cdata->length, PROT_READ,
-                       MAP_PRIVATE, cdata->fd, 0);
-    if (cdata->mmap == MAP_FAILED) {
-        int err = errno;
-        fprintf(stderr, "local_data_create: mmap(%s) failed: "
-            "error %d (%s)\n", opts->path, err, strerror(err));
-        goto error;
-    }
-    return cdata;
-
-error:
-    if (cdata) {
-        if (cdata->fd >= 0) {
-            close(cdata->fd);
-        }
-        free(cdata);
-    }
-    return NULL;
-}
-
-static void local_data_free(struct local_data *cdata)
-{
-    close(cdata->fd);
-    munmap(cdata->mmap, cdata->length);
-}
-
-struct libhdfs_data {
-    hdfsFS fs;
-    hdfsFile file;
-    long long length;
-    double *buf;
-};
-
-static void libhdfs_data_free(struct libhdfs_data *ldata)
-{
-    if (ldata->fs) {
-        free(ldata->buf);
-        if (ldata->file) {
-            hdfsCloseFile(ldata->fs, ldata->file);
-        }
-        hdfsDisconnect(ldata->fs);
-    }
-    free(ldata);
-}
-
-static int libhdfs_data_create_file(struct libhdfs_data *ldata,
-                                    const struct options *opts)
-{
-    int ret;
-    double *chunk = NULL;
-    long long offset = 0;
-
-    ldata->file = hdfsOpenFile(ldata->fs, opts->path, O_WRONLY, 0, 1, 0);
-    if (!ldata->file) {
-        ret = errno;
-        fprintf(stderr, "libhdfs_data_create_file: hdfsOpenFile(%s, "
-            "O_WRONLY) failed: error %d (%s)\n", opts->path, ret,
-            strerror(ret));
-        goto done;
-    }
-    ret = test_file_chunk_setup(&chunk);
-    if (ret)
-        goto done;
-    while (offset < opts->length) {
-        ret = hdfsWrite(ldata->fs, ldata->file, chunk, VECSUM_CHUNK_SIZE);
-        if (ret < 0) {
-            ret = errno;
-            fprintf(stderr, "libhdfs_data_create_file: got error %d (%s) at "
-                    "offset %lld of %s\n", ret, strerror(ret),
-                    offset, opts->path);
-            goto done;
-        } else if (ret < VECSUM_CHUNK_SIZE) {
-            fprintf(stderr, "libhdfs_data_create_file: got short write "
-                    "of %d at offset %lld of %s\n", ret, offset, opts->path);
-            goto done;
-        }
-        offset += VECSUM_CHUNK_SIZE;
-    }
-    ret = 0;
-done:
-    free(chunk);
-    if (ldata->file) {
-        if (hdfsCloseFile(ldata->fs, ldata->file)) {
-            fprintf(stderr, "libhdfs_data_create_file: hdfsCloseFile error.");
-            ret = EIO;
-        }
-        ldata->file = NULL;
-    }
-    return ret;
-}
-
-static struct libhdfs_data *libhdfs_data_create(const struct options *opts)
-{
-    struct libhdfs_data *ldata = NULL;
-    struct hdfsBuilder *builder = NULL;
-    hdfsFileInfo *pinfo = NULL;
-
-    ldata = calloc(1, sizeof(struct libhdfs_data));
-    if (!ldata) {
-        fprintf(stderr, "Failed to allocate libhdfs test data.\n");
-        goto error;
-    }
-    builder = hdfsNewBuilder();
-    if (!builder) {
-        fprintf(stderr, "Failed to create builder.\n");
-        goto error;
-    }
-    hdfsBuilderSetNameNode(builder, opts->rpc_address);
-    hdfsBuilderConfSetStr(builder,
-        "dfs.client.read.shortcircuit.skip.checksum", "true");
-    ldata->fs = hdfsBuilderConnect(builder);
-    if (!ldata->fs) {
-        fprintf(stderr, "Could not connect to default namenode!\n");
-        goto error;
-    }
-    pinfo = hdfsGetPathInfo(ldata->fs, opts->path);
-    if (!pinfo) {
-        int err = errno;
-        fprintf(stderr, "hdfsGetPathInfo(%s) failed: error %d (%s).  "
-                "Attempting to re-create file.\n",
-            opts->path, err, strerror(err));
-        if (libhdfs_data_create_file(ldata, opts))
-            goto error;
-    } else if (pinfo->mSize != opts->length) {
-        fprintf(stderr, "hdfsGetPathInfo(%s) failed: length was %lld, "
-                "but we want length %lld.  Attempting to re-create file.\n",
-                opts->path, (long long)pinfo->mSize, (long long)opts->length);
-        if (libhdfs_data_create_file(ldata, opts))
-            goto error;
-    }
-    ldata->file = hdfsOpenFile(ldata->fs, opts->path, O_RDONLY, 0, 0, 0);
-    if (!ldata->file) {
-        int err = errno;
-        fprintf(stderr, "hdfsOpenFile(%s) failed: error %d (%s)\n",
-            opts->path, err, strerror(err));
-        goto error;
-    }
-    ldata->length = opts->length;
-    return ldata;
-
-error:
-    if (pinfo)
-        hdfsFreeFileInfo(pinfo, 1);
-    if (ldata)
-        libhdfs_data_free(ldata);
-    return NULL;
-}
-
-static int check_byte_size(int byte_size, const char *const str)
-{
-    if (byte_size % sizeof(double)) {
-        fprintf(stderr, "%s is not a multiple "
-            "of sizeof(double)\n", str);
-        return EINVAL;
-    }
-    if ((byte_size / sizeof(double)) % DOUBLES_PER_LOOP_ITER) {
-        fprintf(stderr, "The number of doubles contained in "
-            "%s is not a multiple of DOUBLES_PER_LOOP_ITER\n",
-            str);
-        return EINVAL;
-    }
-    return 0;
-}
-
-#ifdef HAVE_INTEL_SSE_INTRINSICS
-
-#include <emmintrin.h>
-
-static double vecsum(const double *buf, int num_doubles)
-{
-    int i;
-    double hi, lo;
-    __m128d x0, x1, x2, x3, x4, x5, x6, x7;
-    __m128d sum0 = _mm_set_pd(0.0,0.0);
-    __m128d sum1 = _mm_set_pd(0.0,0.0);
-    __m128d sum2 = _mm_set_pd(0.0,0.0);
-    __m128d sum3 = _mm_set_pd(0.0,0.0);
-    __m128d sum4 = _mm_set_pd(0.0,0.0);
-    __m128d sum5 = _mm_set_pd(0.0,0.0);
-    __m128d sum6 = _mm_set_pd(0.0,0.0);
-    __m128d sum7 = _mm_set_pd(0.0,0.0);
-    for (i = 0; i < num_doubles; i+=DOUBLES_PER_LOOP_ITER) {
-        x0 = _mm_load_pd(buf + i + 0);
-        x1 = _mm_load_pd(buf + i + 2);
-        x2 = _mm_load_pd(buf + i + 4);
-        x3 = _mm_load_pd(buf + i + 6);
-        x4 = _mm_load_pd(buf + i + 8);
-        x5 = _mm_load_pd(buf + i + 10);
-        x6 = _mm_load_pd(buf + i + 12);
-        x7 = _mm_load_pd(buf + i + 14);
-        sum0 = _mm_add_pd(sum0, x0);
-        sum1 = _mm_add_pd(sum1, x1);
-        sum2 = _mm_add_pd(sum2, x2);
-        sum3 = _mm_add_pd(sum3, x3);
-        sum4 = _mm_add_pd(sum4, x4);
-        sum5 = _mm_add_pd(sum5, x5);
-        sum6 = _mm_add_pd(sum6, x6);
-        sum7 = _mm_add_pd(sum7, x7);
-    }
-    x0 = _mm_add_pd(sum0, sum1);
-    x1 = _mm_add_pd(sum2, sum3);
-    x2 = _mm_add_pd(sum4, sum5);
-    x3 = _mm_add_pd(sum6, sum7);
-    x4 = _mm_add_pd(x0, x1);
-    x5 = _mm_add_pd(x2, x3);
-    x6 = _mm_add_pd(x4, x5);
-    _mm_storeh_pd(&hi, x6);
-    _mm_storel_pd(&lo, x6);
-    return hi + lo;
-}
-
-#else
-
-static double vecsum(const double *buf, int num_doubles)
-{
-    int i;
-    double sum = 0.0;
-    for (i = 0; i < num_doubles; i++) {
-        sum += buf[i];
-    }
-    return sum;
-}
-
-#endif
-
-static int vecsum_zcr_loop(int pass, struct libhdfs_data *ldata,
-        struct hadoopRzOptions *zopts,
-        const struct options *opts)
-{
-    int32_t len;
-    double sum = 0.0;
-    const double *buf;
-    struct hadoopRzBuffer *rzbuf = NULL;
-    int ret;
-
-    while (1) {
-        rzbuf = hadoopReadZero(ldata->file, zopts, ZCR_READ_CHUNK_SIZE);
-        if (!rzbuf) {
-            ret = errno;
-            fprintf(stderr, "hadoopReadZero failed with error "
-                "code %d (%s)\n", ret, strerror(ret));
-            goto done;
-        }
-        buf = hadoopRzBufferGet(rzbuf);
-        if (!buf) break;
-        len = hadoopRzBufferLength(rzbuf);
-        if (len < ZCR_READ_CHUNK_SIZE) {
-            fprintf(stderr, "hadoopReadZero got a partial read "
-                "of length %d\n", len);
-            ret = EINVAL;
-            goto done;
-        }
-        sum += vecsum(buf,
-            ZCR_READ_CHUNK_SIZE / sizeof(double));
-        hadoopRzBufferFree(ldata->file, rzbuf);
-    }
-    printf("finished zcr pass %d.  sum = %g\n", pass, sum);
-    ret = 0;
-
-done:
-    if (rzbuf)
-        hadoopRzBufferFree(ldata->file, rzbuf);
-    return ret;
-}
-
-static int vecsum_zcr(struct libhdfs_data *ldata,
-        const struct options *opts)
-{
-    int ret, pass;
-    struct hadoopRzOptions *zopts = NULL;
-
-    zopts = hadoopRzOptionsAlloc();
-    if (!zopts) {
-        fprintf(stderr, "hadoopRzOptionsAlloc failed.\n");
-        ret = ENOMEM;
-        goto done;
-    }
-    if (hadoopRzOptionsSetSkipChecksum(zopts, 1)) {
-        ret = errno;
-        perror("hadoopRzOptionsSetSkipChecksum failed: ");
-        goto done;
-    }
-    if (hadoopRzOptionsSetByteBufferPool(zopts, NULL)) {
-        ret = errno;
-        perror("hadoopRzOptionsSetByteBufferPool failed: ");
-        goto done;
-    }
-    for (pass = 0; pass < opts->passes; ++pass) {
-        ret = vecsum_zcr_loop(pass, ldata, zopts, opts);
-        if (ret) {
-            fprintf(stderr, "vecsum_zcr_loop pass %d failed "
-                "with error %d\n", pass, ret);
-            goto done;
-        }
-        hdfsSeek(ldata->fs, ldata->file, 0);
-    }
-    ret = 0;
-done:
-    if (zopts)
-        hadoopRzOptionsFree(zopts);
-    return ret;
-}
-
-tSize hdfsReadFully(hdfsFS fs, hdfsFile f, void* buffer, tSize length)
-{
-    uint8_t *buf = buffer;
-    tSize ret, nread = 0;
-
-    while (length > 0) {
-        ret = hdfsRead(fs, f, buf, length);
-        if (ret < 0) {
-            if (errno != EINTR) {
-                return -1;
-            }
-        }
-        if (ret == 0) {
-            break;
-        }
-        nread += ret;
-        length -= ret;
-        buf += ret;
-    }
-    return nread;
-}
-
-static int vecsum_normal_loop(int pass, const struct libhdfs_data *ldata,
-            const struct options *opts)
-{
-    double sum = 0.0;
-
-    while (1) {
-        int res = hdfsReadFully(ldata->fs, ldata->file, ldata->buf,
-                NORMAL_READ_CHUNK_SIZE);
-        if (res == 0) // EOF
-            break;
-        if (res < 0) {
-            int err = errno;
-            fprintf(stderr, "hdfsRead failed with error %d (%s)\n",
-                err, strerror(err));
-            return err;
-        }
-        if (res < NORMAL_READ_CHUNK_SIZE) {
-            fprintf(stderr, "hdfsRead got a partial read of "
-                "length %d\n", res);
-            return EINVAL;
-        }
-        sum += vecsum(ldata->buf,
-                  NORMAL_READ_CHUNK_SIZE / sizeof(double));
-    }
-    printf("finished normal pass %d.  sum = %g\n", pass, sum);
-    return 0;
-}
-
-static int vecsum_libhdfs(struct libhdfs_data *ldata,
-            const struct options *opts)
-{
-    int pass;
-
-    ldata->buf = malloc(NORMAL_READ_CHUNK_SIZE);
-    if (!ldata->buf) {
-        fprintf(stderr, "failed to malloc buffer of size %d\n",
-            NORMAL_READ_CHUNK_SIZE);
-        return ENOMEM;
-    }
-    for (pass = 0; pass < opts->passes; ++pass) {
-        int ret = vecsum_normal_loop(pass, ldata, opts);
-        if (ret) {
-            fprintf(stderr, "vecsum_normal_loop pass %d failed "
-                "with error %d\n", pass, ret);
-            return ret;
-        }
-        hdfsSeek(ldata->fs, ldata->file, 0);
-    }
-    return 0;
-}
-
-static void vecsum_local(struct local_data *cdata, const struct options *opts)
-{
-    int pass;
-
-    for (pass = 0; pass < opts->passes; pass++) {
-        double sum = vecsum(cdata->mmap, cdata->length / sizeof(double));
-        printf("finished vecsum_local pass %d.  sum = %g\n", pass, sum);
-    }
-}
-
-static long long vecsum_length(const struct options *opts,
-                const struct libhdfs_data *ldata)
-{
-    if (opts->ty == VECSUM_LOCAL) {
-        struct stat st_buf = { 0 };
-        if (stat(opts->path, &st_buf)) {
-            int err = errno;
-            fprintf(stderr, "vecsum_length: stat(%s) failed: "
-                "error %d (%s)\n", opts->path, err, strerror(err));
-            return -EIO;
-        }
-        return st_buf.st_size;
-    } else {
-        return ldata->length;
-    }
-}
-
-/*
- * vecsum is a microbenchmark which measures the speed of various ways of
- * reading from HDFS.  It creates a file containing floating-point 'doubles',
- * and computes the sum of all the doubles several times.  For some CPUs,
- * assembly optimizations are used for the summation (SSE, etc).
- */
-int main(void)
-{
-    int ret = 1;
-    struct options *opts = NULL;
-    struct local_data *cdata = NULL;
-    struct libhdfs_data *ldata = NULL;
-    struct stopwatch *watch = NULL;
-
-    if (check_byte_size(VECSUM_CHUNK_SIZE, "VECSUM_CHUNK_SIZE") ||
-        check_byte_size(ZCR_READ_CHUNK_SIZE,
-                "ZCR_READ_CHUNK_SIZE") ||
-        check_byte_size(NORMAL_READ_CHUNK_SIZE,
-                "NORMAL_READ_CHUNK_SIZE")) {
-        goto done;
-    }
-    opts = options_create();
-    if (!opts)
-        goto done;
-    if (opts->ty == VECSUM_LOCAL) {
-        cdata = local_data_create(opts);
-        if (!cdata)
-            goto done;
-    } else {
-        ldata = libhdfs_data_create(opts);
-        if (!ldata)
-            goto done;
-    }
-    watch = stopwatch_create();
-    if (!watch)
-        goto done;
-    switch (opts->ty) {
-    case VECSUM_LOCAL:
-        vecsum_local(cdata, opts);
-        ret = 0;
-        break;
-    case VECSUM_LIBHDFS:
-        ret = vecsum_libhdfs(ldata, opts);
-        break;
-    case VECSUM_ZCR:
-        ret = vecsum_zcr(ldata, opts);
-        break;
-    }
-    if (ret) {
-        fprintf(stderr, "vecsum failed with error %d\n", ret);
-        goto done;
-    }
-    ret = 0;
-done:
-    fprintf(stderr, "cleaning up...\n");
-    if (watch && (ret == 0)) {
-        long long length = vecsum_length(opts, ldata);
-        if (length >= 0) {
-            stopwatch_stop(watch, length * opts->passes);
-        }
-    }
-    if (cdata)
-        local_data_free(cdata);
-    if (ldata)
-        libhdfs_data_free(ldata);
-    if (opts)
-        options_free(opts);
-    return ret;
-}
-
-// vim: ts=4:sw=4:tw=79:et

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c
deleted file mode 100644
index 702430c..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "expect.h"
-#include "hdfs.h"
-#include "native_mini_dfs.h"
-#include "os/thread.h"
-
-#include <errno.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define TO_STR_HELPER(X) #X
-#define TO_STR(X) TO_STR_HELPER(X)
-
-#define TLH_MAX_THREADS 100
-
-#define TLH_DEFAULT_BLOCK_SIZE 134217728
-
-static struct NativeMiniDfsCluster* tlhCluster;
-
-struct tlhThreadInfo {
-    /** Thread index */
-    int threadIdx;
-    /** 0 = thread was successful; error code otherwise */
-    int success;
-    /** thread identifier */
-    thread theThread;
-};
-
-static int hdfsSingleNameNodeConnect(struct NativeMiniDfsCluster *cl, hdfsFS *fs,
-                                     const char *username)
-{
-    int ret;
-    tPort port;
-    hdfsFS hdfs;
-    struct hdfsBuilder *bld;
-    
-    port = (tPort)nmdGetNameNodePort(cl);
-    if (port < 0) {
-        fprintf(stderr, "hdfsSingleNameNodeConnect: nmdGetNameNodePort "
-                "returned error %d\n", port);
-        return port;
-    }
-    bld = hdfsNewBuilder();
-    if (!bld)
-        return -ENOMEM;
-    hdfsBuilderSetForceNewInstance(bld);
-    hdfsBuilderSetNameNode(bld, "localhost");
-    hdfsBuilderSetNameNodePort(bld, port);
-    hdfsBuilderConfSetStr(bld, "dfs.block.size",
-                          TO_STR(TLH_DEFAULT_BLOCK_SIZE));
-    hdfsBuilderConfSetStr(bld, "dfs.blocksize",
-                          TO_STR(TLH_DEFAULT_BLOCK_SIZE));
-    if (username) {
-        hdfsBuilderSetUserName(bld, username);
-    }
-    hdfs = hdfsBuilderConnect(bld);
-    if (!hdfs) {
-        ret = -errno;
-        return ret;
-    }
-    *fs = hdfs;
-    return 0;
-}
-
-static int doTestGetDefaultBlockSize(hdfsFS fs, const char *path)
-{
-    int64_t blockSize;
-    int ret;
-
-    blockSize = hdfsGetDefaultBlockSize(fs);
-    if (blockSize < 0) {
-        ret = errno;
-        fprintf(stderr, "hdfsGetDefaultBlockSize failed with error %d\n", ret);
-        return ret;
-    } else if (blockSize != TLH_DEFAULT_BLOCK_SIZE) {
-        fprintf(stderr, "hdfsGetDefaultBlockSize got %"PRId64", but we "
-                "expected %d\n", blockSize, TLH_DEFAULT_BLOCK_SIZE);
-        return EIO;
-    }
-
-    blockSize = hdfsGetDefaultBlockSizeAtPath(fs, path);
-    if (blockSize < 0) {
-        ret = errno;
-        fprintf(stderr, "hdfsGetDefaultBlockSizeAtPath(%s) failed with "
-                "error %d\n", path, ret);
-        return ret;
-    } else if (blockSize != TLH_DEFAULT_BLOCK_SIZE) {
-        fprintf(stderr, "hdfsGetDefaultBlockSizeAtPath(%s) got "
-                "%"PRId64", but we expected %d\n", 
-                path, blockSize, TLH_DEFAULT_BLOCK_SIZE);
-        return EIO;
-    }
-    return 0;
-}
-
-struct tlhPaths {
-    char prefix[256];
-    char file1[256];
-    char file2[256];
-};
-
-static int setupPaths(const struct tlhThreadInfo *ti, struct tlhPaths *paths)
-{
-    memset(paths, 0, sizeof(*paths));
-    if (snprintf(paths->prefix, sizeof(paths->prefix), "/tlhData%04d",
-                 ti->threadIdx) >= sizeof(paths->prefix)) {
-        return ENAMETOOLONG;
-    }
-    if (snprintf(paths->file1, sizeof(paths->file1), "%s/file1",
-                 paths->prefix) >= sizeof(paths->file1)) {
-        return ENAMETOOLONG;
-    }
-    if (snprintf(paths->file2, sizeof(paths->file2), "%s/file2",
-                 paths->prefix) >= sizeof(paths->file2)) {
-        return ENAMETOOLONG;
-    }
-    return 0;
-}
-
-static int doTestHdfsOperations(struct tlhThreadInfo *ti, hdfsFS fs,
-                                const struct tlhPaths *paths)
-{
-    char tmp[4096];
-    hdfsFile file;
-    int ret, expected, numEntries;
-    hdfsFileInfo *fileInfo;
-    struct hdfsReadStatistics *readStats = NULL;
-
-    if (hdfsExists(fs, paths->prefix) == 0) {
-        EXPECT_ZERO(hdfsDelete(fs, paths->prefix, 1));
-    }
-    EXPECT_ZERO(hdfsCreateDirectory(fs, paths->prefix));
-
-    EXPECT_ZERO(doTestGetDefaultBlockSize(fs, paths->prefix));
-
-    /* There should be no entry in the directory. */
-    errno = EACCES; // see if errno is set to 0 on success
-    EXPECT_NULL_WITH_ERRNO(hdfsListDirectory(fs, paths->prefix, &numEntries), 0);
-    if (numEntries != 0) {
-        fprintf(stderr, "hdfsListDirectory set numEntries to "
-                "%d on empty directory.", numEntries);
-    }
-
-    /* There should not be any file to open for reading. */
-    EXPECT_NULL(hdfsOpenFile(fs, paths->file1, O_RDONLY, 0, 0, 0));
-
-    /* hdfsOpenFile should not accept mode = 3 */
-    EXPECT_NULL(hdfsOpenFile(fs, paths->file1, 3, 0, 0, 0));
-
-    file = hdfsOpenFile(fs, paths->file1, O_WRONLY, 0, 0, 0);
-    EXPECT_NONNULL(file);
-
-    /* TODO: implement writeFully and use it here */
-    expected = (int)strlen(paths->prefix);
-    ret = hdfsWrite(fs, file, paths->prefix, expected);
-    if (ret < 0) {
-        ret = errno;
-        fprintf(stderr, "hdfsWrite failed and set errno %d\n", ret);
-        return ret;
-    }
-    if (ret != expected) {
-        fprintf(stderr, "hdfsWrite was supposed to write %d bytes, but "
-                "it wrote %d\n", ret, expected);
-        return EIO;
-    }
-    EXPECT_ZERO(hdfsFlush(fs, file));
-    EXPECT_ZERO(hdfsHSync(fs, file));
-    EXPECT_ZERO(hdfsCloseFile(fs, file));
-
-    /* There should be 1 entry in the directory. */
-    EXPECT_NONNULL(hdfsListDirectory(fs, paths->prefix, &numEntries));
-    if (numEntries != 1) {
-        fprintf(stderr, "hdfsListDirectory set numEntries to "
-                "%d on directory containing 1 file.", numEntries);
-    }
-
-    /* Let's re-open the file for reading */
-    file = hdfsOpenFile(fs, paths->file1, O_RDONLY, 0, 0, 0);
-    EXPECT_NONNULL(file);
-
-    EXPECT_ZERO(hdfsFileGetReadStatistics(file, &readStats));
-    errno = 0;
-    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalBytesRead);
-    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalLocalBytesRead);
-    EXPECT_UINT64_EQ(UINT64_C(0), readStats->totalShortCircuitBytesRead);
-    hdfsFileFreeReadStatistics(readStats);
-    /* TODO: implement readFully and use it here */
-    ret = hdfsRead(fs, file, tmp, sizeof(tmp));
-    if (ret < 0) {
-        ret = errno;
-        fprintf(stderr, "hdfsRead failed and set errno %d\n", ret);
-        return ret;
-    }
-    if (ret != expected) {
-        fprintf(stderr, "hdfsRead was supposed to read %d bytes, but "
-                "it read %d\n", ret, expected);
-        return EIO;
-    }
-    EXPECT_ZERO(hdfsFileGetReadStatistics(file, &readStats));
-    errno = 0;
-    EXPECT_UINT64_EQ((uint64_t)expected, readStats->totalBytesRead);
-    hdfsFileFreeReadStatistics(readStats);
-    EXPECT_ZERO(hdfsFileClearReadStatistics(file));
-    EXPECT_ZERO(hdfsFileGetReadStatistics(file, &readStats));
-    EXPECT_UINT64_EQ((uint64_t)0, readStats->totalBytesRead);
-    hdfsFileFreeReadStatistics(readStats);
-    EXPECT_ZERO(memcmp(paths->prefix, tmp, expected));
-    EXPECT_ZERO(hdfsCloseFile(fs, file));
-
-    // TODO: Non-recursive delete should fail?
-    //EXPECT_NONZERO(hdfsDelete(fs, prefix, 0));
-    EXPECT_ZERO(hdfsCopy(fs, paths->file1, fs, paths->file2));
-
-    EXPECT_ZERO(hdfsChown(fs, paths->file2, NULL, NULL));
-    EXPECT_ZERO(hdfsChown(fs, paths->file2, NULL, "doop"));
-    fileInfo = hdfsGetPathInfo(fs, paths->file2);
-    EXPECT_NONNULL(fileInfo);
-    EXPECT_ZERO(strcmp("doop", fileInfo->mGroup));
-    EXPECT_ZERO(hdfsFileIsEncrypted(fileInfo));
-    hdfsFreeFileInfo(fileInfo, 1);
-
-    EXPECT_ZERO(hdfsChown(fs, paths->file2, "ha", "doop2"));
-    fileInfo = hdfsGetPathInfo(fs, paths->file2);
-    EXPECT_NONNULL(fileInfo);
-    EXPECT_ZERO(strcmp("ha", fileInfo->mOwner));
-    EXPECT_ZERO(strcmp("doop2", fileInfo->mGroup));
-    hdfsFreeFileInfo(fileInfo, 1);
-
-    EXPECT_ZERO(hdfsChown(fs, paths->file2, "ha2", NULL));
-    fileInfo = hdfsGetPathInfo(fs, paths->file2);
-    EXPECT_NONNULL(fileInfo);
-    EXPECT_ZERO(strcmp("ha2", fileInfo->mOwner));
-    EXPECT_ZERO(strcmp("doop2", fileInfo->mGroup));
-    hdfsFreeFileInfo(fileInfo, 1);
-
-    snprintf(tmp, sizeof(tmp), "%s/nonexistent-file-name", paths->prefix);
-    EXPECT_NEGATIVE_ONE_WITH_ERRNO(hdfsChown(fs, tmp, "ha3", NULL), ENOENT);
-    return 0;
-}
-
-static int testHdfsOperationsImpl(struct tlhThreadInfo *ti)
-{
-    hdfsFS fs = NULL;
-    struct tlhPaths paths;
-
-    fprintf(stderr, "testHdfsOperations(threadIdx=%d): starting\n",
-        ti->threadIdx);
-    EXPECT_ZERO(hdfsSingleNameNodeConnect(tlhCluster, &fs, NULL));
-    EXPECT_ZERO(setupPaths(ti, &paths));
-    // test some operations
-    EXPECT_ZERO(doTestHdfsOperations(ti, fs, &paths));
-    EXPECT_ZERO(hdfsDisconnect(fs));
-    // reconnect as user "foo" and verify that we get permission errors
-    EXPECT_ZERO(hdfsSingleNameNodeConnect(tlhCluster, &fs, "foo"));
-    EXPECT_NEGATIVE_ONE_WITH_ERRNO(hdfsChown(fs, paths.file1, "ha3", NULL), EACCES);
-    EXPECT_ZERO(hdfsDisconnect(fs));
-    // reconnect to do the final delete.
-    EXPECT_ZERO(hdfsSingleNameNodeConnect(tlhCluster, &fs, NULL));
-    EXPECT_ZERO(hdfsDelete(fs, paths.prefix, 1));
-    EXPECT_ZERO(hdfsDisconnect(fs));
-    return 0;
-}
-
-static void testHdfsOperations(void *v)
-{
-    struct tlhThreadInfo *ti = (struct tlhThreadInfo*)v;
-    int ret = testHdfsOperationsImpl(ti);
-    ti->success = ret;
-}
-
-static int checkFailures(struct tlhThreadInfo *ti, int tlhNumThreads)
-{
-    int i, threadsFailed = 0;
-    const char *sep = "";
-
-    for (i = 0; i < tlhNumThreads; i++) {
-        if (ti[i].success != 0) {
-            threadsFailed = 1;
-        }
-    }
-    if (!threadsFailed) {
-        fprintf(stderr, "testLibHdfs: all threads succeeded.  SUCCESS.\n");
-        return EXIT_SUCCESS;
-    }
-    fprintf(stderr, "testLibHdfs: some threads failed: [");
-    for (i = 0; i < tlhNumThreads; i++) {
-        if (ti[i].success != 0) {
-            fprintf(stderr, "%s%d", sep, i);
-            sep = ", "; 
-        }
-    }
-    fprintf(stderr, "].  FAILURE.\n");
-    return EXIT_FAILURE;
-}
-
-/**
- * Test that we can write a file with libhdfs and then read it back
- */
-int main(void)
-{
-    int i, tlhNumThreads;
-    const char *tlhNumThreadsStr;
-    struct tlhThreadInfo ti[TLH_MAX_THREADS];
-    struct NativeMiniDfsConf conf = {
-        1, /* doFormat */
-    };
-
-    tlhNumThreadsStr = getenv("TLH_NUM_THREADS");
-    if (!tlhNumThreadsStr) {
-        tlhNumThreadsStr = "3";
-    }
-    tlhNumThreads = atoi(tlhNumThreadsStr);
-    if ((tlhNumThreads <= 0) || (tlhNumThreads > TLH_MAX_THREADS)) {
-        fprintf(stderr, "testLibHdfs: must have a number of threads "
-                "between 1 and %d inclusive, not %d\n",
-                TLH_MAX_THREADS, tlhNumThreads);
-        return EXIT_FAILURE;
-    }
-    memset(&ti[0], 0, sizeof(ti));
-    for (i = 0; i < tlhNumThreads; i++) {
-        ti[i].threadIdx = i;
-    }
-
-    tlhCluster = nmdCreate(&conf);
-    EXPECT_NONNULL(tlhCluster);
-    EXPECT_ZERO(nmdWaitClusterUp(tlhCluster));
-
-    for (i = 0; i < tlhNumThreads; i++) {
-        ti[i].theThread.start = testHdfsOperations;
-        ti[i].theThread.arg = &ti[i];
-        EXPECT_ZERO(threadCreate(&ti[i].theThread));
-    }
-    for (i = 0; i < tlhNumThreads; i++) {
-        EXPECT_ZERO(threadJoin(&ti[i].theThread));
-    }
-
-    EXPECT_ZERO(nmdShutdown(tlhCluster));
-    nmdFree(tlhCluster);
-    return checkFailures(ti, tlhNumThreads);
-}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_native_mini_dfs.c
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_native_mini_dfs.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_native_mini_dfs.c
deleted file mode 100644
index 850b0fc..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_native_mini_dfs.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "expect.h"
-#include "native_mini_dfs.h"
-
-#include <errno.h>
-
-static struct NativeMiniDfsConf conf = {
-    1, /* doFormat */
-};
-
-/**
- * Test that we can create a MiniDFSCluster and shut it down.
- */
-int main(void) {
-    struct NativeMiniDfsCluster* cl;
-    
-    cl = nmdCreate(&conf);
-    EXPECT_NONNULL(cl);
-    EXPECT_ZERO(nmdWaitClusterUp(cl));
-    EXPECT_ZERO(nmdShutdown(cl));
-    nmdFree(cl);
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.c
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.c
deleted file mode 100644
index 59308a5..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "util/posix_util.h"
-
-#include <dirent.h>
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <limits.h>
-
-static pthread_mutex_t gTempdirLock = PTHREAD_MUTEX_INITIALIZER;
-
-static int gTempdirNonce = 0;
-
-int recursiveDeleteContents(const char *path)
-{
-  int ret;
-  DIR *dp;
-  struct dirent *de;
-  char tmp[PATH_MAX];
-
-  dp = opendir(path);
-  if (!dp) {
-    ret = -errno;
-    fprintf(stderr, "recursiveDelete(%s) failed with error %d\n", path, ret);
-    return ret;
-  }
-  while (1) {
-    de = readdir(dp);
-    if (!de) {
-      ret = 0;
-      break;
-    }
-    if ((de->d_name[0] == '.') && (de->d_name[1] == '\0'))
-      continue;
-    if ((de->d_name[0] == '.') && (de->d_name[1] == '.') &&
-        (de->d_name[2] == '\0'))
-      continue;
-    snprintf(tmp, sizeof(tmp), "%s/%s", path, de->d_name);
-    ret = recursiveDelete(tmp);
-    if (ret)
-      break;
-  }
-  if (closedir(dp)) {
-    ret = -errno;
-    fprintf(stderr, "recursiveDelete(%s): closedir failed with "
-            "error %d\n", path, ret);
-    return ret;
-  }
-  return ret;
-}
-
-/*
- * Simple recursive delete implementation.
- * It could be optimized, but there is no need at the moment.
- * TODO: use fstat, etc.
- */
-int recursiveDelete(const char *path)
-{
-  int ret;
-  struct stat stBuf;
-
-  ret = stat(path, &stBuf);
-  if (ret != 0) {
-    ret = -errno;
-    fprintf(stderr, "recursiveDelete(%s): stat failed with "
-            "error %d\n", path, ret);
-    return ret;
-  }
-  if (S_ISDIR(stBuf.st_mode)) {
-    ret = recursiveDeleteContents(path);
-    if (ret)
-      return ret;
-    ret = rmdir(path);
-    if (ret) {
-      ret = errno;
-      fprintf(stderr, "recursiveDelete(%s): rmdir failed with error %d\n",
-              path, ret);
-      return ret;
-    }
-  } else {
-    ret = unlink(path);
-    if (ret) {
-      ret = -errno;
-      fprintf(stderr, "recursiveDelete(%s): unlink failed with "
-              "error %d\n", path, ret);
-      return ret;
-    }
-  }
-  return 0;
-}
-
-int createTempDir(char *tempDir, int nameMax, int mode)
-{
-  char tmp[PATH_MAX];
-  int pid, nonce;
-  const char *base = getenv("TMPDIR");
-  if (!base)
-    base = "/tmp";
-  if (base[0] != '/') {
-    // canonicalize non-absolute TMPDIR
-    if (realpath(base, tmp) == NULL) {
-      return -errno;
-    }
-    base = tmp;
-  }
-  pid = getpid();
-  pthread_mutex_lock(&gTempdirLock);
-  nonce = gTempdirNonce++;
-  pthread_mutex_unlock(&gTempdirLock);
-  snprintf(tempDir, nameMax, "%s/temp.%08d.%08d", base, pid, nonce);
-  if (mkdir(tempDir, mode) == -1) {
-    int ret = errno;
-    return -ret;
-  }
-  return 0;
-}
-
-void sleepNoSig(int sec)
-{
-  int ret;
-  struct timespec req, rem;
-
-  rem.tv_sec = sec;
-  rem.tv_nsec = 0;
-  do {
-    req = rem;
-    ret = nanosleep(&req, &rem);
-  } while ((ret == -1) && (errno == EINTR));
-  if (ret == -1) {
-    ret = errno;
-    fprintf(stderr, "nanosleep error %d (%s)\n", ret, strerror(ret));
-  }
-}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.h b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.h
deleted file mode 100644
index c184c26..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/posix_util.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSIX_UTIL_H__
-#define __POSIX_UTIL_H__
-
-/**
- * Recursively delete the contents of a directory
- *
- * @param path      directory whose contents we should delete
- *
- * @return          0 on success; error code otherwise
- */
-int recursiveDeleteContents(const char *path);
-
-/**
- * Recursively delete a local path, using unlink or rmdir as appropriate.
- *
- * @param path      path to delete
- *
- * @return          0 on success; error code otherwise
- */
-int recursiveDelete(const char *path);
-
-/**
- * Get a temporary directory 
- *
- * @param tempDir   (out param) path to the temporary directory
- * @param nameMax   Length of the tempDir buffer
- * @param mode      Mode to create with
- *
- * @return          0 on success; error code otherwise
- */
-int createTempDir(char *tempDir, int nameMax, int mode);
-
-/**
- * Sleep without using signals
- *
- * @param sec       Number of seconds to sleep
- */
-void sleepNoSig(int sec);
-
-#endif

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/tree.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/tree.h b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/tree.h
deleted file mode 100644
index ac78ee3..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/util/tree.h
+++ /dev/null
@@ -1,765 +0,0 @@
-/*	$NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $	*/
-/*	$OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $	*/
-/* $FreeBSD: src/sys/sys/tree.h,v 1.9.4.1 2011/09/23 00:51:37 kensmith Exp $ */
-
-/*-
- * Copyright 2002 Niels Provos <pr...@citi.umich.edu>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef	_SYS_TREE_H_
-#define	_SYS_TREE_H_
-
-#include <sys/cdefs.h>
-
-/*
- * This file defines data structures for different types of trees:
- * splay trees and red-black trees.
- *
- * A splay tree is a self-organizing data structure.  Every operation
- * on the tree causes a splay to happen.  The splay moves the requested
- * node to the root of the tree and partly rebalances it.
- *
- * This has the benefit that request locality causes faster lookups as
- * the requested nodes move to the top of the tree.  On the other hand,
- * every lookup causes memory writes.
- *
- * The Balance Theorem bounds the total access time for m operations
- * and n inserts on an initially empty tree as O((m + n)lg n).  The
- * amortized cost for a sequence of m accesses to a splay tree is O(lg n);
- *
- * A red-black tree is a binary search tree with the node color as an
- * extra attribute.  It fulfills a set of conditions:
- *	- every search path from the root to a leaf consists of the
- *	  same number of black nodes,
- *	- each red node (except for the root) has a black parent,
- *	- each leaf node is black.
- *
- * Every operation on a red-black tree is bounded as O(lg n).
- * The maximum height of a red-black tree is 2lg (n+1).
- */
-
-#define SPLAY_HEAD(name, type)						\
-struct name {								\
-	struct type *sph_root; /* root of the tree */			\
-}
-
-#define SPLAY_INITIALIZER(root)						\
-	{ NULL }
-
-#define SPLAY_INIT(root) do {						\
-	(root)->sph_root = NULL;					\
-} while (/*CONSTCOND*/ 0)
-
-#define SPLAY_ENTRY(type)						\
-struct {								\
-	struct type *spe_left; /* left element */			\
-	struct type *spe_right; /* right element */			\
-}
-
-#define SPLAY_LEFT(elm, field)		(elm)->field.spe_left
-#define SPLAY_RIGHT(elm, field)		(elm)->field.spe_right
-#define SPLAY_ROOT(head)		(head)->sph_root
-#define SPLAY_EMPTY(head)		(SPLAY_ROOT(head) == NULL)
-
-/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
-#define SPLAY_ROTATE_RIGHT(head, tmp, field) do {			\
-	SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field);	\
-	SPLAY_RIGHT(tmp, field) = (head)->sph_root;			\
-	(head)->sph_root = tmp;						\
-} while (/*CONSTCOND*/ 0)
-
-#define SPLAY_ROTATE_LEFT(head, tmp, field) do {			\
-	SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field);	\
-	SPLAY_LEFT(tmp, field) = (head)->sph_root;			\
-	(head)->sph_root = tmp;						\
-} while (/*CONSTCOND*/ 0)
-
-#define SPLAY_LINKLEFT(head, tmp, field) do {				\
-	SPLAY_LEFT(tmp, field) = (head)->sph_root;			\
-	tmp = (head)->sph_root;						\
-	(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);		\
-} while (/*CONSTCOND*/ 0)
-
-#define SPLAY_LINKRIGHT(head, tmp, field) do {				\
-	SPLAY_RIGHT(tmp, field) = (head)->sph_root;			\
-	tmp = (head)->sph_root;						\
-	(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);	\
-} while (/*CONSTCOND*/ 0)
-
-#define SPLAY_ASSEMBLE(head, node, left, right, field) do {		\
-	SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field);	\
-	SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
-	SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field);	\
-	SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field);	\
-} while (/*CONSTCOND*/ 0)
-
-/* Generates prototypes and inline functions */
-
-#define SPLAY_PROTOTYPE(name, type, field, cmp)				\
-void name##_SPLAY(struct name *, struct type *);			\
-void name##_SPLAY_MINMAX(struct name *, int);				\
-struct type *name##_SPLAY_INSERT(struct name *, struct type *);		\
-struct type *name##_SPLAY_REMOVE(struct name *, struct type *);		\
-									\
-/* Finds the node with the same key as elm */				\
-static __inline struct type *						\
-name##_SPLAY_FIND(struct name *head, struct type *elm)			\
-{									\
-	if (SPLAY_EMPTY(head))						\
-		return(NULL);						\
-	name##_SPLAY(head, elm);					\
-	if ((cmp)(elm, (head)->sph_root) == 0)				\
-		return (head->sph_root);				\
-	return (NULL);							\
-}									\
-									\
-static __inline struct type *						\
-name##_SPLAY_NEXT(struct name *head, struct type *elm)			\
-{									\
-	name##_SPLAY(head, elm);					\
-	if (SPLAY_RIGHT(elm, field) != NULL) {				\
-		elm = SPLAY_RIGHT(elm, field);				\
-		while (SPLAY_LEFT(elm, field) != NULL) {		\
-			elm = SPLAY_LEFT(elm, field);			\
-		}							\
-	} else								\
-		elm = NULL;						\
-	return (elm);							\
-}									\
-									\
-static __inline struct type *						\
-name##_SPLAY_MIN_MAX(struct name *head, int val)			\
-{									\
-	name##_SPLAY_MINMAX(head, val);					\
-        return (SPLAY_ROOT(head));					\
-}
-
-/* Main splay operation.
- * Moves node close to the key of elm to top
- */
-#define SPLAY_GENERATE(name, type, field, cmp)				\
-struct type *								\
-name##_SPLAY_INSERT(struct name *head, struct type *elm)		\
-{									\
-    if (SPLAY_EMPTY(head)) {						\
-	    SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL;	\
-    } else {								\
-	    int __comp;							\
-	    name##_SPLAY(head, elm);					\
-	    __comp = (cmp)(elm, (head)->sph_root);			\
-	    if(__comp < 0) {						\
-		    SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
-		    SPLAY_RIGHT(elm, field) = (head)->sph_root;		\
-		    SPLAY_LEFT((head)->sph_root, field) = NULL;		\
-	    } else if (__comp > 0) {					\
-		    SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
-		    SPLAY_LEFT(elm, field) = (head)->sph_root;		\
-		    SPLAY_RIGHT((head)->sph_root, field) = NULL;	\
-	    } else							\
-		    return ((head)->sph_root);				\
-    }									\
-    (head)->sph_root = (elm);						\
-    return (NULL);							\
-}									\
-									\
-struct type *								\
-name##_SPLAY_REMOVE(struct name *head, struct type *elm)		\
-{									\
-	struct type *__tmp;						\
-	if (SPLAY_EMPTY(head))						\
-		return (NULL);						\
-	name##_SPLAY(head, elm);					\
-	if ((cmp)(elm, (head)->sph_root) == 0) {			\
-		if (SPLAY_LEFT((head)->sph_root, field) == NULL) {	\
-			(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
-		} else {						\
-			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\
-			(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
-			name##_SPLAY(head, elm);			\
-			SPLAY_RIGHT((head)->sph_root, field) = __tmp;	\
-		}							\
-		return (elm);						\
-	}								\
-	return (NULL);							\
-}									\
-									\
-void									\
-name##_SPLAY(struct name *head, struct type *elm)			\
-{									\
-	struct type __node, *__left, *__right, *__tmp;			\
-	int __comp;							\
-\
-	SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
-	__left = __right = &__node;					\
-\
-	while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) {		\
-		if (__comp < 0) {					\
-			__tmp = SPLAY_LEFT((head)->sph_root, field);	\
-			if (__tmp == NULL)				\
-				break;					\
-			if ((cmp)(elm, __tmp) < 0){			\
-				SPLAY_ROTATE_RIGHT(head, __tmp, field);	\
-				if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
-					break;				\
-			}						\
-			SPLAY_LINKLEFT(head, __right, field);		\
-		} else if (__comp > 0) {				\
-			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\
-			if (__tmp == NULL)				\
-				break;					\
-			if ((cmp)(elm, __tmp) > 0){			\
-				SPLAY_ROTATE_LEFT(head, __tmp, field);	\
-				if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
-					break;				\
-			}						\
-			SPLAY_LINKRIGHT(head, __left, field);		\
-		}							\
-	}								\
-	SPLAY_ASSEMBLE(head, &__node, __left, __right, field);		\
-}									\
-									\
-/* Splay with either the minimum or the maximum element			\
- * Used to find minimum or maximum element in tree.			\
- */									\
-void name##_SPLAY_MINMAX(struct name *head, int __comp) \
-{									\
-	struct type __node, *__left, *__right, *__tmp;			\
-\
-	SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
-	__left = __right = &__node;					\
-\
-	while (1) {							\
-		if (__comp < 0) {					\
-			__tmp = SPLAY_LEFT((head)->sph_root, field);	\
-			if (__tmp == NULL)				\
-				break;					\
-			if (__comp < 0){				\
-				SPLAY_ROTATE_RIGHT(head, __tmp, field);	\
-				if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
-					break;				\
-			}						\
-			SPLAY_LINKLEFT(head, __right, field);		\
-		} else if (__comp > 0) {				\
-			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\
-			if (__tmp == NULL)				\
-				break;					\
-			if (__comp > 0) {				\
-				SPLAY_ROTATE_LEFT(head, __tmp, field);	\
-				if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
-					break;				\
-			}						\
-			SPLAY_LINKRIGHT(head, __left, field);		\
-		}							\
-	}								\
-	SPLAY_ASSEMBLE(head, &__node, __left, __right, field);		\
-}
-
-#define SPLAY_NEGINF	-1
-#define SPLAY_INF	1
-
-#define SPLAY_INSERT(name, x, y)	name##_SPLAY_INSERT(x, y)
-#define SPLAY_REMOVE(name, x, y)	name##_SPLAY_REMOVE(x, y)
-#define SPLAY_FIND(name, x, y)		name##_SPLAY_FIND(x, y)
-#define SPLAY_NEXT(name, x, y)		name##_SPLAY_NEXT(x, y)
-#define SPLAY_MIN(name, x)		(SPLAY_EMPTY(x) ? NULL	\
-					: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
-#define SPLAY_MAX(name, x)		(SPLAY_EMPTY(x) ? NULL	\
-					: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
-
-#define SPLAY_FOREACH(x, name, head)					\
-	for ((x) = SPLAY_MIN(name, head);				\
-	     (x) != NULL;						\
-	     (x) = SPLAY_NEXT(name, head, x))
-
-/* Macros that define a red-black tree */
-#define RB_HEAD(name, type)						\
-struct name {								\
-	struct type *rbh_root; /* root of the tree */			\
-}
-
-#define RB_INITIALIZER(root)						\
-	{ NULL }
-
-#define RB_INIT(root) do {						\
-	(root)->rbh_root = NULL;					\
-} while (/*CONSTCOND*/ 0)
-
-#define RB_BLACK	0
-#define RB_RED		1
-#define RB_ENTRY(type)							\
-struct {								\
-	struct type *rbe_left;		/* left element */		\
-	struct type *rbe_right;		/* right element */		\
-	struct type *rbe_parent;	/* parent element */		\
-	int rbe_color;			/* node color */		\
-}
-
-#define RB_LEFT(elm, field)		(elm)->field.rbe_left
-#define RB_RIGHT(elm, field)		(elm)->field.rbe_right
-#define RB_PARENT(elm, field)		(elm)->field.rbe_parent
-#define RB_COLOR(elm, field)		(elm)->field.rbe_color
-#define RB_ROOT(head)			(head)->rbh_root
-#define RB_EMPTY(head)			(RB_ROOT(head) == NULL)
-
-#define RB_SET(elm, parent, field) do {					\
-	RB_PARENT(elm, field) = parent;					\
-	RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL;		\
-	RB_COLOR(elm, field) = RB_RED;					\
-} while (/*CONSTCOND*/ 0)
-
-#define RB_SET_BLACKRED(black, red, field) do {				\
-	RB_COLOR(black, field) = RB_BLACK;				\
-	RB_COLOR(red, field) = RB_RED;					\
-} while (/*CONSTCOND*/ 0)
-
-#ifndef RB_AUGMENT
-#define RB_AUGMENT(x)	do {} while (0)
-#endif
-
-#define RB_ROTATE_LEFT(head, elm, tmp, field) do {			\
-	(tmp) = RB_RIGHT(elm, field);					\
-	if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) {	\
-		RB_PARENT(RB_LEFT(tmp, field), field) = (elm);		\
-	}								\
-	RB_AUGMENT(elm);						\
-	if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) {	\
-		if ((elm) == RB_LEFT(RB_PARENT(elm, field), field))	\
-			RB_LEFT(RB_PARENT(elm, field), field) = (tmp);	\
-		else							\
-			RB_RIGHT(RB_PARENT(elm, field), field) = (tmp);	\
-	} else								\
-		(head)->rbh_root = (tmp);				\
-	RB_LEFT(tmp, field) = (elm);					\
-	RB_PARENT(elm, field) = (tmp);					\
-	RB_AUGMENT(tmp);						\
-	if ((RB_PARENT(tmp, field)))					\
-		RB_AUGMENT(RB_PARENT(tmp, field));			\
-} while (/*CONSTCOND*/ 0)
-
-#define RB_ROTATE_RIGHT(head, elm, tmp, field) do {			\
-	(tmp) = RB_LEFT(elm, field);					\
-	if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) {	\
-		RB_PARENT(RB_RIGHT(tmp, field), field) = (elm);		\
-	}								\
-	RB_AUGMENT(elm);						\
-	if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) {	\
-		if ((elm) == RB_LEFT(RB_PARENT(elm, field), field))	\
-			RB_LEFT(RB_PARENT(elm, field), field) = (tmp);	\
-		else							\
-			RB_RIGHT(RB_PARENT(elm, field), field) = (tmp);	\
-	} else								\
-		(head)->rbh_root = (tmp);				\
-	RB_RIGHT(tmp, field) = (elm);					\
-	RB_PARENT(elm, field) = (tmp);					\
-	RB_AUGMENT(tmp);						\
-	if ((RB_PARENT(tmp, field)))					\
-		RB_AUGMENT(RB_PARENT(tmp, field));			\
-} while (/*CONSTCOND*/ 0)
-
-/* Generates prototypes and inline functions */
-#define	RB_PROTOTYPE(name, type, field, cmp)				\
-	RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
-#define	RB_PROTOTYPE_STATIC(name, type, field, cmp)			\
-	RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
-#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr)		\
-attr void name##_RB_INSERT_COLOR(struct name *, struct type *);		\
-attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
-attr struct type *name##_RB_REMOVE(struct name *, struct type *);	\
-attr struct type *name##_RB_INSERT(struct name *, struct type *);	\
-attr struct type *name##_RB_FIND(struct name *, struct type *);		\
-attr struct type *name##_RB_NFIND(struct name *, struct type *);	\
-attr struct type *name##_RB_NEXT(struct type *);			\
-attr struct type *name##_RB_PREV(struct type *);			\
-attr struct type *name##_RB_MINMAX(struct name *, int);			\
-									\
-
-/* Main rb operation.
- * Moves node close to the key of elm to top
- */
-#define	RB_GENERATE(name, type, field, cmp)				\
-	RB_GENERATE_INTERNAL(name, type, field, cmp,)
-#define	RB_GENERATE_STATIC(name, type, field, cmp)			\
-	RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
-#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr)		\
-attr void								\
-name##_RB_INSERT_COLOR(struct name *head, struct type *elm)		\
-{									\
-	struct type *parent, *gparent, *tmp;				\
-	while ((parent = RB_PARENT(elm, field)) != NULL &&		\
-	    RB_COLOR(parent, field) == RB_RED) {			\
-		gparent = RB_PARENT(parent, field);			\
-		if (parent == RB_LEFT(gparent, field)) {		\
-			tmp = RB_RIGHT(gparent, field);			\
-			if (tmp && RB_COLOR(tmp, field) == RB_RED) {	\
-				RB_COLOR(tmp, field) = RB_BLACK;	\
-				RB_SET_BLACKRED(parent, gparent, field);\
-				elm = gparent;				\
-				continue;				\
-			}						\
-			if (RB_RIGHT(parent, field) == elm) {		\
-				RB_ROTATE_LEFT(head, parent, tmp, field);\
-				tmp = parent;				\
-				parent = elm;				\
-				elm = tmp;				\
-			}						\
-			RB_SET_BLACKRED(parent, gparent, field);	\
-			RB_ROTATE_RIGHT(head, gparent, tmp, field);	\
-		} else {						\
-			tmp = RB_LEFT(gparent, field);			\
-			if (tmp && RB_COLOR(tmp, field) == RB_RED) {	\
-				RB_COLOR(tmp, field) = RB_BLACK;	\
-				RB_SET_BLACKRED(parent, gparent, field);\
-				elm = gparent;				\
-				continue;				\
-			}						\
-			if (RB_LEFT(parent, field) == elm) {		\
-				RB_ROTATE_RIGHT(head, parent, tmp, field);\
-				tmp = parent;				\
-				parent = elm;				\
-				elm = tmp;				\
-			}						\
-			RB_SET_BLACKRED(parent, gparent, field);	\
-			RB_ROTATE_LEFT(head, gparent, tmp, field);	\
-		}							\
-	}								\
-	RB_COLOR(head->rbh_root, field) = RB_BLACK;			\
-}									\
-									\
-attr void								\
-name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
-{									\
-	struct type *tmp;						\
-	while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) &&	\
-	    elm != RB_ROOT(head)) {					\
-		if (RB_LEFT(parent, field) == elm) {			\
-			tmp = RB_RIGHT(parent, field);			\
-			if (RB_COLOR(tmp, field) == RB_RED) {		\
-				RB_SET_BLACKRED(tmp, parent, field);	\
-				RB_ROTATE_LEFT(head, parent, tmp, field);\
-				tmp = RB_RIGHT(parent, field);		\
-			}						\
-			if ((RB_LEFT(tmp, field) == NULL ||		\
-			    RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
-			    (RB_RIGHT(tmp, field) == NULL ||		\
-			    RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
-				RB_COLOR(tmp, field) = RB_RED;		\
-				elm = parent;				\
-				parent = RB_PARENT(elm, field);		\
-			} else {					\
-				if (RB_RIGHT(tmp, field) == NULL ||	\
-				    RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
-					struct type *oleft;		\
-					if ((oleft = RB_LEFT(tmp, field)) \
-					    != NULL)			\
-						RB_COLOR(oleft, field) = RB_BLACK;\
-					RB_COLOR(tmp, field) = RB_RED;	\
-					RB_ROTATE_RIGHT(head, tmp, oleft, field);\
-					tmp = RB_RIGHT(parent, field);	\
-				}					\
-				RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
-				RB_COLOR(parent, field) = RB_BLACK;	\
-				if (RB_RIGHT(tmp, field))		\
-					RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
-				RB_ROTATE_LEFT(head, parent, tmp, field);\
-				elm = RB_ROOT(head);			\
-				break;					\
-			}						\
-		} else {						\
-			tmp = RB_LEFT(parent, field);			\
-			if (RB_COLOR(tmp, field) == RB_RED) {		\
-				RB_SET_BLACKRED(tmp, parent, field);	\
-				RB_ROTATE_RIGHT(head, parent, tmp, field);\
-				tmp = RB_LEFT(parent, field);		\
-			}						\
-			if ((RB_LEFT(tmp, field) == NULL ||		\
-			    RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
-			    (RB_RIGHT(tmp, field) == NULL ||		\
-			    RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
-				RB_COLOR(tmp, field) = RB_RED;		\
-				elm = parent;				\
-				parent = RB_PARENT(elm, field);		\
-			} else {					\
-				if (RB_LEFT(tmp, field) == NULL ||	\
-				    RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
-					struct type *oright;		\
-					if ((oright = RB_RIGHT(tmp, field)) \
-					    != NULL)			\
-						RB_COLOR(oright, field) = RB_BLACK;\
-					RB_COLOR(tmp, field) = RB_RED;	\
-					RB_ROTATE_LEFT(head, tmp, oright, field);\
-					tmp = RB_LEFT(parent, field);	\
-				}					\
-				RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
-				RB_COLOR(parent, field) = RB_BLACK;	\
-				if (RB_LEFT(tmp, field))		\
-					RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
-				RB_ROTATE_RIGHT(head, parent, tmp, field);\
-				elm = RB_ROOT(head);			\
-				break;					\
-			}						\
-		}							\
-	}								\
-	if (elm)							\
-		RB_COLOR(elm, field) = RB_BLACK;			\
-}									\
-									\
-attr struct type *							\
-name##_RB_REMOVE(struct name *head, struct type *elm)			\
-{									\
-	struct type *child, *parent, *old = elm;			\
-	int color;							\
-	if (RB_LEFT(elm, field) == NULL)				\
-		child = RB_RIGHT(elm, field);				\
-	else if (RB_RIGHT(elm, field) == NULL)				\
-		child = RB_LEFT(elm, field);				\
-	else {								\
-		struct type *left;					\
-		elm = RB_RIGHT(elm, field);				\
-		while ((left = RB_LEFT(elm, field)) != NULL)		\
-			elm = left;					\
-		child = RB_RIGHT(elm, field);				\
-		parent = RB_PARENT(elm, field);				\
-		color = RB_COLOR(elm, field);				\
-		if (child)						\
-			RB_PARENT(child, field) = parent;		\
-		if (parent) {						\
-			if (RB_LEFT(parent, field) == elm)		\
-				RB_LEFT(parent, field) = child;		\
-			else						\
-				RB_RIGHT(parent, field) = child;	\
-			RB_AUGMENT(parent);				\
-		} else							\
-			RB_ROOT(head) = child;				\
-		if (RB_PARENT(elm, field) == old)			\
-			parent = elm;					\
-		(elm)->field = (old)->field;				\
-		if (RB_PARENT(old, field)) {				\
-			if (RB_LEFT(RB_PARENT(old, field), field) == old)\
-				RB_LEFT(RB_PARENT(old, field), field) = elm;\
-			else						\
-				RB_RIGHT(RB_PARENT(old, field), field) = elm;\
-			RB_AUGMENT(RB_PARENT(old, field));		\
-		} else							\
-			RB_ROOT(head) = elm;				\
-		RB_PARENT(RB_LEFT(old, field), field) = elm;		\
-		if (RB_RIGHT(old, field))				\
-			RB_PARENT(RB_RIGHT(old, field), field) = elm;	\
-		if (parent) {						\
-			left = parent;					\
-			do {						\
-				RB_AUGMENT(left);			\
-			} while ((left = RB_PARENT(left, field)) != NULL); \
-		}							\
-		goto color;						\
-	}								\
-	parent = RB_PARENT(elm, field);					\
-	color = RB_COLOR(elm, field);					\
-	if (child)							\
-		RB_PARENT(child, field) = parent;			\
-	if (parent) {							\
-		if (RB_LEFT(parent, field) == elm)			\
-			RB_LEFT(parent, field) = child;			\
-		else							\
-			RB_RIGHT(parent, field) = child;		\
-		RB_AUGMENT(parent);					\
-	} else								\
-		RB_ROOT(head) = child;					\
-color:									\
-	if (color == RB_BLACK)						\
-		name##_RB_REMOVE_COLOR(head, parent, child);		\
-	return (old);							\
-}									\
-									\
-/* Inserts a node into the RB tree */					\
-attr struct type *							\
-name##_RB_INSERT(struct name *head, struct type *elm)			\
-{									\
-	struct type *tmp;						\
-	struct type *parent = NULL;					\
-	int comp = 0;							\
-	tmp = RB_ROOT(head);						\
-	while (tmp) {							\
-		parent = tmp;						\
-		comp = (cmp)(elm, parent);				\
-		if (comp < 0)						\
-			tmp = RB_LEFT(tmp, field);			\
-		else if (comp > 0)					\
-			tmp = RB_RIGHT(tmp, field);			\
-		else							\
-			return (tmp);					\
-	}								\
-	RB_SET(elm, parent, field);					\
-	if (parent != NULL) {						\
-		if (comp < 0)						\
-			RB_LEFT(parent, field) = elm;			\
-		else							\
-			RB_RIGHT(parent, field) = elm;			\
-		RB_AUGMENT(parent);					\
-	} else								\
-		RB_ROOT(head) = elm;					\
-	name##_RB_INSERT_COLOR(head, elm);				\
-	return (NULL);							\
-}									\
-									\
-/* Finds the node with the same key as elm */				\
-attr struct type *							\
-name##_RB_FIND(struct name *head, struct type *elm)			\
-{									\
-	struct type *tmp = RB_ROOT(head);				\
-	int comp;							\
-	while (tmp) {							\
-		comp = cmp(elm, tmp);					\
-		if (comp < 0)						\
-			tmp = RB_LEFT(tmp, field);			\
-		else if (comp > 0)					\
-			tmp = RB_RIGHT(tmp, field);			\
-		else							\
-			return (tmp);					\
-	}								\
-	return (NULL);							\
-}									\
-									\
-/* Finds the first node greater than or equal to the search key */	\
-attr struct type *							\
-name##_RB_NFIND(struct name *head, struct type *elm)			\
-{									\
-	struct type *tmp = RB_ROOT(head);				\
-	struct type *res = NULL;					\
-	int comp;							\
-	while (tmp) {							\
-		comp = cmp(elm, tmp);					\
-		if (comp < 0) {						\
-			res = tmp;					\
-			tmp = RB_LEFT(tmp, field);			\
-		}							\
-		else if (comp > 0)					\
-			tmp = RB_RIGHT(tmp, field);			\
-		else							\
-			return (tmp);					\
-	}								\
-	return (res);							\
-}									\
-									\
-/* ARGSUSED */								\
-attr struct type *							\
-name##_RB_NEXT(struct type *elm)					\
-{									\
-	if (RB_RIGHT(elm, field)) {					\
-		elm = RB_RIGHT(elm, field);				\
-		while (RB_LEFT(elm, field))				\
-			elm = RB_LEFT(elm, field);			\
-	} else {							\
-		if (RB_PARENT(elm, field) &&				\
-		    (elm == RB_LEFT(RB_PARENT(elm, field), field)))	\
-			elm = RB_PARENT(elm, field);			\
-		else {							\
-			while (RB_PARENT(elm, field) &&			\
-			    (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
-				elm = RB_PARENT(elm, field);		\
-			elm = RB_PARENT(elm, field);			\
-		}							\
-	}								\
-	return (elm);							\
-}									\
-									\
-/* ARGSUSED */								\
-attr struct type *							\
-name##_RB_PREV(struct type *elm)					\
-{									\
-	if (RB_LEFT(elm, field)) {					\
-		elm = RB_LEFT(elm, field);				\
-		while (RB_RIGHT(elm, field))				\
-			elm = RB_RIGHT(elm, field);			\
-	} else {							\
-		if (RB_PARENT(elm, field) &&				\
-		    (elm == RB_RIGHT(RB_PARENT(elm, field), field)))	\
-			elm = RB_PARENT(elm, field);			\
-		else {							\
-			while (RB_PARENT(elm, field) &&			\
-			    (elm == RB_LEFT(RB_PARENT(elm, field), field)))\
-				elm = RB_PARENT(elm, field);		\
-			elm = RB_PARENT(elm, field);			\
-		}							\
-	}								\
-	return (elm);							\
-}									\
-									\
-attr struct type *							\
-name##_RB_MINMAX(struct name *head, int val)				\
-{									\
-	struct type *tmp = RB_ROOT(head);				\
-	struct type *parent = NULL;					\
-	while (tmp) {							\
-		parent = tmp;						\
-		if (val < 0)						\
-			tmp = RB_LEFT(tmp, field);			\
-		else							\
-			tmp = RB_RIGHT(tmp, field);			\
-	}								\
-	return (parent);						\
-}
-
-#define RB_NEGINF	-1
-#define RB_INF	1
-
-#define RB_INSERT(name, x, y)	name##_RB_INSERT(x, y)
-#define RB_REMOVE(name, x, y)	name##_RB_REMOVE(x, y)
-#define RB_FIND(name, x, y)	name##_RB_FIND(x, y)
-#define RB_NFIND(name, x, y)	name##_RB_NFIND(x, y)
-#define RB_NEXT(name, x, y)	name##_RB_NEXT(y)
-#define RB_PREV(name, x, y)	name##_RB_PREV(y)
-#define RB_MIN(name, x)		name##_RB_MINMAX(x, RB_NEGINF)
-#define RB_MAX(name, x)		name##_RB_MINMAX(x, RB_INF)
-
-#define RB_FOREACH(x, name, head)					\
-	for ((x) = RB_MIN(name, head);					\
-	     (x) != NULL;						\
-	     (x) = name##_RB_NEXT(x))
-
-#define RB_FOREACH_FROM(x, name, y)					\
-	for ((x) = (y);							\
-	    ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL);	\
-	     (x) = (y))
-
-#define RB_FOREACH_SAFE(x, name, head, y)				\
-	for ((x) = RB_MIN(name, head);					\
-	    ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL);	\
-	     (x) = (y))
-
-#define RB_FOREACH_REVERSE(x, name, head)				\
-	for ((x) = RB_MAX(name, head);					\
-	     (x) != NULL;						\
-	     (x) = name##_RB_PREV(x))
-
-#define RB_FOREACH_REVERSE_FROM(x, name, y)				\
-	for ((x) = (y);							\
-	    ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL);	\
-	     (x) = (y))
-
-#define RB_FOREACH_REVERSE_SAFE(x, name, head, y)			\
-	for ((x) = RB_MAX(name, head);					\
-	    ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL);	\
-	     (x) = (y))
-
-#endif	/* _SYS_TREE_H_ */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3112f263/hadoop-hdfs-project/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/pom.xml b/hadoop-hdfs-project/pom.xml
index 0a61c46..4d53edd 100644
--- a/hadoop-hdfs-project/pom.xml
+++ b/hadoop-hdfs-project/pom.xml
@@ -33,6 +33,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modules>
     <module>hadoop-hdfs</module>
     <module>hadoop-hdfs-client</module>
+    <module>hadoop-hdfs-native-client</module>
     <module>hadoop-hdfs-httpfs</module>
     <module>hadoop-hdfs/src/contrib/bkjournal</module>
     <module>hadoop-hdfs-nfs</module>