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