Exemplo n.º 1
0
/**
 * hdfsGetUsed - Return the total raw size of all files in the filesystem.
 *
 * @param fs The configured filesystem handle.
 * @return Returns the total-size; -1 on error.
 */
tOffset
hdfsGetUsed(hdfsFS fs)
{
	tOffset res = -1;
	struct hdfsFS_internal *client = fs;
	struct hdfs_object *ex = NULL, *stats_arr = NULL;

	stats_arr = hdfs_getStats(client->fs_namenode, &ex);
	if (ex) {
		ERR(EIO, "getStats(): %s", hdfs_exception_get_message(ex));
		goto out;
	}
	if (stats_arr->ob_type == H_NULL) {
		ERR(EIO, "getStats(): got bogus null array");
		goto out;
	}
	if (stats_arr->ob_val._array_long._len < 2) {
		ERR(EIO, "getStats(): got short stats array");
		goto out;
	}

	res = stats_arr->ob_val._array_long._vals[1];

out:
	if (stats_arr)
		hdfs_object_free(stats_arr);
	if (ex)
		hdfs_object_free(ex);
	return res;
}
Exemplo n.º 2
0
END_TEST

START_TEST(test_getStats)
{
	struct hdfs_object *e = NULL, *stats;

	stats = hdfs_getStats(h, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	hdfs_object_free(stats);
}