80#include "gapi_job_operations.h"
100 if (!strlen(gurl->
GetHost())) {
142 if (options && (options[0] ==
't')) {
150 Error(
"TAlien",
"could not connect to a alien service at:");
161 Error(
"TAlien",
"we have no valid connection ... I try to connect ...");
173 sprintf(cwd,
"%s",cwdp);
177 fHome = TString(cwdp);
182 if (!
fGc->Connected()) {
183 Error(
"TAlien",
"could not authenticate at:");
203 Info(
"~TAlien",
"destructor called");
223 output.ReplaceAll(
"\"",
"\\\"");
236 TString command(
"submit =< ");
240 cout << command << endl;
244 TList* list =
dynamic_cast<TList*
>(alienResult);
257 while ((
object = iter->
Next()) != 0) {
258 TMap* map =
dynamic_cast<TMap*
>(object);
270 Error(
"Submit",
"error submitting job");
274 Info(
"Submit",
"your job was submitted with the ID = %s", jobID.Data());
292 GAPI_JOBARRAY* gjobarray = gapi_queryjobs(
"-",
gGrid->
GetUser(),
"-",
"-",
"-",
297 if (gjobarray->size() == 0) {
304 for (
UInt_t i = 0; i < gjobarray->size(); i++ ) {
306 GAPI_JOB gjob = gjobarray->at(i);
307 std::map<std::string, std::string>::const_iterator iter = gjob.gapi_jobmap.begin();
308 for (; iter != gjob.gapi_jobmap.end(); ++iter) {
326 if (gapi_kill(atoi(jobid.Data())))
337 if (gapi_resubmit(atoi(jobid.Data())))
349 if (
fGc->Command(command)) {
353 for (
Int_t column = 0 ; column < (
fGc->GetStreamColumns(stream)); column++) {
356 for (
Int_t row=0; row <
fGc->GetStreamRows(stream,column); row++) {
365 fGc->DebugDumpStreams();
385 fGc->PrintCommandStdout();
394 fGc->PrintCommandStderr();
401 const char *conditions,
const char *options)
403 TString cmdline = TString(
"find -z ") + TString(options) + TString(
" ") + TString(path) + TString(
" ") + TString(pattern) + TString(
" ") + TString(conditions);
411 TString cmdline = TString(
"getdataset") + TString(
" ") + TString(options) + TString(
" ") + TString(lfn);
420 for (
Int_t row = 0; row <
fGc->GetStreamRows(stream,column); row++) {
431 return fGc->GetStreamFieldValue(stream,column,row);
438 return fGc->GetStreamFieldKey(stream,column,row);
445 return fGc->GetStreamColumns(stream);
454 TString cmdline = TString(
"ls") + TString(
" ") + TString(options) + TString(
" ") + TString(ldn);
456 return Command(cmdline, verbose);
463 TString cmdline = TString(
"cd") + TString(
" ") + TString(ldn);
474 if (strlen(result) > 0) {
475 if (atoi(result) == 1) {
481 Error(
"Cd",
"Cannot change to directory %s\n",ldn);
490 TString cmdline = TString(
"pwd");
514 Error(
"pwd",
"Cannot get current working directory\n");
523 TString cmdline = TString(
"mkdir");
524 if (strlen(options)) {
525 cmdline += (TString(
" ") + TString(options));
528 cmdline += (TString(
" -s ") + TString(ldn));
539 if (strlen(result) > 0) {
540 if (atoi(result) > 0) {
546 Error(
"Mkdir",
"Cannot create directory %s\n",ldn);
555 TString cmdline = TString(
"rmdir");
556 if (strlen(options)) {
557 cmdline += (TString(
" ") + TString(options));
559 cmdline += (TString(
" -s ") + TString(ldn));
571 if (strlen(result) > 0) {
572 if (atoi(result) == 1) {
578 Error(
"Rmdir",
"Cannot remove directory %s\n",ldn);
586 TString cmdline = TString(
"register") + TString(
" ") + TString(lfn) + TString(
" ") + TString(turl);
588 cmdline += TString(
" ");
590 cmdline += TString(
" ");
591 cmdline += TString(se);
593 cmdline += TString(
" ");
594 cmdline += TString(guid);
607 if (strlen(result) > 0) {
608 if (atoi(result) == 1) {
621 TString cmdline = TString(
"rm") + TString(
" -s ") + TString(options) + TString(
" ") + TString(lfn);
632 if (strlen(result) > 0) {
633 if (atoi(result) == 1) {
639 Error(
"Rm",
"Cannot remove %s\n",lfn);
649 TString path(collectionfile);
653 Error(
"OpenCollection",
654 "Trying to read a collection, but gGrid not initialized with AliEn");
657 TString lfn = path(strlen(
"alien://"), path.Length());
662 Error(
"OpenCollection",
663 "Could not retrieve collection %s from the catalog", collectionfile);
688 TString cmdline = TString(
"type -z") + TString(
" ") + TString(option) + TString(
" ") + TString(lfn);
698 Error(
"Type",
"Did not receive TGridResult from query %s", cmdline.Data());
702 const char* typeStr = gridResult->
GetKey(0,
"type");
703 if (!typeStr || !typeStr[0]) {
704 Error(
"Type",
"Could not get type of %s", lfn);
711 if (strcmp(typeStr,
"file") == 0) {
713 }
else if (strcmp(typeStr,
"directory") == 0) {
715 }
else if (strcmp(typeStr,
"collection") == 0) {
718 Error(
"Type",
"Unknown type %s", typeStr);
730 TString cmdline = TString(
"listFilesFromCollection -z -v") + TString(
" ") + TString(option) + TString(
" ") + TString(lfn);
747 if (!alienpackagedir) {
748 alienpackagedir =
"/alice/packages";
763 if ((pversion.Contains(
"post_"))) {
765 TGridResult* platform =
Ls(
Form(
"%s/%s/%s",alienpackagedir,pname.Data(),pversion.Data()));
768 TString allplatform=
"";
771 allplatform+=pplatform;
777 new TObjString(
Form (
"%s/%s/%s/%s" , alienpackagedir,pname.Data(),pversion.Data(),pplatform.Data())));
781 Info(
"ListPackages",
"Package: %-16s Version: %-20s Platform: [ %s ]",pname.Data(),pversion.Data(),allplatform.Data());
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
static TAlienCollection * OpenAlienCollection(TGridResult *queryresult, Option_t *option="")
Static method used to create an Alien event collection, by creating collection from a TGridResult Get...
static TGridCollection * OpenQuery(TGridResult *queryresult, Bool_t nogrouping=kFALSE)
Static method used to create an Alien event collection, by creating collection from a TGridResult Que...
static TGridCollection * Open(const char *collectionurl, UInt_t maxentries=1000000)
Static method used to create an Alien event collection, by reading an XML collection from the specifi...
virtual void DumpResult()
Dump result set.
TAlien(const char *gridurl, const char *uid=0, const char *passwd=0, const char *options=0)
virtual TGridJob * Submit(const char *jdl)
Submit a command to AliEn. Returns 0 in case of error.
void Shell()
Start an interactive AliEn shell.
virtual Bool_t ResubmitById(TString jobid)
Resubmit a specific job.
virtual TGridResult * LocateSites()
UInt_t GetNColumns(UInt_t stream)
virtual TGridResult * OpenDataset(const char *lfn, const char *options="")
virtual TGridJobStatusList * Ps(const char *options, Bool_t verbose=kTRUE)
Get job status list.
TGridResult * Command(const char *command, bool interactive=kFALSE, UInt_t stream=kOUTPUT)
Execute AliEn command. Returns 0 in case or error.
virtual TGridResult * ListPackages(const char *alienpackagedir="/alice/packages")
List packages in the specified directory.
const char * GetStreamFieldKey(UInt_t stream, UInt_t column, UInt_t row)
virtual Bool_t Rm(const char *lfn, Option_t *option="", Bool_t verbose=kFALSE)
virtual Bool_t KillById(TString jobid)
Kill a specific job.
virtual TGridResult * Ls(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
virtual CatalogType Type(const char *lfn, Option_t *option="", Bool_t verbose=kFALSE)
returns the type of the given lfn
virtual TGridResult * GetCollection(const char *lfn, Option_t *option="", Bool_t verbose=kFALSE)
virtual Bool_t Rmdir(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
TString Escape(const char *input)
Escape " by \".
virtual TGridCollection * OpenCollectionQuery(TGridResult *queryresult, Bool_t nogrouping=kFALSE)
Factory function fo a TAlienCollection based on a gGrid Query.
virtual Bool_t Cd(const char *ldn="", Bool_t verbose=kFALSE)
virtual TGridJDL * GetJDLGenerator()
Create a Alien JDL.
TMap * GetColumn(UInt_t stream=0, UInt_t column=0)
virtual Bool_t Register(const char *lfn, const char *turl, Long_t size=-1, const char *se=0, const char *guid=0, Bool_t verbose=kFALSE)
const char * GetStreamFieldValue(UInt_t stream, UInt_t column, UInt_t row)
virtual Int_t Mkdir(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
virtual TGridCollection * OpenCollection(const char *collectionfile, UInt_t maxentries=kTRUE)
Factory function for a TAlienCollection based on an XML file.
virtual TGridResult * Query(const char *path, const char *pattern, const char *conditions="", const char *options="")
virtual ~TAlien()
do we need to delete fGc ? (rdm)
virtual const char * Pwd(Bool_t verbose=kFALSE)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual const char * GetKey(UInt_t, const char *) const
virtual const char * GetFileName(UInt_t) const
const char * GetUser() const
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Collectable string class.
const char * GetName() const
Returns name of object.
const TString & GetString() const
Mother of all ROOT objects.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual void Unsetenv(const char *name)
Unset environment variable.
This class represents a WWW compatible URL.
const char * GetHost() const