alien.C

Go to the documentation of this file.
00001 //Example of use of the TAlien class (an implementation of TGrid)
00002 //Author: Andreas Peters
00003    
00004 void alien()
00005 {
00006    TString testdir = "root-test3";
00007    int nfiles      = 10;
00008 
00009    // connect to AliEn
00010    TGrid *alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "",
00011                                  "-domain=cern.ch");
00012    if (alien->IsZombie()) {
00013       delete alien;
00014       return;
00015    }
00016 
00017    // get info on AliEn version
00018    printf("Using AliEn version %s\n", alien->GetInfo());
00019 
00020    // print current working directory
00021    printf("Current directory is %s\n", alien->Pwd());
00022 
00023    // check if directory exists
00024    Long_t size, flags, modtime;
00025    if (alien->GetPathInfo(testdir, &size, &flags, &modtime) == 0) {
00026       // delete existing directory
00027       alien->Rmdir(testdir);
00028    }
00029 
00030    // create a directory
00031    alien->Mkdir(testdir);
00032 
00033    // change directory
00034    alien->Cd(testdir);
00035 
00036    printf("Current directory is %s\n", alien->Pwd());
00037 
00038    // insert nfiles into the catalog
00039    Int_t i;
00040    char lfn[32], pfn[256];
00041    for (i = 0; i < nfiles; i++) {
00042       sprintf(lfn, "test-%d.root", i);
00043       sprintf(pfn, "rfio:/castor/cern.ch/user/r/rdm/mytest-%d.root", i);
00044       alien->AddFile(lfn, pfn, 1000000000);
00045    }
00046 
00047    // list the contents of a directory
00048    alien->ls("", "l");
00049 
00050    // get physical file name from lfn
00051    for (i = 0; i < nfiles; i++) {
00052       sprintf(lfn, "test-%d.root", i);
00053       char *pf = alien->GetPhysicalFileName(lfn);
00054       if (i == nfiles-1)
00055          printf("last pfn retrieved is: %s\n", pf);
00056       delete [] pf;
00057    }
00058 
00059    delete alien;
00060 }
00061 

Generated on Tue Jul 5 15:44:51 2011 for ROOT_528-00b_version by  doxygen 1.5.1