Commit e843f19b authored by Volodymyr Yurchenko's avatar Volodymyr Yurchenko Committed by Nikola Hardi
Browse files

Put certain messages in debug mode

parent 59c26d76
......@@ -130,6 +130,8 @@ private:
// lws_write helper
static int websocket_write_back(struct lws *wsi_in, const char *str, int str_size_in);
virtual TGridResult *OpenDataset(const char *lfn, const char *options = "");
public:
TJAlien(const char *gridUrl, const char *uId=0, const char *passwd=0,
const char *options=0);
......@@ -155,10 +157,10 @@ public:
virtual const char *GetHomeDirectory() { return fHome.Data(); }
virtual Int_t Mkdir(const char* ldn = "", Option_t* options = "", Bool_t verbose = kFALSE);
virtual Bool_t Rmdir(const char* ldn = "", Option_t* options = "", Bool_t verbose = kFALSE);
// 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 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 Bool_t Rm(const char *lfn, Option_t *option = "", Bool_t verbose = kFALSE);
virtual TJAlien::CatalogType Type(const char* lfn, Option_t* option = "", Bool_t verbose = kFALSE);
TGridResult* GetCollection(const char* lfn, Option_t* option, Bool_t verbose = kFALSE);
TGridResult* GetCollection(const char* lfn, Option_t* option = "", Bool_t verbose = kFALSE);
//--- Job Submission Interface
virtual TGridJob *Submit(const char * jdl);
......@@ -170,7 +172,13 @@ public:
virtual TGridCollection *OpenCollection(const char *, UInt_t maxentries = 1000000);
virtual TGridCollection *OpenCollectionQuery(TGridResult *queryresult, Bool_t nogrouping);
//--- Not implemented staff here
virtual void NotImplemented(const char *func, const char *file, int line);
TMap *GetColumn(UInt_t stream = 0, UInt_t column = 0);
const char *GetStreamFieldValue(UInt_t stream, UInt_t column, UInt_t row);
const char *GetStreamFieldKey(UInt_t stream, UInt_t column, UInt_t row);
UInt_t GetNColumns(UInt_t stream);
virtual TGridResult* ListPackages(const char* alienpackagedir="/alice/packages");
ClassDef(TJAlien, 0) // Interface to JAliEn GRID services
};
......
......@@ -36,7 +36,7 @@ TJAlien::TJAlien (const char* gridUrl, const char* uId, const char* passwd,
UNUSED(uId);
UNUSED(passwd);
UNUSED(options);
// Clear flags
destroy_flag = 0;
connection_flag = 0;
......@@ -135,7 +135,7 @@ void TJAlien::MakeWebsocketConnection(std::string certpath, std::string keypath)
// Use this for debugging
//lws_set_log_level(1023, NULL);//LLL_DEBUG | LLL_INFO | LLL_ERR | LLL_NOTICE, NULL);
lws_set_log_level(0, NULL);
lws_set_log_level(gDebug, NULL);
// Reset context variables
context = NULL;
......@@ -649,15 +649,13 @@ void TJAlien::Token(Option_t* options, bool force_restart)
ConnectJBox(usercertpath, userkeypath);
}
Info("Token", "RequestTokenCert");
TString sCmd("token");
TString sOptions(options);
if (sOptions.Length() > 0)
sCmd += TString(" ") + sOptions;
Info("Token", "Full command = \"%s\"", sCmd.Data());
if (gDebug > 1) Info("Token", "Full command = \"%s\"", sCmd.Data());
TJAlienResult *result = (TJAlienResult*) Command(sCmd.Data());
......@@ -667,8 +665,8 @@ void TJAlien::Token(Option_t* options, bool force_restart)
Int_t exitcode = GetExitCode(result, errorMessage);
if (exitcode != 0)
{
Error("Token", "%s", errorMessage->GetString().Data());
delete result;
Error("Token", "%s", errorMessage->GetString().Data());
delete result;
}
std::string tokencert = homedir + "/.globus/tokencert.pem";
......@@ -683,9 +681,9 @@ void TJAlien::Token(Option_t* options, bool force_restart)
(tokenkeyfile = fopen(tokenkeypath.c_str(), "r")) )
{
if (system(("chmod 755 " + tokencertpath).c_str()))
Error("Token", "RequestTokenCert: error while accessing token files");
Error("Token", "Error while accessing token files");
if (system(("chmod 755 " + tokenkeypath).c_str()))
Error("Token", "RequestTokenCert: error while accessing token files");
Error("Token", "Error while accessing token files");
fclose(tokencertfile);
fclose(tokenkeyfile);
......@@ -698,9 +696,9 @@ void TJAlien::Token(Option_t* options, bool force_restart)
fprintf(tokencertfile, "%s", result->GetKey(0, "tokencert"));
fprintf(tokenkeyfile, "%s", result->GetKey(0, "tokenkey"));
if (system(("chmod 440 " + tokencertpath).c_str()))
Error("Token", "RequestTokenCert: error while accessing token files");
Error("Token", "Error while accessing token files");
if (system(("chmod 400 " + tokenkeypath).c_str()))
Error("Token", "RequestTokenCert: error while accessing token files");
Error("Token", "Error while accessing token files");
fclose(tokencertfile);
fclose(tokenkeyfile);
......@@ -732,7 +730,7 @@ TGridResult *TJAlien::Ls(const char* lfn, Option_t* options, Bool_t verbose)
if (sOptions.Length() > 0)
cmdline += TString(" ") + sOptions;
if (verbose) Info("Ls", "Full command = \"%s\"", cmdline.Data());
if (gDebug > 1) Info("Ls", "Full command = \"%s\"", cmdline.Data());
TJAlienResult *result = (TJAlienResult*) Command(cmdline.Data());
if (verbose)
......@@ -747,17 +745,17 @@ TGridResult *TJAlien::Ls(const char* lfn, Option_t* options, Bool_t verbose)
Int_t exitcode = GetExitCode(result, errorMessage);
if (exitcode != 0)
{
if (verbose) Error("Ls", "%s", errorMessage->GetString().Data());
if (gDebug > 1) Error("Ls", "%s", errorMessage->GetString().Data());
delete result;
return NULL;
}
}
else
{
if (verbose) Error("Ls", "Ls: error while running command, no return result");
if (gDebug > 1) Error("Ls", "Ls: error while running command, no return result");
return NULL;
}
if (verbose) Info("Ls", "Ls command successful");
if (gDebug > 1) Info("Ls", "Ls command successful");
return result;
}
......@@ -787,28 +785,27 @@ Bool_t TJAlien::Cd(const char* lfn, Bool_t verbose)
Int_t exitcode = GetExitCode(result, errorMessage);
if (exitcode != 0)
{
if (verbose) Error("Cd", "%s", errorMessage->GetString().Data());
if (gDebug > 1) Error("Cd", "%s", errorMessage->GetString().Data());
delete result;
return false;
return kFALSE;
}
else
{
if (verbose) Info("Cd", "Cd command successful, changed to \"%s\"", sLfn.Data());
if (gDebug > 1) Info("Cd", "Cd command successful, changed to \"%s\"", sLfn.Data());
delete result;
return true;
return kTRUE;
}
}
else
{
Error("Cd", "Cd: error while running command, no return result");
return false;
return kFALSE;
}
}
//______________________________________________________________________________
const char *TJAlien::Pwd(Bool_t verbose)
{
// TO DO Check what verbose is suppose to do
Info("Pwd", "Pwd command received");
TString cmdline = TString("pwd");
......@@ -892,11 +889,11 @@ Int_t TJAlien::Mkdir(const char* ldn, Option_t* option, Bool_t verbose)
Int_t exitcode = GetExitCode(jalienresult, errorMessage);
if (exitcode != 0)
{
if (verbose) Error("Mkdir", "Mkdir command failed with error message \"%s\"", errorMessage->GetString().Data());
if (gDebug > 1) Error("Mkdir", "Mkdir command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return exitcode;
}
if (verbose) Info("Mkdir", "Mkdir command successful, created directory \"%s\"", ldn);
if (gDebug > 1) Info("Mkdir", "Mkdir command successful, created directory \"%s\"", ldn);
delete result;
return exitcode;
}
......@@ -940,29 +937,40 @@ Bool_t TJAlien::Rmdir(const char* ldn, Option_t* options, Bool_t verbose)
Int_t exitcode = GetExitCode(jalienresult, errorMessage);
if (exitcode != 0)
{
Error("Rmdir", "Rmdir command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
if (gDebug > 1) Error("Rmdir", "Rmdir command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
}
else
{
Info("Rmdir", "Rmdir command successful, removed directory \"%s\"", ldn);
delete result;
return kTRUE;
if (gDebug > 1) Info("Rmdir", "Rmdir command successful, removed directory \"%s\"", ldn);
delete result;
return kTRUE;
}
}
Error("Rmdir","Cannot remove directory %s",ldn);
if (gDebug > 1) Error("Rmdir","Cannot remove directory %s",ldn);
return kFALSE;
}
/*
* needed? not in JBox!! TODO
*/
//______________________________________________________________________________
/*
Bool_t TJAlien::Register(const char* lfn, const char* turl, Long_t size, const char* se, const char* guid, Bool_t verbose)
{
UNUSED(lfn);
UNUSED(turl);
UNUSED(size);
UNUSED(se);
UNUSED(guid);
UNUSED(verbose);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return kFALSE;
/*
if (lfn == NULL || std::string(lfn).find_first_not_of(' ') == std::string::npos)
{
Error("Register", "Command requires an argument");
return -1;
}
TString cmdline = TString("register ") + TString(lfn) + TString(" ") + TString(turl);
if (se) {
cmdline += (TString(" ") + size + TString(" ") + TString(se));
......@@ -979,24 +987,79 @@ Bool_t TJAlien::Register(const char* lfn, const char* turl, Long_t size, const c
}
if (result) {
TJAlienResult *jalienresult = (TJAlienResult *) result;
TObjString *errorMessage = 0;
Int_t exitcode = GetExitCode(jalienresult, errorMessage);
if (exitcode != 0) {
Error("Register", "Register command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
} else {
Info("Register", "Register command successful, registered file \"%s\"", lfn);
delete result;
return kTRUE;
TJAlienResult *jalienresult = (TJAlienResult *) result;
TObjString *errorMessage = 0;
Int_t exitcode = GetExitCode(jalienresult, errorMessage);
if (exitcode != 0) {
if (gDebug > 1) Error("Register", "Register command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
} else {
if (gDebug > 1) Info("Register", "Register command successful, registered file \"%s\"", lfn);
delete result;
return kTRUE;
}
}
if (gDebug > 1) Error("Register", "Unable to register file %s", lfn);
return kFALSE;*/
}
//______________________________________________________________________________
TGridResult* TJAlien::ListPackages(const char* alienpackagedir)
{
if (!alienpackagedir) {
alienpackagedir = "/alice/packages";
}
Error("Register", "Unable to register file %s", lfn);
return kFALSE;
TGridResult* gr = (TGridResult*) new TJAlienResult();
TGridResult* result = Ls(alienpackagedir);
if (result)
{
Int_t i = 0;
while (result->GetFileName(i))
{
TString pname=result->GetFileName(i);
TGridResult* version = Ls(Form("%s/%s",alienpackagedir,pname.Data()));
if (version)
{
Int_t j=0;
while (version->GetFileName(j))
{
TString pversion=version->GetFileName(j);
if (!pversion.Contains("post_"))
{
TGridResult* platform = Ls(Form("%s/%s/%s", alienpackagedir, pname.Data(), pversion.Data()));
if (platform)
{
Int_t k = 0;
TString allplatform = "";
while (platform->GetFileName(k))
{
TString pplatform = platform->GetFileName(k);
allplatform += pplatform;
allplatform += " ";
TMap* grmap = new TMap();
grmap->Add((TObject*) new TObjString("name"), (TObject*) new TObjString(pplatform.Data()));
grmap->Add((TObject*) new TObjString("path"), new TObjString( Form ( "%s/%s/%s/%s" , alienpackagedir, pname.Data(), pversion.Data(), pplatform.Data())));
gr->Add(grmap);
k++;
}
Info("ListPackages","Package: %-16s Version: %-20s Platform: [ %s ]", pname.Data(), pversion.Data(), allplatform.Data());
delete platform;
}
}
j++;
}
delete version;
}
i++;
}
delete result;
}
return gr;
}
*/
//______________________________________________________________________________
Bool_t TJAlien::Rm(const char* lfn, Option_t* options, Bool_t verbose)
......@@ -1029,19 +1092,19 @@ Bool_t TJAlien::Rm(const char* lfn, Option_t* options, Bool_t verbose)
Int_t exitcode = GetExitCode(jalienresult, errorMessage);
if (exitcode != 0)
{
Error("Rm", "Rm command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
if (gDebug > 1) Error("Rm", "Rm command failed with error message \"%s\"", errorMessage->GetString().Data());
delete result;
return kFALSE;
}
else
{
Info("Rm", "Rm command successful");
delete result;
return kTRUE;
if (gDebug > 1) Info("Rm", "Rm command successful");
delete result;
return kTRUE;
}
}
Error("Rm","Cannot remove %s",lfn);
if (gDebug > 1) Error("Rm", "Cannot remove %s", lfn);
return kFALSE;
}
......@@ -1049,6 +1112,11 @@ Bool_t TJAlien::Rm(const char* lfn, Option_t* options, Bool_t verbose)
TJAlien::CatalogType TJAlien::Type(const char* lfn, Option_t* option, Bool_t verbose)
{
// returns the type of the given lfn
if (lfn == NULL || std::string(lfn).find_first_not_of(' ') == std::string::npos)
{
Error("Type", "Command requires an argument");
return kFailed;
}
TString cmdline;
TString sOption(option);
......@@ -1125,7 +1193,7 @@ TGridJob *TJAlien::Submit(const char *jdl)
TString command = TString("submit ");
command += jdl;
Info("TJAlien", "command: %s", command.Data());
if (gDebug > 1) Info("TJAlien", "command: %s", command.Data());
TGridResult* result = Command(command, kFALSE, kOUTPUT);
TJAlienResult* jalienResult = dynamic_cast<TJAlienResult*> (result);
......@@ -1306,7 +1374,8 @@ TGridJobStatusList *TJAlien::Ps(const char* options, Bool_t verbose)
//______________________________________________________________________________
TGridResult* TJAlien::GetCollection(const char* lfn, Option_t* option, Bool_t verbose)
{
//
if (lfn == NULL || std::string(lfn).find_first_not_of(' ') == std::string::npos)
lfn = GetHomeDirectory();
TString cmdline;
TString sOption(option);
......@@ -1380,6 +1449,52 @@ TGridCollection *TJAlien::OpenCollectionQuery(TGridResult *queryresult, Bool_t n
return (TGridCollection*)TJAlienCollection::OpenQuery(queryresult, nogrouping);
}
//______________________________________________________________________________
TGridResult *TJAlien::OpenDataset(const char *lfn, const char *options)
{
UNUSED(lfn);
UNUSED(options);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return NULL;
}
//______________________________________________________________________________
TMap *TJAlien::GetColumn(UInt_t stream, UInt_t column)
{
UNUSED(stream);
UNUSED(column);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return NULL;
}
//______________________________________________________________________________
const char *TJAlien::GetStreamFieldValue(UInt_t stream, UInt_t column, UInt_t row)
{
UNUSED(stream);
UNUSED(column);
UNUSED(row);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return NULL;
}
//______________________________________________________________________________
const char *TJAlien::GetStreamFieldKey(UInt_t stream, UInt_t column, UInt_t row)
{
UNUSED(stream);
UNUSED(column);
UNUSED(row);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return NULL;
}
//______________________________________________________________________________
UInt_t TJAlien::GetNColumns(UInt_t stream)
{
UNUSED(stream);
(dynamic_cast<TJAlien*> (gGrid))->NotImplemented(__func__, __FILE__, __LINE__);
return -1;
}
//______________________________________________________________________________
TGridResult *TJAlien::Query(const char *path, const char *pattern,
const char *conditions, const char *options)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment