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 / debug21.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  4KB  |  157 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 "pvfs2-internal.h"
  18.  
  19. #define SEGMAX 16
  20. #define BYTEMAX (4*1024*1024)
  21.  
  22. int main(int argc, char **argv)
  23. {
  24.     int i;
  25.     PINT_Request *r1a;
  26.     PINT_Request *r1;
  27.     PINT_Request *r2;
  28.     PINT_Request_state *rs1;
  29.     PINT_Request_state *rs2;
  30.     PINT_request_file_data rf1;
  31.     PINT_Request_result seg1;
  32.  
  33.     /* PVFS_Process_request arguments */
  34.     int retval;
  35.     int32_t blksz[] = {1};
  36.     PVFS_size disps1[] = {8};
  37.     PVFS_size disps2[] = {4};
  38.     PVFS_Request oldrs1[1] = {PVFS_INT};
  39.     PVFS_Request oldrs2[1];
  40.  
  41.     /* set up file type request */
  42.     PVFS_Request_struct(1, blksz, disps1, oldrs1, &r1a);
  43.     oldrs2[0] = r1a;
  44.     PVFS_Request_struct(1, blksz, disps2, oldrs2, &r1);
  45.     rs1 = PINT_new_request_state(r1);
  46.  
  47.     /* set up memory request */
  48.     PVFS_Request_contiguous(8, PVFS_BYTE, &r2);
  49.     rs2 = PINT_new_request_state(r2);
  50.  
  51.     /* set up file data for request */
  52.     PINT_dist_initialize(NULL);
  53.     rf1.server_nr = 0;
  54.     rf1.server_ct = 4;
  55.     rf1.fsize = 6000;
  56.     rf1.dist = PINT_dist_create("simple_stripe");
  57.     rf1.extend_flag = 0;
  58.     PINT_dist_lookup(rf1.dist);
  59.  
  60.     /* set up result struct */
  61.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  62.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  63.     seg1.bytemax = BYTEMAX;
  64.     seg1.segmax = SEGMAX;
  65.     seg1.bytes = 0;
  66.     seg1.segs = 0;
  67.     
  68.     /* skip into the file datatype */
  69.     /*PINT_REQUEST_STATE_SET_TARGET(rs1, 500);*/
  70.     PINT_REQUEST_STATE_SET_FINAL(rs1, 8);
  71.  
  72.    /* Turn on debugging */
  73.      gossip_enable_stderr();
  74.      gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG); 
  75.  
  76.     printf("\n************************************\n");
  77.     printf("One request in CLIENT mode server 0 of 4\n");
  78.     printf("Simple stripe, default stripe size (64K)\n");
  79.     printf("Offset 0, file size 6000, no extend flag\n");
  80.     printf("MemReq size 8 contiguous\n");
  81.     printf("\n************************************\n");
  82.     PINT_REQUEST_STATE_RESET(rs1);
  83.     PINT_REQUEST_STATE_RESET(rs2);
  84.     do
  85.     {
  86.         int r = 0;
  87.         seg1.bytes = 0;
  88.         seg1.segs = 0;
  89.  
  90.         /* process request */
  91.         retval = PINT_process_request(rs1, rs2, &rf1, &seg1, PINT_CLIENT);
  92.  
  93.         if(retval >= 0)
  94.         {
  95.             printf("results of PINT_process_request():\n");
  96.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  97.             for(i=0; i<seg1.segs; i++, r++)
  98.             {
  99.                 printf("  segment %d: offset: %d size: %d\n",
  100.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  101.             }
  102.         }
  103.  
  104.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  105.     
  106.     if(retval < 0)
  107.     {
  108.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  109.         return(-1);
  110.     }
  111.     if(PINT_REQUEST_DONE(rs1))
  112.     {
  113.         printf("**** request done.\n");
  114.     }
  115.     
  116.     printf("\n************************************\n");
  117.     printf("One request in SERVER mode server 0 of 4\n");
  118.     printf("Simple stripe, default stripe size (64K)\n");
  119.     printf("Offset 32, file size 6000, no extend flag\n");
  120.     printf("MemReq size 8 contiguous\n");
  121.     printf("\n************************************\n");
  122.     PINT_REQUEST_STATE_RESET(rs1);
  123.     do
  124.     {
  125.         int r = 0;
  126.         seg1.bytes = 0;
  127.         seg1.segs = 0;
  128.  
  129.         /* process request */
  130.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_SERVER);
  131.  
  132.         if(retval >= 0)
  133.         {
  134.             printf("results of PINT_process_request():\n");
  135.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  136.             for(i=0; i<seg1.segs; i++, r++)
  137.             {
  138.                 printf("  segment %d: offset: %d size: %d\n",
  139.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  140.             }
  141.         }
  142.  
  143.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  144.     
  145.     if(retval < 0)
  146.     {
  147.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  148.         return(-1);
  149.     }
  150.     if(PINT_REQUEST_DONE(rs1))
  151.     {
  152.         printf("**** request done.\n");
  153.     }
  154.  
  155.     return 0;
  156. }
  157.