| ||||||||||||
|
Grid File Access Library (GFAL)Grid storage interactions today require using several existing software components:
The GFAL library hides these interactions and presents a Posix interface for the I/O operations. The currently supported protocols are: file for local access, dcap (dCache access protocol) and rfio (DPM, CASTOR access protocol). Anyway, most of the Storage Element in the GILDA testbed are Disk Pool Manager (DPM) servers and so during the execise you are going to use rfio to remote access data. GFAL APIs are officially available as C APIs. To make things simpler, the GILDA team has developed a Java version of GFAL APIs. More detailed information on how to use this Java APIs can be found on the official Java GFAL API wiki page. The goal of the following exercise is to modify the RegularExplorer class that we used in the previous exercises to let it access remotely files on Storage Elements on the Grid. In particular, you will see how to read the Shapes Data files needed to generate the objects in the surface from a SE, and how to write the output file on a given SE and register it on the LFC File Catalog, using the Java GFAL APIs. Step 1: Download the explorer_gfal.zip and unpack it. Step 2: Edit the SimpleSurface.java class. The original version reads the data of the object to be generated along the surface from 6 different local files. Now you are going to change the code to read the same files from a SE (they were saved on opteron.gs.unina.it). Two of them (ConesData.txt and CuboidsData.txt) were already modified by us to achieve that purpose. So have a look to them to understand which class you need use and look in the code for "Modify Here" comments and try to do the same. You need to read remotely PyramidsData.txt, PipesData.txt, HemispheresData.txt, CylindersData.txt. GFalFile gFalFile1 = new GFalFile(); String outputS1 = ""; try { gFalFile1.openFile(DIR+"ConesData.txt", GFalFile.READONLY, 644, false); } catch (GFalFileException exc){ System.err.println("Error: problem in opening file:" + DIR + "ConesData.txt"); System.err.println(exc.getMessage()); System.exit(1); } try { GFalUtilities gFalUt = new GFalUtilities(); long stat[] = gFalUt.statFile(DIR+"ConesData.txt", false); byte[] output = gFalFile1.readFile((int)stat[4]); outputS1 = new String(output); } catch (GFalFileException exc) { System.err.println("Error1: problem while reading the remote file"); System.err.println(exc.getMessage()); System.exit(1); } catch (GFalUtilitiesException exc) { System.err.println("Error2: problem while determining the size"); System.err.println(exc.getMessage()); System.exit(1); } try { gFalFile1.closeFile(); } catch (GFalFileException exc) { System.err.println("Error: problem while closing the remote file"); System.err.println(exc.getMessage()); System.exit(1); } BufferedReader br = new BufferedReader(new StringReader(outputS1)); String line = br.readLine(); while (line != null && line.trim() != ""){ double[] x = extract(line,4,"Cones"); shapes[count] = new Cone(x[0],x[1],x[2],x[3]); count++; line = br.readLine(); } br.close(); Step 3: Edit the RegularExplorer.java class. Replace the code between the "modify here" comment with the appropriate GFAL code to register into the LFC File Catalog the file created and written on the SE given as argument (already done by us). Have a look to how to use the lfcRegisterFile method of the GFalFile class on javadoc of the GFAL Java API. Anyway, if you encounter any problem feel free to look at the solution here. Step 4: Compile RegularExplorer.java and SimpleSurface.java. You will need to set up your $CLASSPATH environment variable to find the gfal.jar and the regexp.jar packages. Morever, you need also to set up $LD_LIBRARY_PATH to find libgfal.so. Then you have to unpack the regexp.jar package (with jar xvf regexp.jar), copy the new class files generated in the package and, finally, re-pack all the *.class into a new regexp.jar (with jar cvf regexp.jar uk/ac/nesc/training/sfk/) Step 5: Test the just created jar from your workstation. The RegularExplorer main was slightly modified to take information on which Storage Element to save the output file and the LFN to use to register it into the File Catalog. You need a valid proxy to try it out. Moreover you must set the LCG_RFIO_TYPE and LCG_GFAL_VO environment variables in the following way: export LCG_RFIO_TYPE=dpm, LCG_GFAL_VO=gilda $ java uk.ac.nesc.training.sfk.RegularExplorer 0 0 10 10 2000 opteron.gs.unina.it lfn:/grid/gilda/scardaci/out1.dat Total written bytes: 98223 Warning: GFAL supports only rfio (dcap and file too) as I/O protocol. The SEs available on the GILDA testbed are mostly using DPM (that use rfio), but there are some old Classical SE (disk based that uses insecure rfio). Actually due a missing information published by the BDII, you have to way to determine the SE type. So do your test with the following SE that are DPM based: aliserv6.ct.infn.it, opteron.gs.unina.it, gildase.oact.inaf.it (ask to the GILDA tutor in the room for more SRM DPM available) Step 6: Check if the file was successfully registered onto LFC (you can use lfc-ls -l /grid/gilda/<your_home_dir>/out1.dat) and try to download it to your UI (use the lcg-cp command). $ lfc-ls -l /grid/gilda/scardaci | grep out.dat Step 7: Download the out.dat file from the SE with the lcg-cp command and use gnuplot to visualize the data in this file. Step 8: Now that our classes work fine on the UI, it's time to test them on the grid. So we need a regExplorer.jdl and a explorerGfal.sh script that will prepare the correct environment on the WN and launch the RegularExplorer java executable (we already prepared them for you, look in your package). Step 9: Submit the regExplorer.jdl job, cross your fingers, monitor its status until it will get DONE. Step 10: Verify that the job run properly, inspecting the File Catalog and retrieving back to your workstation its output. Again, use gnuplot to visualize the sampled surface.
|
|||||||||||
|