home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / test-many-datafiles-import.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  4KB  |  163 lines

  1. /*
  2.  * (C) 2002 Clemson University.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */       
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <pvfs2-types.h>
  10. #include <gossip.h>
  11. #include <pvfs2-debug.h>
  12.  
  13. #include <pint-distribution.h>
  14. #include <pint-dist-utils.h>
  15. #include <pvfs2-request.h>
  16. #include <pint-request.h>
  17. #include <assert.h>
  18. #include "pvfs2-internal.h"
  19.  
  20. #define SEGMAX 16
  21. #define BYTEMAX (4*1024*1024)
  22.  
  23. int main(int argc, char **argv)
  24. {
  25.     int i,j;
  26.     PINT_Request *file_req;
  27.     PINT_Request *mem_req;
  28.     PINT_Request_state *mem_state;
  29.     PINT_Request_state *file_state;
  30.     PINT_Request_state *file_state_server;
  31.     PINT_request_file_data rf1;
  32.     PINT_Request_result seg1;
  33.     PVFS_size total_bytes_client = 0;
  34.     PVFS_size total_bytes_server = 0;
  35.  
  36.     /* PVFS_Process_request arguments */
  37.     int retval;
  38.  
  39.     /* setup file datatype */
  40.     file_req = PVFS_BYTE;
  41.  
  42.     PINT_dist_initialize(NULL);
  43.  
  44.     /* setup mem datatype */
  45.     PVFS_Request_contiguous(2251664, PVFS_BYTE, &mem_req);
  46.  
  47.     for(j=0; j<67; j++)
  48.     {
  49.         mem_state = PINT_new_request_state(mem_req);
  50.         file_state = PINT_new_request_state(file_req);
  51.         file_state_server = PINT_new_request_state(file_req);
  52.  
  53.         /* set up file data for request */
  54.         rf1.server_nr = j;
  55.         rf1.server_ct = 67;
  56.         rf1.fsize = 41943040;
  57.         rf1.dist = PINT_dist_create("simple_stripe");
  58.         rf1.extend_flag = 1;
  59.         PINT_dist_lookup(rf1.dist);
  60.  
  61.         /* set up result struct */
  62.         seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  63.         seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  64.         seg1.bytemax = BYTEMAX;
  65.         seg1.segmax = SEGMAX;
  66.         seg1.bytes = 0;
  67.         seg1.segs = 0;
  68.         
  69.  
  70.         PINT_REQUEST_STATE_SET_TARGET(file_state, 41943040);
  71.         PINT_REQUEST_STATE_SET_FINAL(file_state, 41943040+PINT_REQUEST_TOTAL_BYTES(mem_req));
  72.         PINT_REQUEST_STATE_SET_TARGET(file_state_server, 41943040);
  73.         PINT_REQUEST_STATE_SET_FINAL(file_state_server, 41943040+PINT_REQUEST_TOTAL_BYTES(mem_req));
  74.  
  75.  
  76.        /* Turn on debugging */
  77.         // gossip_enable_stderr();
  78.         // gossip_set_debug_mask(1,REQUEST_DEBUG); 
  79.  
  80.         printf("\nCLIENT ************************************\n");
  81.         do
  82.         {
  83.             seg1.bytes = 0;
  84.             seg1.segs = 0;
  85.             total_bytes_client = 0;
  86.             total_bytes_server = 0;
  87.  
  88.             /* process request */
  89.             retval = PINT_process_request(file_state, mem_state, &rf1, &seg1, PINT_CLIENT);
  90.  
  91.             if(retval >= 0)
  92.             {
  93.                 printf("results of PINT_process_request():\n");
  94.                 printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  95.                 total_bytes_client += seg1.bytes;
  96.                 for(i=0; i<seg1.segs; i++)
  97.                 {
  98.                     printf("  segment %d: offset: %d size: %d\n",
  99.                         i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  100.                 }
  101.             }
  102.  
  103.         } while(!PINT_REQUEST_DONE(file_state) && retval >= 0);
  104.         
  105.         if(retval < 0)
  106.         {
  107.             fprintf(stderr, "Error: PINT_process_request() failure.\n");
  108.             return(-1);
  109.         }
  110.         if(PINT_REQUEST_DONE(file_state))
  111.         {
  112.             printf("**** request done.\n");
  113.         }
  114.         
  115.         printf("\nSERVER ************************************\n");
  116.         do
  117.         {
  118.             seg1.bytes = 0;
  119.             seg1.segs = 0;
  120.  
  121.             /* process request */
  122.             retval = PINT_process_request(file_state_server, NULL, &rf1, &seg1, PINT_SERVER);
  123.  
  124.             if(retval >= 0)
  125.             {
  126.                 printf("results of PINT_process_request():\n");
  127.                 printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  128.                 total_bytes_server += seg1.bytes;
  129.                 for(i=0; i<seg1.segs; i++)
  130.                 {
  131.                     printf("  segment %d: offset: %d size: %d\n",
  132.                         i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  133.                 }
  134.             }
  135.  
  136.         } while(!PINT_REQUEST_DONE(file_state_server) && retval >= 0);
  137.  
  138.         if(retval < 0)
  139.         {
  140.             fprintf(stderr, "Error: PINT_process_request() failure.\n");
  141.             return(-1);
  142.         }
  143.         if(PINT_REQUEST_DONE(file_state_server))
  144.         {
  145.             printf("**** request done.\n");
  146.         }
  147.  
  148.         printf("total bytes processed on client side: %lld\n", (long long)total_bytes_client);
  149.         printf("total bytes processed on server side: %lld\n", (long long)total_bytes_server);
  150.  
  151.         if(total_bytes_client == total_bytes_server)
  152.         {
  153.         printf("SUCCESS.\n");
  154.         }
  155.         else
  156.         {
  157.         printf("FAILURE!!!\n");
  158.         }
  159.     }
  160.  
  161.     return 0;
  162. }
  163.