80 #include "gapi_job_operations.h" 100 if (!strlen(gurl->
GetHost())) {
137 Info(
"TAlien",
"%s => %s port: %d user: %s",gridurl,fHost.Data(),fPort,fUser.Data());
142 if (options && (options[0] ==
't')) {
143 fGc = GapiUI::MakeGapiUI(
kTRUE);
146 fGc = GapiUI::MakeGapiUI(
kFALSE);
150 Error(
"TAlien",
"could not connect to a alien service at:");
151 Error(
"TAlien",
"host: %s port: %d user: %s", fHost.Data(), fPort, fUser.Data());
160 if (!Command(
"motd")) {
161 Error(
"TAlien",
"we have no valid connection ... I try to connect ...");
162 fGc->Connect(fHost, fPort, fUser, passwd);
165 fGc->Connect(fHost, fPort, fUser, passwd);
173 sprintf(cwd,
"%s",cwdp);
177 fHome = TString(cwdp);
182 if (!fGc->Connected()) {
183 Error(
"TAlien",
"could not authenticate at:");
184 Error(
"TAlien",
"host: %s port: %d user: %s",fHost.Data(),fPort,fUser.Data());
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();
377 return Command(
"locatesites");
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);
404 return Command(cmdline);
411 TString cmdline = TString(
"getdataset") + TString(
" ") + TString(options) + TString(
" ") + TString(lfn);
412 return Command(cmdline,
kTRUE);
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);
472 const char*
result = (GetStreamFieldValue(kOUTPUT,0,0));
474 if (strlen(result) > 0) {
475 if (atoi(result) == 1) {
481 Error(
"Cd",
"Cannot change to directory %s\n",ldn);
482 if (!verbose) Stdout();
490 TString cmdline = TString(
"pwd");
514 Error(
"pwd",
"Cannot get current working directory\n");
515 if (!verbose) Stdout();
523 TString cmdline = TString(
"mkdir");
524 if (strlen(options)) {
525 cmdline += (TString(
" ") + TString(options));
528 cmdline += (TString(
" -s ") + TString(ldn));
537 const char*
result = (GetStreamFieldValue(kOUTPUT,0,0));
539 if (strlen(result) > 0) {
540 if (atoi(result) > 0) {
546 Error(
"Mkdir",
"Cannot create directory %s\n",ldn);
547 if (!verbose) Stdout();
555 TString cmdline = TString(
"rmdir");
556 if (strlen(options)) {
557 cmdline += (TString(
" ") + TString(options));
559 cmdline += (TString(
" -s ") + TString(ldn));
569 const char*
result = (GetStreamFieldValue(kOUTPUT,0,0));
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);
605 const char*
result = (GetStreamFieldValue(kOUTPUT,0,0));
607 if (strlen(result) > 0) {
608 if (atoi(result) == 1) {
621 TString cmdline = TString(
"rm") + TString(
" -s ") + TString(options) + TString(
" ") + TString(lfn);
630 const char*
result = (GetStreamFieldValue(kOUTPUT,0,0));
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());
virtual Bool_t ResubmitById(TString jobid)
Resubmit a specific job.
virtual const char * GetKey(UInt_t, const char *) const
virtual Int_t Mkdir(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
Collectable string class.
This class represents a WWW compatible URL.
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)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual CatalogType Type(const char *lfn, Option_t *option="", Bool_t verbose=kFALSE)
returns the type of the given lfn
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Iterator abstract base class.
TString Escape(const char *input)
Escape " by \".
const char * GetStreamFieldKey(UInt_t stream, UInt_t column, UInt_t row)
static TAlienCollection * OpenAlienCollection(TGridResult *queryresult, Option_t *option="")
Static method used to create an Alien event collection, by creating collection from a TGridResult Get...
const char * GetHost() const
virtual TGridJobStatusList * Ps(const char *options, Bool_t verbose=kTRUE)
Get job status list.
virtual TGridCollection * OpenCollection(const char *collectionfile, UInt_t maxentries=kTRUE)
Factory function for a TAlienCollection based on an XML file.
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 const char * Pwd(Bool_t verbose=kFALSE)
void Shell()
Start an interactive AliEn shell.
virtual const char * Getenv(const char *env)
Get environment variable.
void Info(const char *location, const char *msgfmt,...)
virtual Bool_t Rmdir(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
virtual TGridCollection * OpenCollectionQuery(TGridResult *queryresult, Bool_t nogrouping=kFALSE)
Factory function fo a TAlienCollection based on a gGrid Query.
void Error(const char *location, const char *msgfmt,...)
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
const char * GetName() const
Returns name of object.
virtual TGridResult * ListPackages(const char *alienpackagedir="/alice/packages")
List packages in the specified directory.
virtual ~TAlien()
do we need to delete fGc ? (rdm)
R__EXTERN TSystem * gSystem
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...
virtual void DumpResult()
Dump result set.
char * Form(const char *fmt,...)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void Unsetenv(const char *name)
Unset environment variable.
TString GetString() const
virtual TGridJob * Submit(const char *jdl)
Submit a command to AliEn. Returns 0 in case of error.
virtual Bool_t Cd(const char *ldn="", Bool_t verbose=kFALSE)
virtual TGridResult * Ls(const char *ldn="", Option_t *options="", Bool_t verbose=kFALSE)
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 * OpenDataset(const char *lfn, const char *options="")
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
virtual TGridResult * LocateSites()
UInt_t GetNColumns(UInt_t stream)
Mother of all ROOT objects.
const char * GetStreamFieldValue(UInt_t stream, UInt_t column, UInt_t row)
virtual TGridResult * GetCollection(const char *lfn, Option_t *option="", Bool_t verbose=kFALSE)
virtual TGridResult * Query(const char *path, const char *pattern, const char *conditions="", const char *options="")
virtual void Add(TObject *obj)
virtual TObject * Next()=0
virtual const char * GetFileName(UInt_t) const
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
const char * GetUser() const
TGridResult * Command(const char *command, bool interactive=kFALSE, UInt_t stream=kOUTPUT)
Execute AliEn command. Returns 0 in case or error.
virtual TGridJDL * GetJDLGenerator()
Create a Alien JDL.
TMap * GetColumn(UInt_t stream=0, UInt_t column=0)