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 / debug29.c < prev    next >
C/C++ Source or Header  |  2005-09-27  |  5KB  |  226 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 (32*1024)
  23.  
  24. PVFS_offset exp1_offset[] =
  25. {
  26.         0, 32768, 65024, 97792, 130560
  27. };
  28. PVFS_offset exp1_size[] =
  29. {
  30.         32768, 32256, 32768, 32768, 512
  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 : 32768
  39. },{
  40.        offset_array : &exp1_offset[1],
  41.        size_array : &exp1_size[1],
  42.        segmax : SEGMAX,
  43.        segs : 1,
  44.        bytes : 32256
  45. },{
  46.        offset_array : &exp1_offset[2],
  47.        size_array : &exp1_size[2],
  48.        segmax : SEGMAX,
  49.        segs : 1,
  50.        bytes : 32768
  51. },{
  52.        offset_array : &exp1_offset[3],
  53.        size_array : &exp1_size[3],
  54.        segmax : SEGMAX,
  55.        segs : 1,
  56.        bytes : 32768
  57. },{
  58.        offset_array : &exp1_offset[4],
  59.        size_array : &exp1_size[4],
  60.        segmax : SEGMAX,
  61.        segs : 1,
  62.        bytes : 512
  63. }};
  64.  
  65.  
  66. int request_debug(void)
  67. {
  68.     int i;
  69.     PINT_Request *r, *m;
  70.     PINT_Request *r_enc, *m_enc;
  71.     PINT_Request_state *rs1, *ms1;
  72.     PINT_request_file_data rf1;
  73.     PINT_Request_result seg1;
  74.     int ret = -1;
  75.     int pack_size = 0;
  76.  
  77.     /* PVFS_Process_request arguments */
  78.     int retval;
  79.  
  80.    /* Turn on debugging */
  81.     if (gossipflag)
  82.     {
  83.         gossip_enable_stderr();
  84.         gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG);
  85.     }
  86.  
  87.     PVFS_Request_contiguous(1, PVFS_BYTE, &r);
  88.     pack_size = PINT_REQUEST_PACK_SIZE(r);
  89.     r_enc = (PINT_Request*)malloc(pack_size);
  90.     ret = PINT_request_commit(r_enc, r);
  91.     PVFS_Request_free(&r);
  92.  
  93.     /* set up request state */
  94.     rs1 = PINT_new_request_state(r_enc);
  95.  
  96.     PINT_REQUEST_STATE_SET_TARGET(rs1, 512);
  97.     PINT_REQUEST_STATE_SET_FINAL(rs1, 0);
  98.  
  99.     /* set up mem type */
  100.     PVFS_Request_contiguous(128*1024, PVFS_BYTE, &m);
  101.     pack_size = PINT_REQUEST_PACK_SIZE(m);
  102.     m_enc = (PINT_Request*)malloc(pack_size);
  103.     ret = PINT_request_commit(m_enc, m);
  104.     PVFS_Request_free(&m);
  105.  
  106.     /* set up mem type state */
  107.     ms1 = PINT_new_request_state(m_enc);
  108.  
  109.     /* set up file data for each server */
  110.     PINT_dist_initialize(NULL);
  111.     rf1.server_nr = 0;
  112.     rf1.server_ct = 4;
  113.     rf1.fsize = 0;
  114.     rf1.dist = PINT_dist_create("simple_stripe");
  115.     rf1.extend_flag = 1;
  116.     PINT_dist_lookup(rf1.dist);
  117.  
  118.     /* set up response for each server */
  119.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  120.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  121.     seg1.segmax = SEGMAX;
  122.     seg1.bytemax = BYTEMAX;
  123.     seg1.segs = 0;
  124.     seg1.bytes = 0;
  125.  
  126.     i = 0;
  127.  
  128.     printf("\n************************************\n");
  129.     printf("one request in CLIENT mode \n");
  130.     printf("Simple stripe, default stripe size (64K)\n");
  131.     printf("Contig request\n");
  132.     printf("Contig Memtype\n");
  133.     printf("Each from offset 0, file size 0, extend flag\n");
  134.     printf("Server 0\n");
  135.     printf("\n************************************\n");
  136.     do
  137.     {
  138.         seg1.bytes = 0;
  139.         seg1.segs = 0;
  140.  
  141.         /* process request */
  142.         /* note that bytemax is exactly large enough to hold all of the
  143.          * data that I should find here
  144.          */
  145.         retval = PINT_process_request(rs1, ms1, &rf1, &seg1, PINT_CLIENT);
  146.  
  147.         if(retval >= 0)
  148.         {
  149.             prtseg(&seg1,"Results obtained");
  150.             prtseg(&expected[i],"Results expected");
  151.             cmpseg(&seg1,&expected[i]);
  152.         }
  153.  
  154.         i++;
  155.  
  156.     } while(!PINT_REQUEST_DONE(rs1)); 
  157.  
  158.     printf("\n************************************\n");
  159.     printf("Server 1\n");
  160.     printf("************************************\n");
  161.     PINT_REQUEST_STATE_RESET(rs1);
  162.     PINT_REQUEST_STATE_RESET(ms1);
  163.     rf1.server_nr = 1;
  164.     do
  165.     {
  166.         seg1.bytes = 0;
  167.         seg1.segs = 0;
  168.  
  169.         /* process request */
  170.         /* note that bytemax is exactly large enough to hold all of the
  171.          * data that I should find here
  172.          */
  173.         retval = PINT_process_request(rs1, ms1, &rf1, &seg1, PINT_CLIENT);
  174.  
  175.         if(retval >= 0)
  176.         {
  177.             prtseg(&seg1,"Results obtained");
  178.             prtseg(&expected[i],"Results expected");
  179.             cmpseg(&seg1,&expected[i]);
  180.         }
  181.  
  182.         i++;
  183.  
  184.     } while(!PINT_REQUEST_DONE(rs1)); 
  185.  
  186.     printf("\n************************************\n");
  187.     printf("Server 2\n");
  188.     printf("************************************\n");
  189.     PINT_REQUEST_STATE_RESET(rs1);
  190.     PINT_REQUEST_STATE_RESET(ms1);
  191.     rf1.server_nr = 2;
  192.     do
  193.     {
  194.         seg1.bytes = 0;
  195.         seg1.segs = 0;
  196.  
  197.         /* process request */
  198.         /* note that bytemax is exactly large enough to hold all of the
  199.          * data that I should find here
  200.          */
  201.         retval = PINT_process_request(rs1, ms1, &rf1, &seg1, PINT_CLIENT);
  202.  
  203.         if(retval >= 0)
  204.         {
  205.             prtseg(&seg1,"Results obtained");
  206.             prtseg(&expected[i],"Results expected");
  207.             cmpseg(&seg1,&expected[i]);
  208.         }
  209.  
  210.         i++;
  211.  
  212.     } while(!PINT_REQUEST_DONE(rs1)); 
  213.     
  214.     if(retval < 0)
  215.     {
  216.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  217.         return(-1);
  218.     }
  219.     if(PINT_REQUEST_DONE(rs1))
  220.     {
  221.         printf("**** first request done.\n");
  222.     }
  223.  
  224.     return 0;
  225. }
  226.