test_libhdfs_ops.c 19 KB

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