#include "TError.h"
#include "TList.h"
#include "TPluginManager.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TVirtualProof.h"
TVirtualProof *gProof = 0;
TProof_t TVirtualProof::fgProofHook = 0;
TList *TVirtualProof::fgProofEnvList = 0;
ClassImp(TVirtualProof)
TVirtualProof *TVirtualProof::Open(const char *cluster, const char *conffile,
const char *confdir, Int_t loglevel)
{
const char *pn = "TVirtualProof::Open";
if (!cluster) {
TPluginManager *pm = gROOT->GetPluginManager();
if (!pm) {
::Error(pn, "plugin manager not found");
return 0;
}
if (gROOT->IsBatch()) {
::Error(pn, "we are in batch mode, cannot show PROOF Session Viewer");
return 0;
}
TPluginHandler *sv = pm->FindHandler("TSessionViewer", "");
if (!sv) {
::Error(pn, "no plugin found for TSessionViewer");
return 0;
}
if (sv->LoadPlugin() == -1) {
::Error(pn, "plugin for TSessionViewer could not be loaded");
return 0;
}
sv->ExecPlugin(0);
return 0;
} else {
TVirtualProof *proof = 0;
TString fqdn = cluster;
if (fqdn == "")
fqdn = "localhost";
TUrl u(fqdn);
if (!strcmp(u.GetProtocol(), TUrl("a").GetProtocol()))
u.SetProtocol("proof");
if (u.GetPort() == TUrl("a").GetPort())
u.SetPort(1093);
TString o(u.GetOptions());
Int_t locid = -1;
Bool_t create = kFALSE;
if (o.Length() > 0) {
if (o.BeginsWith("N",TString::kIgnoreCase)) {
create = kTRUE;
} else if (o.IsDigit()) {
locid = o.Atoi();
}
u.SetOptions("");
}
TVirtualProofMgr *mgr = TVirtualProofMgr::Create(u.GetUrl());
if (mgr && mgr->IsValid()) {
Bool_t attach = (create || mgr->IsProofd()) ? kFALSE : kTRUE;
if (attach) {
TVirtualProofDesc *d = 0;
if (locid < 0)
d = (TVirtualProofDesc *) mgr->QuerySessions("")->First();
else
d = (TVirtualProofDesc *) mgr->GetProofDesc(locid);
if (d) {
proof = (TVirtualProof*) mgr->AttachSession(d->GetLocalId());
if (!proof || !proof->IsValid()) {
if (locid)
::Error(pn, "new session could not be attached");
SafeDelete(proof);
}
}
}
if (!proof) {
proof = (TVirtualProof*) mgr->CreateSession(conffile, confdir, loglevel);
if (!proof || !proof->IsValid()) {
::Error(pn, "new session could not be created");
SafeDelete(proof);
}
}
}
return proof;
}
}
Int_t TVirtualProof::Reset(const char *url, const char *usr)
{
if (!url)
return -1;
const char *pn = "TVirtualProof::Reset";
if (!strlen(url))
url = gSystem->GetHostByName(gSystem->HostName()).GetHostName();
TUrl u(url);
if (!strcmp(u.GetProtocol(), TUrl("a").GetProtocol()))
u.SetProtocol("proof");
if (u.GetPort() == TUrl("a").GetPort())
u.SetPort(1093);
TVirtualProofMgr *mgr = TVirtualProofMgr::Create(u.GetUrl());
if (mgr && mgr->IsValid())
if (!(mgr->IsProofd()))
return mgr->Reset(usr);
else
::Info(pn,"proofd: functionality not supported by server");
else
::Info(pn,"could not open a valid connection to %s", u.GetUrl());
return -1;
}
void TVirtualProof::SetTProofHook(TProof_t proofhook)
{
fgProofHook = proofhook;
}
const TList *TVirtualProof::GetEnvVars()
{
return fgProofEnvList;
}
TProof_t TVirtualProof::GetTProofHook()
{
return fgProofHook;
}
void TVirtualProof::AddEnvVar(const char *name, const char *value)
{
if (gDebug > 0) ::Info("TVirtualProof::AddEnvVar","%s=%s", name, value);
if (fgProofEnvList == 0) {
fgProofEnvList = new TList;
fgProofEnvList->SetOwner();
} else {
TObject *o = fgProofEnvList->FindObject(name);
if (o != 0) {
fgProofEnvList->Remove(o);
}
}
fgProofEnvList->Add(new TNamed(name, value));
}
void TVirtualProof::DelEnvVar(const char *name)
{
if (fgProofEnvList == 0) return;
TObject *o = fgProofEnvList->FindObject(name);
if (o != 0) {
fgProofEnvList->Remove(o);
}
}
void TVirtualProof::ResetEnvVars()
{
if (fgProofEnvList == 0) return;
SafeDelete(fgProofEnvList);
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.