TestXrdClient_read.cc

Go to the documentation of this file.
00001 //         $Id: TestXrdClient_read.cc 32231 2010-02-05 18:24:46Z ganis $
00002 
00003 // const char *TestXrdClient_readCVSID = "$Id: TestXrdClient_read.cc 32231 2010-02-05 18:24:46Z ganis $";
00004 #include "XrdClient/XrdClient.hh"
00005 #include "XrdClient/XrdClientEnv.hh"
00006 #include "XrdSys/XrdSysHeaders.hh"
00007 #include "XrdClient/XrdClientCallback.hh"
00008 #include <fstream>
00009 #include <vector>
00010 #include <string>
00011 #include <sys/time.h>
00012 #include <math.h>
00013 
00014 
00015 
00016 
00017 class MyXrdClientCallback: public XrdClientCallback {
00018 
00019    virtual void OpenComplete(XrdClientAbs *clientP, void *cbArg, bool res) {
00020       cout << "OpenComplete! res:" << res << endl;
00021    }
00022 
00023 };
00024 
00025 
00026 
00027 
00028 
00029 kXR_unt16 open_mode = (kXR_ur | kXR_uw);
00030 kXR_unt16 open_opts = (0);
00031  
00032 int ReadSome(kXR_int64 *offs, kXR_int32 *lens, int maxnread, long long &totalbytes) {
00033 
00034     for (int i = 0; i < maxnread;) {
00035 
00036         lens[i] = -1;
00037         offs[i] = -1;
00038         
00039         if (cin.eof()) return i;
00040 
00041         cin >> lens[i] >> offs[i];
00042 
00043         if ((lens[i] > 0) && (offs[i] >= 0)) {
00044           totalbytes += lens[i];
00045           i++;
00046         }
00047 
00048     }
00049 
00050     return maxnread;
00051 
00052 }
00053 
00054 // Waste cpu cycles for msdelay milliseconds
00055 void Think(long msdelay) {
00056 
00057     timeval tv;
00058     long long tlimit, t;
00059 
00060     if (msdelay <= 0) return;
00061 
00062     gettimeofday(&tv, 0);
00063     tlimit = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000 + msdelay;
00064     t = 0;
00065 
00066     while ( t < tlimit ) {
00067 
00068         double numb[1000];
00069         for (int i = 0; i < 100; i++)
00070             numb[i] = random();
00071 
00072         for (int i = 0; i < 100; i++)
00073             numb[i] = sqrt(numb[i]);
00074         
00075         for (int i = 0; i < 100; i++)
00076             memmove(numb+10, numb, 90*sizeof(double));
00077 
00078         gettimeofday(&tv, 0);
00079         t = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
00080     }
00081 
00082 
00083 }
00084 
00085 
00086 int main(int argc, char **argv) {
00087     void *buf;
00088     int vectored_style = 0;
00089     long read_delay = 0;
00090     timeval tv;
00091     double starttime = 0, openphasetime = 0, endtime = 0, closetime = 0;
00092     long long totalbytesread = 0, prevtotalbytesread = 0;
00093     long totalreadscount = 0;
00094     int filezcount = 0;
00095     string summarypref = "$$$";
00096     bool iserror = false;
00097     bool dobytecheck = false;
00098 
00099     gettimeofday(&tv, 0);
00100     starttime = tv.tv_sec + tv.tv_usec / 1000000.0;
00101     closetime = openphasetime = starttime;
00102 
00103 
00104     if (argc < 2) {
00105         cout << endl << endl <<
00106             "This program gets from the standard input a sequence of" << endl <<
00107             " <length> <offset>             (one for each line, with <length> less than 16M)" << endl <<
00108             " and performs the corresponding read requests towards the given xrootd URL or to ALL" << endl <<
00109             " the xrootd URLS contained in the given file." << endl <<
00110             endl <<
00111             "Usage: TestXrdClient_read <xrootd url or file name> <blksize> <cachesize> <vectored_style>  <inter_read_delay_ms> [--check] [-DSparmname stringvalue]... [-DIparmname intvalue]..." <<
00112             endl << endl <<
00113             " Where:" << endl <<
00114             "  <xrootd url>          is the xrootd URL of a remote file " << endl <<
00115             "  <rasize>              is the read ahead size. Can be 0." << endl <<
00116             "  <cachesize>           is the size of the internal cache, in bytes. Can be 0." << endl <<
00117             "  <vectored_style>      means 0: no vectored reads (default)," << endl <<
00118             "                              1: sync vectored reads," << endl <<
00119             "                              2: async vectored reads, do not access the buffer," << endl <<
00120             "                              3: async vectored reads, copy the buffers" << endl <<
00121             "                                (makes it sync through async calls!)" << endl <<
00122             "                              4: no vectored reads. Async reads followed by sync reads." << endl <<
00123             "                                (exploits the multistreaming for single reads)" << endl <<
00124             "                              5: don't read, but write data which is compatible with the --check option." << endl <<
00125             "  <inter_read_delay_ms> is the optional think time between reads." << endl <<
00126             "                        note: the think time will comsume cpu cycles, not sleep." << endl <<
00127             "  --check               verify if the value of the byte at offet i is i%256. Valid only for the single url mode." << endl <<
00128             " -DSparmname stringvalue" << endl <<
00129             "                        set the internal parm <parmname> with the string value <stringvalue>" << endl <<
00130             "                         See XrdClientConst.hh for a list of parameters." << endl <<
00131             " -DIparmname intvalue" << endl <<
00132             "                        set the internal parm <parmname> with the integer value <intvalue>" << endl <<
00133             "                         See XrdClientConst.hh for a list of parameters." << endl <<
00134             "                         Examples: -DSSocks4Server 123.345.567.8 -DISocks4Port 8080 -DIDebugLevel 1" << endl;
00135         exit(1);
00136     }
00137 
00138     if (argc > 2)
00139       EnvPutInt( NAME_READAHEADSIZE, atol(argv[2]));
00140 
00141     if (argc >= 3)
00142       EnvPutInt( NAME_READCACHESIZE, atol(argv[3]));
00143    
00144     if (argc > 4)
00145         vectored_style = atol(argv[4]);
00146 
00147     cout << "Read style: ";
00148     switch (vectored_style) {
00149     case 0:
00150        cout << "Synchronous reads, ev. with read ahead." << endl;
00151        break;
00152     case 1:
00153        cout << "Synchronous readv" << endl;
00154        break;
00155     case 2:
00156        cout << "Asynchronous readv, data is not processed." << endl;
00157        break;
00158     case 3:
00159        cout << "Asynchronous readv." << endl;
00160        break;
00161     case 4:
00162        cout << "Asynchronous reads." << endl;
00163        break;
00164     case 5:
00165        cout << "Write test file." << endl;
00166        open_opts |= kXR_open_updt;
00167        break;
00168     default:
00169        cout << "Unknown." << endl;
00170        break;
00171     }
00172 
00173 
00174     if (argc > 5)
00175         read_delay = atol(argv[5]);
00176 
00177     // The other args, they have to be an even number. Odd only if --check is there
00178     if (argc > 6)
00179       for (int i=6; i < argc; i++) {
00180 
00181         if (strstr(argv[i], "--check") == argv[i]) {
00182           cerr << "Enabling file content check." << endl;
00183           dobytecheck = true;
00184           continue;
00185         }
00186 
00187         if ( (strstr(argv[i], "-DS") == argv[i]) &&
00188              (argc >= i+2) ) {
00189           cerr << "Overriding " << argv[i]+3 << " with value " << argv[i+1] << ". ";
00190           EnvPutString( argv[i]+3, argv[i+1] );
00191           cerr << " Final value: " << EnvGetString(argv[i]+3) << endl;
00192           i++;
00193           continue;
00194         }
00195 
00196         if ( (strstr(argv[i], "-DI") == argv[i]) &&
00197              (argc >= i+2) ) {
00198           cerr << "Overriding '" << argv[i]+3 << "' with value " << argv[i+1] << ". ";
00199           EnvPutInt( argv[i]+3, atoi(argv[i+1]) );
00200           cerr << " Final value: " << EnvGetLong(argv[i]+3) << endl;
00201           i++;
00202           continue;
00203         }
00204 
00205       }
00206 
00207     buf = malloc(200*1024*1024);
00208 
00209     // Check if we have a file or a root:// url
00210     bool isrooturl = (strstr(argv[1], "root://"));
00211     int retval = 0;
00212     int ntoread = 0;
00213     int maxtoread = 20480;
00214     kXR_int64 v_offsets[20480];
00215     kXR_int32 v_lens[20480];
00216 
00217     if (isrooturl) {
00218         MyXrdClientCallback mycb;
00219         XrdClient *cli = new XrdClient(argv[1], &mycb, (void *)1234);
00220 
00221         cli->Open(open_mode, open_opts | ( (vectored_style > 4) ? kXR_delete : 0 ) );
00222         filezcount = 1;
00223 
00224         gettimeofday(&tv, 0);
00225         openphasetime = tv.tv_sec + tv.tv_usec / 1000000.0;
00226 
00227         while ( (ntoread = ReadSome(v_offsets, v_lens, maxtoread, totalbytesread)) ) {
00228           cout << ".";
00229 
00230           totalreadscount += ntoread;
00231 
00232             switch (vectored_style) {
00233             case 0: // no readv
00234                 for (int iii = 0; iii < ntoread; iii++) {
00235                     retval = cli->Read(buf, v_offsets[iii], v_lens[iii]);
00236 
00237                     if (retval <= 0) {
00238                         cout << endl << "---Read (" << iii << " of " << ntoread << " " <<
00239                             v_lens[iii] << "@" << v_offsets[iii] <<
00240                             " returned " << retval << endl;
00241                         
00242                         iserror = true;
00243                         break;
00244                     }
00245                     else {
00246 
00247                       if (dobytecheck)
00248                         for ( unsigned int jj = 0; jj < (unsigned)v_lens[iii]; jj++) {
00249                           
00250                           if ( ((jj+v_offsets[iii]) % 256) != ((unsigned char *)buf)[jj] ) {
00251                             cout << "errore nel file all'offset= " << jj+v_offsets[iii] <<
00252                               " letto: " << (int)((unsigned char *)buf)[jj] << " atteso: " << (jj+v_offsets[iii]) % 256 << endl;
00253                             iserror = true;
00254                             break;
00255                           }
00256                       }
00257                       if (!((iii+1) % 100)) Think(read_delay);
00258                     }
00259 
00260                 }               
00261                 break;
00262             case 1: // sync
00263                 retval = cli->ReadV((char *)buf, v_offsets, v_lens, ntoread);
00264                 cout << endl << "---ReadV returned " << retval << endl;
00265 
00266                 if (retval > 0)
00267                    for (int iii = 0; iii < ntoread; iii++){
00268                       if (!((iii+1) % 100)) Think(read_delay);
00269                       
00270                    }
00271 
00272                 else {
00273                   iserror = true;
00274                   break;
00275                 }
00276 
00277                 break;
00278                 
00279             case 2: // async
00280                 retval = cli->ReadV(0, v_offsets, v_lens, ntoread);
00281                 cout << endl << "---ReadV returned " << retval << endl;
00282                 break;
00283                 
00284             case 3: // async and immediate read, optimized!
00285                 cli->RemoveAllDataFromCache();
00286                 for (int ii = 0; ii < ntoread+512; ii+=512) {
00287 
00288                     if (ii < ntoread) {
00289                       // Read a chunk of data
00290                       retval = cli->ReadV(0, v_offsets+ii, v_lens+ii, xrdmin(ntoread - ii, 512) );
00291                       cout << endl << "---ReadV returned " << retval << endl;
00292 
00293                       if (retval <= 0) {
00294                         iserror = true;
00295                         break;
00296                       }
00297                     }
00298 
00299 
00300                     // Process the preceeding chunk while the last is coming
00301                     for (int iii = ii-512; (iii >= 0) && (iii < ii) && (iii < ntoread); iii++) {
00302                         retval = cli->Read(buf, v_offsets[iii], v_lens[iii]);
00303 
00304                         if (retval <= 0)
00305                             cout << endl << "---Read (" << iii << " of " << ntoread << " " <<
00306                                 v_lens[iii] << "@" << v_offsets[iii] <<
00307                                 " returned " << retval << endl;
00308 
00309                         if (dobytecheck)
00310                           for ( unsigned int jj = 0; jj < (unsigned)v_lens[iii]; jj++) {
00311                             if ( ((jj+v_offsets[iii]) % 256) != ((unsigned char *)buf)[jj] ) {
00312                               cout << "errore nel file all'offset= " << jj+v_offsets[iii] <<
00313                                 " letto: " << (int)((unsigned char *)buf)[jj] << " atteso: " << (jj+v_offsets[iii]) % 256 << endl;
00314                               iserror = true;
00315                               break;
00316                             }
00317                           }
00318                         
00319                         if (!((iii+1) % 100)) Think(read_delay);
00320                     }
00321                     
00322                 }
00323                             
00324                 retval = 1;
00325 
00326                 break;
00327                 
00328             
00329             case 4: // read async and then read
00330                 cli->RemoveAllDataFromCache();
00331                 for (int iii = -512; iii < ntoread; iii++) {
00332                     if (iii + 512 < ntoread)
00333                       retval = cli->Read_Async(v_offsets[iii+512], v_lens[iii+512]);
00334           
00335                     if (retval <= 0) {
00336                         cout << endl << "---Read_Async (" << iii+512 << " of " << ntoread << " " <<
00337                             v_lens[iii+512] << "@" << v_offsets[iii+512] <<
00338                             " returned " << retval << endl;
00339                         iserror = true;
00340                         break;
00341                     }
00342 
00343                     if (iii >= 0) {
00344                       retval = cli->Read(buf, v_offsets[iii], v_lens[iii]);
00345 
00346                       if (retval <= 0) {
00347                         cout << endl << "---Read (" << iii << " of " << ntoread << " " <<
00348                           v_lens[iii] << "@" << v_offsets[iii] <<
00349                           " returned " << retval << endl;
00350                         
00351                         iserror = true;
00352                         break;
00353                       }
00354 
00355                       if (!((iii+1) % 100)) Think(read_delay);
00356                     }
00357 
00358                 }
00359 
00360                 break;
00361 
00362             case 5: // don't read... write
00363               for (int iii = 0; iii < ntoread; iii++) {
00364 
00365                   for (int kkk = 0; kkk < v_lens[iii]; kkk++)
00366                     ((unsigned char *)buf)[kkk] = (v_offsets[iii]+kkk) % 256;
00367 
00368                   retval = cli->Write(buf, v_offsets[iii], v_lens[iii]);
00369 
00370                   if (retval <= 0) {
00371                     cout << endl << "---Write (" << iii << " of " << ntoread << ") " <<
00372                       v_lens[iii] << "@" << v_offsets[iii] <<
00373                       " returned " << retval << endl;            
00374                     iserror = true;
00375                     break;
00376                   }
00377 
00378                   if (retval > 0) {
00379                     if (!((iii+1) % 100)) Think(read_delay);
00380                   }
00381               }
00382                 
00383               break;
00384 
00385 
00386 
00387             } // switch
00388 
00389             if (!cli->IsOpen_wait()) {
00390               iserror = true;
00391               break;
00392             }
00393 
00394         } // while
00395 
00396         gettimeofday(&tv, 0);
00397         closetime = tv.tv_sec + tv.tv_usec / 1000000.0;
00398 
00399         cli->Close();
00400         delete cli;
00401         cli = 0;
00402 
00403 
00404     }
00405     else {
00406       // Same test on multiple filez
00407 
00408       vector<XrdClient *> xrdcvec;
00409       ifstream filez(argv[1]);
00410       int i = 0, fnamecount = 0;;
00411       XrdClientUrlInfo u;
00412 
00413       // Open all the files (in parallel man!)
00414       while (!filez.eof()) {
00415         string s;
00416         XrdClient * cli;
00417 
00418         filez >> s;
00419         if (s != "") {
00420           fnamecount++;
00421           cli = new XrdClient(s.c_str());
00422           u.TakeUrl(s.c_str());
00423 
00424           if (cli->Open( open_mode, open_opts | ((vectored_style > 4) ? kXR_delete : 0) )) {
00425             cout << "--- Open of " << s << " in progress." << endl;
00426             xrdcvec.push_back(cli);
00427           }
00428           else delete cli;
00429         }
00430             
00431         i++;
00432       }
00433 
00434       filez.close();
00435 
00436       filezcount = xrdcvec.size();
00437       cout << "--- All the open requests have been submitted" << endl;
00438 
00439       if (fnamecount == filezcount) {
00440      
00441         i = 0;
00442 
00443 
00444         gettimeofday(&tv, 0);
00445         openphasetime = tv.tv_sec + tv.tv_usec / 1000000.0;
00446 
00447         while ( (ntoread = ReadSome(v_offsets, v_lens, 10240, totalbytesread)) ) {
00448 
00449 
00450           switch (vectored_style) {
00451           case 0: // no readv
00452             for (int iii = 0; iii < ntoread; iii++) {
00453 
00454 
00455               for(int i = 0; i < (int) xrdcvec.size(); i++) {
00456 
00457                 retval = xrdcvec[i]->Read(buf, v_offsets[iii], v_lens[iii]);
00458 
00459 
00460                 if (retval <= 0) {
00461                   cout << endl << "---Read (" << iii << " of " << ntoread << ") " <<
00462                     v_lens[iii] << "@" << v_offsets[iii] <<
00463                     " returned " << retval << endl;              
00464                   iserror = true;
00465                   break;
00466                 }
00467 
00468 
00469                 if (retval > 0) {
00470 
00471                       if (dobytecheck)
00472                         for ( unsigned int jj = 0; jj < (unsigned)v_lens[iii]; jj++) {
00473                           
00474                           if ( ((jj+v_offsets[iii]) % 256) != ((unsigned char *)buf)[jj] ) {
00475                             cout << "errore nel file all'offset= " << jj+v_offsets[iii] <<
00476                               " letto: " << (int)((unsigned char *)buf)[jj] << " atteso: " << (jj+v_offsets[iii]) % 256 << endl;
00477                             iserror = true;
00478                             break;
00479                           }
00480                       }
00481 
00482                   Think(read_delay);
00483                 }
00484 
00485               }
00486 
00487             }
00488                 
00489             break;
00490           case 1: // sync
00491 
00492             for(int i = 0; i < (int) xrdcvec.size(); i++) {
00493 
00494               retval = xrdcvec[i]->ReadV((char *)buf, v_offsets, v_lens, ntoread);
00495 
00496             
00497               cout << endl << "---ReadV " << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00498                 " of " << ntoread << " chunks " <<
00499                 " returned " << retval << endl;
00500 
00501               if (retval) {
00502                 cout << "start think " << time(0) << endl;
00503                 for (int kkk = 0; kkk < ntoread; kkk++) Think(read_delay);
00504                 cout << time(0) << endl;
00505               }
00506               else {
00507                 iserror = true;
00508                 break;
00509               }
00510 
00511             }
00512 
00513             break;
00514                 
00515           case 2: // async
00516 
00517             for(int i = 0; i < (int) xrdcvec.size(); i++) {
00518 
00519               retval = xrdcvec[i]->ReadV((char *)0, v_offsets, v_lens, ntoread);
00520               cout << endl << "---ReadV " << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00521                 " returned " << retval << endl;
00522             }
00523 
00524             break;
00525                 
00526           case 3: // async readv and immediate read, optimized!
00527                 
00528             for (int ii = 0; ii < ntoread; ii+=4096) {
00529 
00530               // Read a chunk of data
00531               for(int i = 0; i < (int) xrdcvec.size(); i++) {
00532 
00533                 retval = xrdcvec[i]->ReadV((char *)0, v_offsets+ii, v_lens+ii, xrdmin(4096, ntoread-ii));
00534                 cout << endl << "---ReadV " << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00535                   " of " << xrdmin(4096, ntoread-ii) << " chunks " <<
00536                   " returned " << retval << endl;
00537 
00538                 if (retval <= 0) {
00539                   iserror = true;
00540                   break;
00541                 }
00542 
00543               }
00544 
00545               // Process the preceeding chunk while the last is coming
00546               for (int iii = ii-4096; (iii >= 0) && (iii < ii); iii++) {
00547 
00548                 for(int i = 0; i < (int) xrdcvec.size(); i++) {
00549 
00550                   retval = xrdcvec[i]->Read(buf, v_offsets[iii], v_lens[iii]);
00551 
00552                   if (retval <= 0)
00553                     cout << endl << "---Read " << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00554                       "(" << iii << " of " << ntoread << ") " <<
00555                       v_lens[iii] << "@" << v_offsets[iii] <<
00556                       " returned " << retval << endl;   
00557 
00558                   if (retval > 0) {
00559 
00560 
00561                       if (dobytecheck)
00562                         for ( unsigned int jj = 0; jj < (unsigned)v_lens[iii]; jj++) {
00563                           
00564                           if ( ((jj+v_offsets[iii]) % 256) != ((unsigned char *)buf)[jj] ) {
00565                             cout << "errore nel file all'offset= " << jj+v_offsets[iii] <<
00566                               " letto: " << (int)((unsigned char *)buf)[jj] << " atteso: " << (jj+v_offsets[iii]) % 256 << endl;
00567                             iserror = true;
00568                             break;
00569                           }
00570                       }
00571 
00572                     Think(read_delay);
00573                   }
00574 
00575                 }
00576 
00577               }
00578                     
00579             }
00580                             
00581             retval = 1;
00582 
00583             break;
00584 
00585           case 4: // read async and then read
00586 
00587             // Start being in advance of 512 reads per file
00588             for(int i = 0; i < (int) xrdcvec.size(); i++) {
00589 
00590               for (int jj = 0; jj < xrdmin(512, ntoread); jj++) {
00591                   retval =  xrdcvec[i]->Read_Async(v_offsets[jj], v_lens[jj]);
00592 
00593                   if (retval != kOK) {
00594                     cout << endl << "---Read_Async "  << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00595                       "(" << jj << " of " << ntoread << ") " <<
00596                       v_lens[jj] << "@" << v_offsets[jj] <<
00597                       " returned " << retval << endl;    
00598                     break;
00599                   }
00600 
00601                 }
00602 
00603             }
00604 
00605             // Then read everything
00606             for (int ii = 0; ii < ntoread; ii++) {
00607 
00608               // Read_async a chunk of data per file
00609               for(int i = 0; i < (int) xrdcvec.size(); i++) {
00610 
00611                 if (ii + 512 < ntoread)
00612                   retval =  xrdcvec[i]->Read_Async(v_offsets[ii+512], v_lens[ii+512]);
00613 
00614                   if (retval != kOK) {
00615                     cout << endl << "---Read_Async "  << xrdcvec[i]->GetCurrentUrl().GetUrl() <<
00616                       "(" << ii+512 << " of " << ntoread << ") " <<
00617                       v_lens[ii+512] << "@" << v_offsets[ii+512] <<
00618                       " returned " << retval << endl;       
00619                 }
00620 
00621               }
00622 
00623               // Now process one chunk per file
00624               for(int i = 0; i < (int) xrdcvec.size(); i++) {
00625 
00626                   retval = xrdcvec[i]->Read(buf, v_offsets[ii], v_lens[ii]);
00627 
00628 
00629                   if (retval > 0) {
00630 
00631                     if (dobytecheck)
00632                       for ( unsigned int jj = 0; jj < (unsigned)v_lens[ii]; jj++) {
00633                         
00634                         if ( ((jj+v_offsets[ii]) % 256) != ((unsigned char *)buf)[jj] ) {
00635                           cout << "errore nel file all'offset= " << jj+v_offsets[ii] <<
00636                             " letto: " << (int)((unsigned char *)buf)[jj] << " atteso: " << (jj+v_offsets[ii]) % 256 << endl;
00637                           iserror = true;
00638                           break;
00639                         }
00640                       }
00641 
00642                     Think(read_delay);
00643                   }
00644                   else {
00645                     cout << endl << "---Read (" << ii << " of " << ntoread << ") " <<
00646                       v_lens[ii] << "@" << v_offsets[ii] <<
00647                       " returned " << retval << endl;            
00648                     iserror = true;
00649                     break;
00650                   }
00651 
00652 
00653                   if (iserror) break;
00654 
00655                 } // for i
00656                     
00657               if (iserror) break;
00658             } // for ii
00659                             
00660             retval = 1;
00661 
00662 
00663             break;
00664 
00665           case 5: // don't read... write
00666             for (int iii = 0; iii < ntoread; iii++) {
00667 
00668 
00669               for(int i = 0; i < (int) xrdcvec.size(); i++) {
00670 
00671                 for (int kkk = 0; kkk < v_lens[iii]; kkk++)
00672                   ((unsigned char *)buf)[kkk] = (v_offsets[iii]+kkk) % 256;
00673 
00674                 retval = xrdcvec[i]->Write(buf, v_offsets[iii], v_lens[iii]);
00675 
00676                 if (retval <= 0) {
00677                   cout << endl << "---Write (" << iii << " of " << ntoread << ") " <<
00678                     v_lens[iii] << "@" << v_offsets[iii] <<
00679                     " returned " << retval << endl;              
00680                   iserror = true;
00681                   break;
00682                 }
00683 
00684                 if (retval > 0) {
00685                   Think(read_delay);
00686                 }
00687 
00688               }
00689 
00690             }
00691                 
00692             break;
00693 
00694 
00695 
00696                 
00697           } // switch
00698 
00699           if (iserror && prevtotalbytesread) {
00700             totalbytesread = prevtotalbytesread;
00701             break;
00702           }
00703 
00704           prevtotalbytesread = totalbytesread;
00705           totalreadscount += ntoread;
00706         } // while readsome
00707 
00708         gettimeofday(&tv, 0);
00709         closetime = tv.tv_sec + tv.tv_usec / 1000000.0;
00710 
00711         cout << endl << endl << "--- Closing all instances" << endl;
00712         for(int i = 0; i < (int) xrdcvec.size(); i++) {
00713           if (xrdcvec[i]->IsOpen()) xrdcvec[i]->Close();
00714           else cout << "WARNING: file '" <<
00715             xrdcvec[i]->GetCurrentUrl().GetUrl() << " was not opened." << endl;
00716         }
00717     
00718         cout << "--- Deleting all instances" << endl;
00719         for(int i = 0; i < (int) xrdcvec.size(); i++) delete xrdcvec[i];
00720      
00721         cout << "--- Clearing pointer vector" << endl; 
00722         xrdcvec.clear();
00723 
00724 
00725       } //if fnamecount == filezcount
00726 
00727 
00728 
00729     } // Case of multiple urls
00730   
00731 
00732     cout << "--- Freeing buffer" << endl;
00733     free(buf);
00734 
00735     gettimeofday(&tv, 0);
00736     endtime = tv.tv_sec + tv.tv_usec / 1000000.0;
00737 
00738     if (iserror) summarypref = "%%%";
00739 
00740 
00741     cout << "Summary ----------------------------" << endl;
00742     cout << summarypref << " starttime: " << starttime << endl;
00743     cout << summarypref << " lastopentime: " << openphasetime << endl;
00744     cout << summarypref << " closetime: " << closetime << endl;
00745     cout << summarypref << " endtime: " << endtime << endl;
00746     cout << summarypref << " open_elapsed: " << openphasetime - starttime << endl;
00747     cout << summarypref << " data_xfer_elapsed: " << closetime - openphasetime << endl;
00748     cout << summarypref << " close_elapsed: " << endtime - closetime << endl;
00749     cout << summarypref << " total_elapsed: " << endtime - starttime << endl;
00750     cout << summarypref << " totalbytesreadperfile: " << totalbytesread << endl;
00751     cout << summarypref << " maxbytesreadpersecperfile: " << totalbytesread / (closetime - openphasetime) << endl;
00752     cout << summarypref << " effbytesreadpersecperfile: " << totalbytesread / (endtime - starttime) << endl;
00753     cout << summarypref << " readscountperfile: " << totalreadscount << endl;
00754     cout << summarypref << " openedkofilescount: " << filezcount << endl;
00755     cout << endl;
00756 
00757 
00758     return 0;
00759 
00760 
00761 
00762 
00763 }

Generated on Tue Jul 5 14:46:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1