| D0 at Work | Computing | D0 SAM | SAMGrid |
A straightforward interface to the SAM system is provided through the D0 Framework. The package which allows any Framework application to interact with SAM is called SAMManager. Its main purpose is to provide the application with the location of the next input file by communicating with the SAM Project Master. It also determines the location of the output files created by the application (if the output buffer space is managed by SAM), and generates meta-data for those files. If the output file is to be stored and catalogued with SAM in real time, SAMManager will initiate file store after file closing.
The easiest way to get familiar with SAMManager is to see an example of a working application. This can be accomplished by logging into the D0 Central Analysis Server
| d0mino> setup d0cvs | #where to get code |
| d0mino> setup D0RunII t04.20.00 | #where to find test executable |
| d0mino> cd scratchdir | #go to your scratch area |
| d0mino> cvs checkout sam_manager | #check out SAMManager |
| d0mino> cd sam_manager/test/demo | #go to the demo directory |
| d0mino> submit2sam_interactive | #run the demo program |
After running the above commands one might expect to see the output similar to the one given here. Note that in the same directory one can find several other demo scripts which use the sam submit command: submit2sam, submit2sam_script and submit2sam_parallel_script. All of those submit the SAM demo job to the batch system: the first one submits it as a Framework executable, while the other two submit it is as user provided scripts runsam_batch (for running a single user process), and runsam_parallel_batch (for running a multiple user processes in parallel).
The only SAM command used in submit2sam scripts (sam submit) is described in the document on running SAM projects. In the following we describe the framework-related SAM issues.
The test executable SAMTest uses SAMManager to retrieve an input file, it reads and dumps all events using ReadEvent and DumpEvent packages, and writes them into an output file using WriteEvent package. Upon its closing, SAMManager catalogues the newly created output file in the SAM database, and initializes its storing.
All of the packages used in SAMTest are listed in the top level RCP file SAMTest.rcp.
| // ---------------------------------------------------------------- |
| // SAMTest.rcp |
| // ---------------------------------------------------------------- |
| // Required by the framework. |
| string PackageName = "Controller" |
| string Packages = "mgr read dump write" |
| // ---------------------------------------------------------------- |
| // One of these for every item in the above Packages variable, |
| // and each must refer to an RCP file. |
| RCP mgr = <sam_manager SAMManager> |
| RCP read = <io_packages ReadEvent> |
| RCP write = <io_packages WriteEvent> |
| RCP dump = <io_packages DumpEvent> |
| // ---------------------------------------------------------------- |
Behavior of all individual packages is controlled by their respective RCP files: ReadEvent.rcp, WriteEvent.rcp, DumpEvent.rcp (all located in io_packages/rcp subdirectory of demo), and SAMManager.rcp (in sam_manager/rcp).
In order to use ReadEvent with SAMManager, its RCP parameter InputFile has to be set to SAMInput:, a pseudo-file which indicates that SAM will be used to dynamically generate list of input files.
| // ---------------------------------------------------------------- |
| // ReadEvent.rcp |
| // ---------------------------------------------------------------- |
| string PackageName = "ReadEvent" |
| string InputFile = "SAMInput:" |
| string InputFormat = "" |
| int SkipEvents = 0 | // Number of events to skip. |
| int NumEvents = 0 | // Maximum number of events to read (0 = all). |
| bool MakeUnknown = false | // Instantiate unknown objects? |
| bool ExceptUnknown = false | // Throw exception for unknown objects? |
| string ApplicationName = "ReadEvent" | // String passed to d0om_init. |
| string EventOrder = "sequential" | // Event order. |
// ----------------------------------------------------------------
Similarly, WriteEvent will work with SAMManager only if its RCP
parameter OutputFile begins with SAMOutput: or
SAMGenerated:. In the case of SAMOutput: SAMManager
will replace this string with the name of the directory to write output file
into (working directory at the moment), while the remaining file name
expanders, such as the standard D0 output file name generator, are responsible
for the rest. On the other hand, if SAMGenerated: is used SAMManager
will generate the name of the output file.
| // ---------------------------------------------------------------- |
| // WriteEvent.rcp |
| // ---------------------------------------------------------------- |
| string PackageName = "WriteEvent" |
| //string OutputFile = ("SAMOutput:file1","SAMOutput:file2") |
| string OutputFile = "SAMGenerated:" |
| int MaxEventsPerFile = 10 | // 0 = no limit. |
| bool Synchronize = false | // Synchronize file advance with ReadEvent. |
| int InputFilesPerFile = 1 | // Number of input files per output file. |
| string OutputFormat = "EVPACK" | // "DSPACK," "EVPACK," "D0MSQL," or "ORACLE." |
| int CompressionLevel = 1 | // 0=none, 9=most. Only works with EVPACK format. |
| bool CopyUnknown = true | // Copy unknown objects when writing? |
| string ApplicationName = "WriteEvent" | // String passed to d0om_init. |
| bool UseOutputFilter = false | |
| string WriteClassList = "" | // Space-separated list. |
| string VetoClassList = "" | // Space-separated list. |
| string WriteEventTags = "*" | // Space-separated list ("*" = all). |
| string VetoEventTags = "" | // Space-separated list. |
| string WriteChunkTags = "*" | // Space-separated list ("*" = all). |
| string VetoChunkTags = "" | // Space-separated list. |
| // ---------------------------------------------------------------- |
The RCP file for the DumpEvent package determines the frequency and the
total number of events to dump.
| // ---------------------------------------------------------------- |
| // DumpEvent.rcp |
| // ---------------------------------------------------------------- |
| string PackageName = "DumpEvent" | |
| int DumpPeriod = 1 | |
| int DumpNumber = 1000 | |
| bool DumpCollisionID = true | |
| bool DumpEvent = true | |
| string DumpChunks = "" | // Chunks to dump (empty string = all chunks) |
| string OutputFile = "" | // Output stream (out(...)) or filename. |
| // ---------------------------------------------------------------- |
The only parameter in the SAMManager RCP file which always has to be
present is PackageName. If sam submit command is used,
AnalysisProject and Station will be passed into the users'
executable as environment variables. The user also has to provide
ApplicationName, ApplicationVersion and (optionally)
WorkingGroup. Valid ApplicationName/ApplicationVersion pairs can
be found on the SAM Data
Browsing page. The remaining parameters are all optional:
ProcessDescription is the description of the user application,
FileParentageMode controls whether output file parentage is determined
by opened (default) or closed input files, while FileStoreLocation and
DataTier, will be used for storing output files. If
FileStoreLocation is not used, or if invalid location is provided (use
the SAM Data Browsing
page for the list of valid locations), the storing of output files will be
disabled, but metadata for the output file will be generated and printed to to
the standard output, as well as stored into a python file that can be submitted
to the SAM File Storage server using the sam store command.
SAMManager is using the asynchronous mode of storing output files. It will
submit a file store request to the File Storage Server, and will not wait for
callbacks. FileRequestTimeout is timeout (in minutes) for getting an
input file. The Verbose flag is used to control the amount of messages
sent to the standard output. If for any reason SAMManager has to be disabled,
an optional UseSAM flag can be set to 0.
| // ---------------------------------------------------------------- |
| // SAMManager.rcp |
| // ---------------------------------------------------------------- |
| string PackageName = "SAMManager" |
| //string AnalysisProject = "demo" |
| //string Station = "central-analysis" |
| //string ProcessDescription = "demo process" |
| //string WorkingGroup = "demo" |
| string ApplicationName = "demo" |
| string ApplicationVersion = "1" |
| string FileStoreLocation = "/pnfs/sam/lto/sam/demo" |
| //string DataTier = "reconstructed" // default: reconstructed-bygroup |
| int FileRequestTimeout = 15 // in minutes; default 0 (indefinitely) |
| // Output file parentage mode: 0 opened input files (default), |
| // 1 closed input files |
| int FileParentageMode = 0 |
| //int Verbose = 1 // 1 yes, 0 no (default) |
| //int UseSAM = 1 // 1 yes (default), 0 no |
| // ---------------------------------------------------------------- |
Some of the parameters controlling SAMManager can also be supplied on the command line, in which case they override parameters given in the RCP file. For example, if one runs the test executable using
SAMTest -project $SAM_PROJECT -station $SAM_STATION -rcp SAMTest.rcp
then the RCP parameters AnalysisProject and Station would be ignored. If some of the required parameters are not supplied in the SAMManager RCP file or as command line options, SAMManager will attempt to determine them from corresponding environent variables. All valid RCP parameters that have corresponding command line options and environment variables are listed below.
| RCP Parameter | CL Option | Environment Variable | |
| ------------------------------ | ------------------------------ | ------------------------------ | |
| AnalysisProject | -project | SAM_PROJECT | |
| Station | -station | SAM_STATION | |
| ProcessDescription | -desc | ||
| ApplicationName | -app_name | SAM_APPLICATION_NAME | |
| ApplicationVersion | -app_version | SAM_APPLICATION_VERSION | |
| WorkingGroup | -working_group |
Compilation of SAMManager package and the test executable should be
straightforward. On d0mino the necessary steps are the following:
| d0mino> setup d0cvs | #where to get code |
| d0mino> setup D0RunII t04.20.00 | #set environment |
| d0mino> cd scratchdir | #go to your scratch area |
| d0mino> newrel -t t04.20.00 testdir | #will create directory testdir |
| d0mino> cd testdir | #go to testdir |
| d0mino> addpkg -h sam_manager | #get SAMManager code |
| d0mino> gmake | #compile the library |
| d0mino> gmake sam_manager.test | #compile test executable |
Upon compilation, SAMManager library and test executable should be
located in lib/$BFARCH and bin/$BFARCH subdirectories of
testdir.
In order to use SAMManager users' applications should be linked with the SAMManager library (sam_manager), as well as with several other SAM (sam_corba and sam_util) and CORBA libraries (corba_util, OB, JTC and CosNaming). Also, the file RegSAMManager.o should be included in the list of object files. An example below is the GNUmakefile used for compilation of the SAMManager test executable:
//
----------------------------------------------------------------
// GNUmakefile for SAMTest
//
----------------------------------------------------------------
# override CXX = purify KCC
override LOADLIBES += \
-lsam_manager \
-lsam_client_cpplib \
-lsam_mis_cpplib
\
-lsam_corba \
-lsam_util \
-lsam_station \
-lsam_db_server \
-lsam_common \
-lsam_mis \
-lcorba_util \
-lcorba_common \
-lOB \
-lJTC \
-lCosNaming \
-lio_packages \
-lstream_ds \
-ld0om_ds \
-lstream
\
-levpack \
-ldspack \
-lframework \
-lfwkprofiling \
-lrcp \
-ledm \
-lidentifiers \
-ld0om \
-lNameTrans
\
-ld0_util \
-lZMtools \
-lExceptions \
-lErrorLogger \
-lErrLogEx \
-lZMutility \
-lZMTimer \
-lCLHEP \
-lrelversion \
-lconfig_base \
-lrun_config_fwk \
-lmemutil \
-ldl
include SoftRelTools/arch_spec_f77.mk
include
SoftRelTools/arch_spec_zlib.mk
override LDFLAGS += -L$(ORBACUS_LIBDIR) -L$(SAM_LIB_LIBDIR) \
-L$(CORBA_COMMON_LIBDIR) -L$(SAM_IDL_CPPLIB_LIBDIR) \
-L$(SAM_MIS_CPPLIB_LIBDIR) -L$(SAM_CLIENT_CPPLIB_LIBDIR)
COMPLEXBIN := SAMTest
COMPLEXBINCPPFILES :=
BINSTANDALONEOFILES := \
framework.o \
RegSAMManager.o \
ReadEvent.o \
WriteEvent.o \
DumpEvent.o
TBINS := $(COMPLEXBIN)
.PHONY: test tbin
test:
+@$(MAKE) -j 1 tbin
//
----------------------------------------------------------------
All SAMManager error messages that users may encounter within their
applications are meant to be sufficiently detailed to enable one to take the
appropriate action.
Project: SAM
Package: sam_manager
$Id:
framework_sam_projects.html,v 1.44 2004/01/27 22:40:28 veseli Exp $
This work is part of a development project, called SAM, which consists of a number of coordinated packages each named sam_xxxx .
Notice of authorship, copyright status, and terms and conditions, should the software eventually become available for use outside Fermilab, can be found in the README and LICENCE files in the top level directory of the main sam package.
| Wyatt Merritt | |
| Security, Privacy, Legal | |
| Last modified: June 14, 2004 05:09:37 PM CDT | |