test_libhdfs_ops.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "hdfs.h"
  19. #include "hdfs_test.h"
  20. #include "platform.h"
  21. #include <inttypes.h>
  22. #include <jni.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <time.h>
  27. #include <unistd.h>
  28. void permission_disp(short permissions, char *rtr) {
  29. int i;
  30. short permissionsId;
  31. char* perm;
  32. rtr[9] = '\0';
  33. for(i=2;i>=0;i--)
  34. {
  35. permissionsId = permissions >> (i * 3) & (short)7;
  36. switch(permissionsId) {
  37. case 7:
  38. perm = "rwx"; break;
  39. case 6:
  40. perm = "rw-"; break;
  41. case 5:
  42. perm = "r-x"; break;
  43. case 4:
  44. perm = "r--"; break;
  45. case 3:
  46. perm = "-wx"; break;
  47. case 2:
  48. perm = "-w-"; break;
  49. case 1:
  50. perm = "--x"; break;
  51. case 0:
  52. perm = "---"; break;
  53. default:
  54. perm = "???";
  55. }
  56. strncpy(rtr, perm, 3);
  57. rtr+=3;
  58. }
  59. }
  60. int main(int argc, char **argv) {
  61. const char *writePath = "/tmp/testfile.txt";
  62. const char *fileContents = "Hello, World!";
  63. const char *readPath = "/tmp/testfile.txt";
  64. const char *srcPath = "/tmp/testfile.txt";
  65. const char *dstPath = "/tmp/testfile2.txt";
  66. const char *slashTmp = "/tmp";
  67. const char *newDirectory = "/tmp/newdir";
  68. const char *newOwner = "root";
  69. const char *tuser = "nobody";
  70. const char *appendPath = "/tmp/appends";
  71. const char *userPath = "/tmp/usertestfile.txt";
  72. char buffer[32], buffer2[256], rdbuffer[32];
  73. tSize num_written_bytes, num_read_bytes;
  74. hdfsFS fs, lfs;
  75. hdfsFile writeFile, readFile, localFile, appendFile, userFile;
  76. tOffset currentPos, seekPos;
  77. int exists, totalResult, result, numEntries, i, j;
  78. const char *resp;
  79. hdfsFileInfo *fileInfo, *fileList, *finfo;
  80. char *buffer3;
  81. char permissions[10];
  82. char ***hosts;
  83. short newPerm = 0666;
  84. tTime newMtime, newAtime;
  85. fs = hdfsConnectNewInstance("default", 0);
  86. if(!fs) {
  87. fprintf(stderr, "Oops! Failed to connect to hdfs!\n");
  88. exit(-1);
  89. }
  90. lfs = hdfsConnectNewInstance(NULL, 0);
  91. if(!lfs) {
  92. fprintf(stderr, "Oops! Failed to connect to 'local' hdfs!\n");
  93. exit(-1);
  94. }
  95. {
  96. //Write tests
  97. writeFile = hdfsOpenFile(fs, writePath, O_WRONLY|O_CREAT, 0, 0, 0);
  98. if(!writeFile) {
  99. fprintf(stderr, "Failed to open %s for writing!\n", writePath);
  100. exit(-1);
  101. }
  102. fprintf(stderr, "Opened %s for writing successfully...\n", writePath);
  103. num_written_bytes =
  104. hdfsWrite(fs, writeFile, (void*)fileContents,
  105. (tSize)(strlen(fileContents)+1));
  106. if (num_written_bytes != strlen(fileContents) + 1) {
  107. fprintf(stderr, "Failed to write correct number of bytes - expected %d, got %d\n",
  108. (int)(strlen(fileContents) + 1), (int)num_written_bytes);
  109. exit(-1);
  110. }
  111. fprintf(stderr, "Wrote %d bytes\n", num_written_bytes);
  112. currentPos = -1;
  113. if ((currentPos = hdfsTell(fs, writeFile)) == -1) {
  114. fprintf(stderr,
  115. "Failed to get current file position correctly! Got %ld!\n",
  116. currentPos);
  117. exit(-1);
  118. }
  119. fprintf(stderr, "Current position: %ld\n", currentPos);
  120. if (hdfsFlush(fs, writeFile)) {
  121. fprintf(stderr, "Failed to 'flush' %s\n", writePath);
  122. exit(-1);
  123. }
  124. fprintf(stderr, "Flushed %s successfully!\n", writePath);
  125. if (hdfsHFlush(fs, writeFile)) {
  126. fprintf(stderr, "Failed to 'hflush' %s\n", writePath);
  127. exit(-1);
  128. }
  129. fprintf(stderr, "HFlushed %s successfully!\n", writePath);
  130. hdfsCloseFile(fs, writeFile);
  131. }
  132. {
  133. //Read tests
  134. exists = hdfsExists(fs, readPath);
  135. if (exists) {
  136. fprintf(stderr, "Failed to validate existence of %s\n", readPath);
  137. exit(-1);
  138. }
  139. readFile = hdfsOpenFile(fs, readPath, O_RDONLY, 0, 0, 0);
  140. if (!readFile) {
  141. fprintf(stderr, "Failed to open %s for reading!\n", readPath);
  142. exit(-1);
  143. }
  144. if (!hdfsFileIsOpenForRead(readFile)) {
  145. fprintf(stderr, "hdfsFileIsOpenForRead: we just opened a file "
  146. "with O_RDONLY, and it did not show up as 'open for "
  147. "read'\n");
  148. exit(-1);
  149. }
  150. fprintf(stderr, "hdfsAvailable: %d\n", hdfsAvailable(fs, readFile));
  151. seekPos = 1;
  152. if(hdfsSeek(fs, readFile, seekPos)) {
  153. fprintf(stderr, "Failed to seek %s for reading!\n", readPath);
  154. exit(-1);
  155. }
  156. currentPos = -1;
  157. if((currentPos = hdfsTell(fs, readFile)) != seekPos) {
  158. fprintf(stderr,
  159. "Failed to get current file position correctly! Got %ld!\n",
  160. currentPos);
  161. exit(-1);
  162. }
  163. fprintf(stderr, "Current position: %ld\n", currentPos);
  164. if (!hdfsFileUsesDirectRead(readFile)) {
  165. fprintf(stderr, "Direct read support incorrectly not detected "
  166. "for HDFS filesystem\n");
  167. exit(-1);
  168. }
  169. fprintf(stderr, "Direct read support detected for HDFS\n");
  170. // Test the direct read path
  171. if(hdfsSeek(fs, readFile, 0)) {
  172. fprintf(stderr, "Failed to seek %s for reading!\n", readPath);
  173. exit(-1);
  174. }
  175. memset(buffer, 0, sizeof(buffer));
  176. num_read_bytes = hdfsRead(fs, readFile, (void*)buffer,
  177. sizeof(buffer));
  178. if (strncmp(fileContents, buffer, strlen(fileContents)) != 0) {
  179. fprintf(stderr, "Failed to read (direct). Expected %s but got %s (%d bytes)\n",
  180. fileContents, buffer, num_read_bytes);
  181. exit(-1);
  182. }
  183. fprintf(stderr, "Read (direct) following %d bytes:\n%s\n",
  184. num_read_bytes, buffer);
  185. if (hdfsSeek(fs, readFile, 0L)) {
  186. fprintf(stderr, "Failed to seek to file start!\n");
  187. exit(-1);
  188. }
  189. // Disable the direct read path so that we really go through the slow
  190. // read path
  191. hdfsFileDisableDirectRead(readFile);
  192. num_read_bytes = hdfsRead(fs, readFile, (void*)buffer,
  193. sizeof(buffer));
  194. fprintf(stderr, "Read following %d bytes:\n%s\n",
  195. num_read_bytes, buffer);
  196. memset(buffer, 0, strlen(fileContents + 1));
  197. num_read_bytes = hdfsPread(fs, readFile, 0, (void*)buffer,
  198. sizeof(buffer));
  199. fprintf(stderr, "Read following %d bytes:\n%s\n",
  200. num_read_bytes, buffer);
  201. hdfsCloseFile(fs, readFile);
  202. // Test correct behaviour for unsupported filesystems
  203. localFile = hdfsOpenFile(lfs, writePath, O_WRONLY|O_CREAT, 0, 0, 0);
  204. if(!localFile) {
  205. fprintf(stderr, "Failed to open %s for writing!\n", writePath);
  206. exit(-1);
  207. }
  208. num_written_bytes = hdfsWrite(lfs, localFile, (void*)fileContents,
  209. (tSize)(strlen(fileContents) + 1));
  210. hdfsCloseFile(lfs, localFile);
  211. localFile = hdfsOpenFile(lfs, writePath, O_RDONLY, 0, 0, 0);
  212. if (hdfsFileUsesDirectRead(localFile)) {
  213. fprintf(stderr, "Direct read support incorrectly detected for local "
  214. "filesystem\n");
  215. exit(-1);
  216. }
  217. hdfsCloseFile(lfs, localFile);
  218. }
  219. totalResult = 0;
  220. result = 0;
  221. {
  222. //Generic file-system operations
  223. fprintf(stderr, "hdfsCopy(remote-local): %s\n", ((result = hdfsCopy(fs, srcPath, lfs, srcPath)) != 0 ? "Failed!" : "Success!"));
  224. totalResult += result;
  225. fprintf(stderr, "hdfsCopy(remote-remote): %s\n", ((result = hdfsCopy(fs, srcPath, fs, dstPath)) != 0 ? "Failed!" : "Success!"));
  226. totalResult += result;
  227. fprintf(stderr, "hdfsMove(local-local): %s\n", ((result = hdfsMove(lfs, srcPath, lfs, dstPath)) != 0 ? "Failed!" : "Success!"));
  228. totalResult += result;
  229. fprintf(stderr, "hdfsMove(remote-local): %s\n", ((result = hdfsMove(fs, srcPath, lfs, srcPath)) != 0 ? "Failed!" : "Success!"));
  230. totalResult += result;
  231. fprintf(stderr, "hdfsRename: %s\n", ((result = hdfsRename(fs, dstPath, srcPath)) != 0 ? "Failed!" : "Success!"));
  232. totalResult += result;
  233. fprintf(stderr, "hdfsCopy(remote-remote): %s\n", ((result = hdfsCopy(fs, srcPath, fs, dstPath)) != 0 ? "Failed!" : "Success!"));
  234. totalResult += result;
  235. fprintf(stderr, "hdfsCreateDirectory: %s\n", ((result = hdfsCreateDirectory(fs, newDirectory)) != 0 ? "Failed!" : "Success!"));
  236. totalResult += result;
  237. fprintf(stderr, "hdfsSetReplication: %s\n", ((result = hdfsSetReplication(fs, srcPath, 2)) != 0 ? "Failed!" : "Success!"));
  238. totalResult += result;
  239. fprintf(stderr, "hdfsGetWorkingDirectory: %s\n", ((resp = hdfsGetWorkingDirectory(fs, buffer2, sizeof(buffer2))) != 0 ? buffer2 : "Failed!"));
  240. totalResult += (resp ? 0 : 1);
  241. fprintf(stderr, "hdfsSetWorkingDirectory: %s\n", ((result = hdfsSetWorkingDirectory(fs, slashTmp)) != 0 ? "Failed!" : "Success!"));
  242. totalResult += result;
  243. fprintf(stderr, "hdfsGetWorkingDirectory: %s\n", ((resp = hdfsGetWorkingDirectory(fs, buffer2, sizeof(buffer2))) != 0 ? buffer2 : "Failed!"));
  244. totalResult += (resp ? 0 : 1);
  245. fprintf(stderr, "hdfsGetDefaultBlockSize: %ld\n", hdfsGetDefaultBlockSize(fs));
  246. fprintf(stderr, "hdfsGetCapacity: %ld\n", hdfsGetCapacity(fs));
  247. fprintf(stderr, "hdfsGetUsed: %ld\n", hdfsGetUsed(fs));
  248. fileInfo = NULL;
  249. if((fileInfo = hdfsGetPathInfo(fs, slashTmp)) != NULL) {
  250. fprintf(stderr, "hdfsGetPathInfo - SUCCESS!\n");
  251. fprintf(stderr, "Name: %s, ", fileInfo->mName);
  252. fprintf(stderr, "Type: %c, ", (char)(fileInfo->mKind));
  253. fprintf(stderr, "Replication: %d, ", fileInfo->mReplication);
  254. fprintf(stderr, "BlockSize: %ld, ", fileInfo->mBlockSize);
  255. fprintf(stderr, "Size: %ld, ", fileInfo->mSize);
  256. fprintf(stderr, "LastMod: %s", ctime(&fileInfo->mLastMod));
  257. fprintf(stderr, "Owner: %s, ", fileInfo->mOwner);
  258. fprintf(stderr, "Group: %s, ", fileInfo->mGroup);
  259. permission_disp(fileInfo->mPermissions, permissions);
  260. fprintf(stderr, "Permissions: %d (%s)\n", fileInfo->mPermissions, permissions);
  261. hdfsFreeFileInfo(fileInfo, 1);
  262. } else {
  263. totalResult++;
  264. fprintf(stderr, "waah! hdfsGetPathInfo for %s - FAILED!\n", slashTmp);
  265. }
  266. fileList = 0;
  267. if((fileList = hdfsListDirectory(fs, slashTmp, &numEntries)) != NULL) {
  268. for(i=0; i < numEntries; ++i) {
  269. fprintf(stderr, "Name: %s, ", fileList[i].mName);
  270. fprintf(stderr, "Type: %c, ", (char)fileList[i].mKind);
  271. fprintf(stderr, "Replication: %d, ", fileList[i].mReplication);
  272. fprintf(stderr, "BlockSize: %ld, ", fileList[i].mBlockSize);
  273. fprintf(stderr, "Size: %ld, ", fileList[i].mSize);
  274. fprintf(stderr, "LastMod: %s", ctime(&fileList[i].mLastMod));
  275. fprintf(stderr, "Owner: %s, ", fileList[i].mOwner);
  276. fprintf(stderr, "Group: %s, ", fileList[i].mGroup);
  277. permission_disp(fileList[i].mPermissions, permissions);
  278. fprintf(stderr, "Permissions: %d (%s)\n", fileList[i].mPermissions, permissions);
  279. }
  280. hdfsFreeFileInfo(fileList, numEntries);
  281. } else {
  282. if (errno) {
  283. totalResult++;
  284. fprintf(stderr, "waah! hdfsListDirectory - FAILED!\n");
  285. } else {
  286. fprintf(stderr, "Empty directory!\n");
  287. }
  288. }
  289. hosts = hdfsGetHosts(fs, srcPath, 0, 1);
  290. if(hosts) {
  291. fprintf(stderr, "hdfsGetHosts - SUCCESS! ... \n");
  292. i=0;
  293. while(hosts[i]) {
  294. j = 0;
  295. while(hosts[i][j]) {
  296. fprintf(stderr,
  297. "\thosts[%d][%d] - %s\n", i, j, hosts[i][j]);
  298. ++j;
  299. }
  300. ++i;
  301. }
  302. } else {
  303. totalResult++;
  304. fprintf(stderr, "waah! hdfsGetHosts - FAILED!\n");
  305. }
  306. // setting tmp dir to 777 so later when connectAsUser nobody, we can write to it
  307. // chown write
  308. fprintf(stderr, "hdfsChown: %s\n", ((result = hdfsChown(fs, writePath, NULL, "users")) != 0 ? "Failed!" : "Success!"));
  309. totalResult += result;
  310. fprintf(stderr, "hdfsChown: %s\n", ((result = hdfsChown(fs, writePath, newOwner, NULL)) != 0 ? "Failed!" : "Success!"));
  311. totalResult += result;
  312. // chmod write
  313. fprintf(stderr, "hdfsChmod: %s\n", ((result = hdfsChmod(fs, writePath, newPerm)) != 0 ? "Failed!" : "Success!"));
  314. totalResult += result;
  315. sleep(2);
  316. newMtime = time(NULL);
  317. newAtime = time(NULL);
  318. // utime write
  319. fprintf(stderr, "hdfsUtime: %s\n", ((result = hdfsUtime(fs, writePath, newMtime, newAtime)) != 0 ? "Failed!" : "Success!"));
  320. totalResult += result;
  321. // chown/chmod/utime read
  322. finfo = hdfsGetPathInfo(fs, writePath);
  323. fprintf(stderr, "hdfsChown read: %s\n", ((result = (strcmp(finfo->mOwner, newOwner))) != 0 ? "Failed!" : "Success!"));
  324. totalResult += result;
  325. fprintf(stderr, "hdfsChmod read: %s\n", ((result = (finfo->mPermissions != newPerm)) != 0 ? "Failed!" : "Success!"));
  326. totalResult += result;
  327. // will later use /tmp/ as a different user so enable it
  328. fprintf(stderr, "hdfsChmod: %s\n", ((result = hdfsChmod(fs, "/tmp/", 0777)) != 0 ? "Failed!" : "Success!"));
  329. totalResult += result;
  330. fprintf(stderr,"newMTime=%ld\n",newMtime);
  331. fprintf(stderr,"curMTime=%ld\n",finfo->mLastMod);
  332. fprintf(stderr, "hdfsUtime read (mtime): %s\n", ((result = (finfo->mLastMod != newMtime)) != 0 ? "Failed!" : "Success!"));
  333. totalResult += result;
  334. // No easy way to turn on access times from hdfs_test right now
  335. // fprintf(stderr, "hdfsUtime read (atime): %s\n", ((result = (finfo->mLastAccess != newAtime)) != 0 ? "Failed!" : "Success!"));
  336. // totalResult += result;
  337. hdfsFreeFileInfo(finfo, 1);
  338. // Clean up
  339. fprintf(stderr, "hdfsDelete: %s\n", ((result = hdfsDelete(fs, newDirectory, 1)) != 0 ? "Failed!" : "Success!"));
  340. totalResult += result;
  341. fprintf(stderr, "hdfsDelete: %s\n", ((result = hdfsDelete(fs, srcPath, 1)) != 0 ? "Failed!" : "Success!"));
  342. totalResult += result;
  343. fprintf(stderr, "hdfsDelete: %s\n", ((result = hdfsDelete(lfs, srcPath, 1)) != 0 ? "Failed!" : "Success!"));
  344. totalResult += result;
  345. fprintf(stderr, "hdfsDelete: %s\n", ((result = hdfsDelete(lfs, dstPath, 1)) != 0 ? "Failed!" : "Success!"));
  346. totalResult += result;
  347. fprintf(stderr, "hdfsExists: %s\n", ((result = hdfsExists(fs, newDirectory)) != 0 ? "Success!" : "Failed!"));
  348. totalResult += (result ? 0 : 1);
  349. }
  350. {
  351. // TEST APPENDS
  352. // CREATE
  353. appendFile = hdfsOpenFile(fs, appendPath, O_WRONLY, 0, 0, 0);
  354. if(!appendFile) {
  355. fprintf(stderr, "Failed to open %s for writing!\n", appendPath);
  356. exit(-1);
  357. }
  358. fprintf(stderr, "Opened %s for writing successfully...\n", appendPath);
  359. buffer3 = "Hello,";
  360. num_written_bytes = hdfsWrite(fs, appendFile, (void*)buffer3,
  361. (tSize)strlen(buffer3));
  362. fprintf(stderr, "Wrote %d bytes\n", num_written_bytes);
  363. if (hdfsFlush(fs, appendFile)) {
  364. fprintf(stderr, "Failed to 'flush' %s\n", appendPath);
  365. exit(-1);
  366. }
  367. fprintf(stderr, "Flushed %s successfully!\n", appendPath);
  368. hdfsCloseFile(fs, appendFile);
  369. // RE-OPEN
  370. appendFile = hdfsOpenFile(fs, appendPath, O_WRONLY|O_APPEND, 0, 0, 0);
  371. if(!appendFile) {
  372. fprintf(stderr, "Failed to open %s for writing!\n", appendPath);
  373. exit(-1);
  374. }
  375. fprintf(stderr, "Opened %s for writing successfully...\n", appendPath);
  376. buffer3 = " World";
  377. num_written_bytes = hdfsWrite(fs, appendFile, (void*)buffer3,
  378. (tSize)(strlen(buffer3) + 1));
  379. fprintf(stderr, "Wrote %d bytes\n", num_written_bytes);
  380. if (hdfsFlush(fs, appendFile)) {
  381. fprintf(stderr, "Failed to 'flush' %s\n", appendPath);
  382. exit(-1);
  383. }
  384. fprintf(stderr, "Flushed %s successfully!\n", appendPath);
  385. hdfsCloseFile(fs, appendFile);
  386. // CHECK size
  387. finfo = hdfsGetPathInfo(fs, appendPath);
  388. fprintf(stderr, "fileinfo->mSize: == total %s\n", ((result = (finfo->mSize == (tOffset)(strlen("Hello, World") + 1))) == 1 ? "Success!" : "Failed!"));
  389. totalResult += (result ? 0 : 1);
  390. // READ and check data
  391. readFile = hdfsOpenFile(fs, appendPath, O_RDONLY, 0, 0, 0);
  392. if (!readFile) {
  393. fprintf(stderr, "Failed to open %s for reading!\n", appendPath);
  394. exit(-1);
  395. }
  396. num_read_bytes = hdfsRead(fs, readFile, (void*)rdbuffer, sizeof(rdbuffer));
  397. fprintf(stderr, "Read following %d bytes:\n%s\n",
  398. num_read_bytes, rdbuffer);
  399. fprintf(stderr, "read == Hello, World %s\n", ((result = (strcmp(rdbuffer, "Hello, World"))) == 0 ? "Success!" : "Failed!"));
  400. hdfsCloseFile(fs, readFile);
  401. // DONE test appends
  402. }
  403. totalResult += (hdfsDisconnect(fs) != 0);
  404. {
  405. //
  406. // Now test as connecting as a specific user
  407. // This is only meant to test that we connected as that user, not to test
  408. // the actual fs user capabilities. Thus just create a file and read
  409. // the owner is correct.
  410. fs = hdfsConnectAsUserNewInstance("default", 0, tuser);
  411. if(!fs) {
  412. fprintf(stderr, "Oops! Failed to connect to hdfs as user %s!\n",tuser);
  413. exit(-1);
  414. }
  415. userFile = hdfsOpenFile(fs, userPath, O_WRONLY|O_CREAT, 0, 0, 0);
  416. if(!userFile) {
  417. fprintf(stderr, "Failed to open %s for writing!\n", userPath);
  418. exit(-1);
  419. }
  420. fprintf(stderr, "Opened %s for writing successfully...\n", userPath);
  421. num_written_bytes = hdfsWrite(fs, userFile, (void*)fileContents,
  422. (tSize)(strlen(fileContents)+1));
  423. fprintf(stderr, "Wrote %d bytes\n", num_written_bytes);
  424. if (hdfsFlush(fs, userFile)) {
  425. fprintf(stderr, "Failed to 'flush' %s\n", userPath);
  426. exit(-1);
  427. }
  428. fprintf(stderr, "Flushed %s successfully!\n", userPath);
  429. hdfsCloseFile(fs, userFile);
  430. finfo = hdfsGetPathInfo(fs, userPath);
  431. fprintf(stderr, "hdfs new file user is correct: %s\n", ((result = (strcmp(finfo->mOwner, tuser))) != 0 ? "Failed!" : "Success!"));
  432. totalResult += result;
  433. }
  434. totalResult += (hdfsDisconnect(fs) != 0);
  435. if (totalResult != 0) {
  436. return -1;
  437. } else {
  438. return 0;
  439. }
  440. }
  441. /**
  442. * vim: ts=4: sw=4: et:
  443. */