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 / debug2.c < prev    next >
C/C++ Source or Header  |  2005-07-07  |  8KB  |  342 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 <string.h>
  10. #include <pvfs2-types.h>
  11. #include <gossip.h>
  12. #include <pvfs2-debug.h>
  13.  
  14. #include <pint-distribution.h>
  15. #include <pint-dist-utils.h>
  16. #include <pvfs2-request.h>
  17. #include <pint-request.h>
  18.  
  19. #include <debug.h>
  20.  
  21. #define SEGMAX 16
  22. #define BYTEMAX (1024*1024)
  23.  
  24. PVFS_offset exp1_offset[] =
  25. {
  26.         0
  27. };
  28. PVFS_offset exp1_size[] =
  29. {
  30.         1048576
  31. };
  32. PINT_Request_result expected[] =
  33. {{
  34.        offset_array : &exp1_offset[0],
  35.        size_array : &exp1_size[0],
  36.        segmax : SEGMAX,
  37.        segs : 1,
  38.        bytes : 1048576
  39. }, {
  40.        offset_array : &exp1_offset[0],
  41.        size_array : &exp1_size[0],
  42.        segmax : SEGMAX,
  43.        segs : 1,
  44.        bytes : 1048576
  45. }, {
  46.        offset_array : &exp1_offset[0],
  47.        size_array : &exp1_size[0],
  48.        segmax : SEGMAX,
  49.        segs : 1,
  50.        bytes : 1048576
  51. }, {
  52.        offset_array : &exp1_offset[0],
  53.        size_array : &exp1_size[0],
  54.        segmax : SEGMAX,
  55.        segs : 1,
  56.        bytes : 1048576
  57. }};
  58.  
  59.  
  60. int request_debug(void)
  61. {
  62.     int i;
  63.     PINT_Request *r;
  64.     PINT_Request *r_enc;
  65.     PINT_Request *r_dec;
  66.     PINT_Request_state *rs1;
  67.     PINT_Request_state *rs2;
  68.     PINT_Request_state *rs3;
  69.     PINT_Request_state *rs4;
  70.     PINT_request_file_data rf1;
  71.     PINT_request_file_data rf2;
  72.     PINT_request_file_data rf3;
  73.     PINT_request_file_data rf4;
  74.     PINT_Request_result seg1;
  75.     int ret = -1;
  76.     int pack_size = 0;
  77.  
  78.     /* PVFS_Process_request arguments */
  79.     int retval;
  80.  
  81.     /* the case that we want to test is a write, with 4 servers holding
  82.      * parts of the file data.  We will setup 4 different request states,
  83.      * one per server.  The request will be large enough that all 4
  84.      * servers will be involved
  85.      */
  86.  
  87.     /* set up one request, we will reuse it for each server scenario */
  88.     /* we want to read 4M of data, resulting from 1M from each server */
  89.     PVFS_Request_contiguous((4*1024*1024), PVFS_BYTE, &r);
  90.  
  91.     /* allocate a new request and pack the original one into it */
  92.     pack_size = PINT_REQUEST_PACK_SIZE(r);
  93.     r_enc = (PINT_Request*)malloc(pack_size);
  94.     ret = PINT_request_commit(r_enc, r);
  95.     if(ret < 0)
  96.     {
  97.         fprintf(stderr, "PINT_Request_commit() failure.\n");
  98.         return(-1);
  99.     }
  100.     ret = PINT_request_encode(r_enc);
  101.     if(ret < 0)
  102.     {
  103.         fprintf(stderr, "PINT_Request_encode() failure.\n");
  104.         return(-1);
  105.     }
  106.  
  107.  
  108.     /* decode the encoded request (hopefully ending up with something
  109.      * equivalent to the original request)
  110.      */
  111.     r_dec = (PINT_Request*)malloc(pack_size);
  112.     memcpy(r_dec, r_enc, pack_size);
  113.     free(r_enc);
  114.     free(r);
  115.     ret = PINT_request_decode(r_dec);
  116.     if(ret < 0)
  117.     {
  118.         fprintf(stderr, "PINT_request_decode() failure.\n");
  119.         return(-1);
  120.     }
  121.  
  122.     /* set up four request states */
  123.     rs1 = PINT_new_request_state(r_dec);
  124.     rs2 = PINT_new_request_state(r_dec);
  125.     rs3 = PINT_new_request_state(r_dec);
  126.     rs4 = PINT_new_request_state(r_dec);
  127.  
  128.     /* set up file data for each server */
  129.     PINT_dist_initialize(NULL);
  130.     rf1.server_nr = 0;
  131.     rf1.server_ct = 4;
  132.     rf1.fsize = 0;
  133.     rf1.dist = PINT_dist_create("simple_stripe");
  134.     rf1.extend_flag = 1;
  135.     PINT_dist_lookup(rf1.dist);
  136.  
  137.     rf2.server_nr = 1;
  138.     rf2.server_ct = 4;
  139.     rf2.fsize = 0;
  140.     rf2.dist = PINT_dist_create("simple_stripe");
  141.     rf2.extend_flag = 1;
  142.     PINT_dist_lookup(rf2.dist);
  143.  
  144.     rf3.server_nr = 2;
  145.     rf3.server_ct = 4;
  146.     rf3.fsize = 0;
  147.     rf3.dist = PINT_dist_create("simple_stripe");
  148.     rf3.extend_flag = 1;
  149.     PINT_dist_lookup(rf3.dist);
  150.  
  151.     rf4.server_nr = 3;
  152.     rf4.server_ct = 4;
  153.     rf4.fsize = 0;
  154.     rf4.dist = PINT_dist_create("simple_stripe");
  155.     rf4.extend_flag = 1;
  156.     PINT_dist_lookup(rf4.dist);
  157.  
  158.     /* set up response for each server */
  159.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  160.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  161.     seg1.segmax = SEGMAX;
  162.     seg1.bytemax = BYTEMAX;
  163.     seg1.segs = 0;
  164.     seg1.bytes = 0;
  165.  
  166.    /* Turn on debugging */
  167.     if (gossipflag)
  168.     {
  169.         gossip_enable_stderr();
  170.         gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG);
  171.     }
  172.  
  173.     i = 0;
  174.  
  175.     printf("\n************************************\n");
  176.     printf("Four requests in SERVER mode 4 each contiguous servers 0-3 of 4\n");
  177.     printf("Simple stripe, default stripe size (64K)\n");
  178.     printf("Each from offset 0, file size 0, extend flag\n");
  179.     printf("Server 0\n");
  180.     printf("\n************************************\n");
  181.     do
  182.     {
  183.         seg1.bytes = 0;
  184.         seg1.segs = 0;
  185.  
  186.         /* process request */
  187.         /* note that bytemax is exactly large enough to hold all of the
  188.          * data that I should find here
  189.          */
  190.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_SERVER);
  191.  
  192.         if(!PINT_REQUEST_DONE(rs1))
  193.         {
  194.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  195.         }
  196.  
  197.         if(retval >= 0)
  198.         {
  199.             prtseg(&seg1,"Results obtained");
  200.             prtseg(&expected[i],"Results expected");
  201.             cmpseg(&seg1,&expected[i]);
  202.         }
  203.  
  204.         i++;
  205.  
  206.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0); 
  207.     
  208.     if(retval < 0)
  209.     {
  210.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  211.         return(-1);
  212.     }
  213.     if(PINT_REQUEST_DONE(rs1))
  214.     {
  215.         printf("**** first request done.\n");
  216.     }
  217.  
  218.     printf("\n************************************\n");
  219.     printf("Server 1\n");
  220.     printf("\n************************************\n");
  221.     do
  222.     {
  223.         seg1.bytes = 0;
  224.         seg1.segs = 0;
  225.  
  226.         /* process request */
  227.         /* note that bytemax is exactly large enough to hold all of the
  228.          * data that I should find here
  229.          */
  230.         retval = PINT_process_request(rs2, NULL, &rf2, &seg1, PINT_SERVER);
  231.  
  232.         if(!PINT_REQUEST_DONE(rs2))
  233.         {
  234.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  235.         }
  236.  
  237.         if(retval >= 0)
  238.         {
  239.             prtseg(&seg1,"Results obtained");
  240.             prtseg(&expected[i],"Results expected");
  241.             cmpseg(&seg1,&expected[i]);
  242.         }
  243.  
  244.         i++;
  245.  
  246.     } while(!PINT_REQUEST_DONE(rs2) && retval >= 0);
  247.     
  248.     if(retval < 0)
  249.     {
  250.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  251.         return(-1);
  252.     }
  253.     if(PINT_REQUEST_DONE(rs2))
  254.     {
  255.         printf("**** second request done.\n");
  256.     }
  257.  
  258.     printf("\n************************************\n");
  259.     printf("Server 2\n");
  260.     printf("\n************************************\n");
  261.     do
  262.     {
  263.         seg1.bytes = 0;
  264.         seg1.segs = 0;
  265.  
  266.         /* process request */
  267.         /* note that bytemax is exactly large enough to hold all of the
  268.          * data that I should find here
  269.          */
  270.         retval = PINT_process_request(rs3, NULL, &rf3, &seg1, PINT_SERVER);
  271.  
  272.         if(!PINT_REQUEST_DONE(rs3))
  273.         {
  274.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  275.         }
  276.  
  277.         if(retval >= 0)
  278.         {
  279.             prtseg(&seg1,"Results obtained");
  280.             prtseg(&expected[i],"Results expected");
  281.             cmpseg(&seg1,&expected[i]);
  282.         }
  283.  
  284.         i++;
  285.  
  286.     } while(!PINT_REQUEST_DONE(rs3) && retval >= 0);
  287.     
  288.     if(retval < 0)
  289.     {
  290.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  291.         return(-1);
  292.     }
  293.     if(PINT_REQUEST_DONE(rs3))
  294.     {
  295.         printf("**** third request done.\n");
  296.     }
  297.  
  298.  
  299.     printf("\n************************************\n");
  300.     printf("Server 3\n");
  301.     printf("\n************************************\n");
  302.     do
  303.     {
  304.         seg1.bytes = 0;
  305.         seg1.segs = 0;
  306.  
  307.         /* process request */
  308.         /* note that bytemax is exactly large enough to hold all of the
  309.          * data that I should find here
  310.          */
  311.         retval = PINT_process_request(rs4, NULL, &rf4, &seg1, PINT_SERVER);
  312.  
  313.         if(!PINT_REQUEST_DONE(rs4))
  314.         {
  315.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  316.         }
  317.  
  318.         if(retval >= 0)
  319.         {
  320.             prtseg(&seg1,"Results obtained");
  321.             prtseg(&expected[i],"Results expected");
  322.             cmpseg(&seg1,&expected[i]);
  323.         }
  324.  
  325.         i++;
  326.  
  327.     } while(!PINT_REQUEST_DONE(rs4) && retval >= 0);
  328.     
  329.     if(retval < 0)
  330.     {
  331.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  332.         return(-1);
  333.     }
  334.     if(PINT_REQUEST_DONE(rs4))
  335.     {
  336.         printf("**** fourth request done.\n");
  337.     }
  338.  
  339.  
  340.     return 0;
  341. }
  342.