Commit bf34b2f6 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added the retrieval commands and changed the archival ones

parent 10fc760a
......@@ -20,7 +20,9 @@ void CTACmd::usage(std::ostream &os) const throw() {
os <<
"Usage:\n"
"\t" << m_programName << " archive <source_file1> [<source_file2> [<source_file3> [...]]] <destination_path>\n"
"\t" << m_programName << " getarchivejobs <tape_pool>\n"
"\t" << m_programName << " lsarchivejobs [<tape_pool>]\n"
"\t" << m_programName << " retrieve <source_file1> [<source_file2> [<source_file3> [...]]] <destination_path>\n"
"\t" << m_programName << " lsretrievejobs [<vid>]\n"
"\t" << m_programName << " chdirclass <directory_name> <storage_class_name>\n"
"\t" << m_programName << " cldirclass <directory_name>\n"
"\t" << m_programName << " getdirclass <directory_name>\n"
......
......@@ -110,7 +110,6 @@ int XrdProFilesystem::executeArchiveCommand(const ParsedRequest &req, XrdOucErrI
for(size_t i=0; i<req.args.size()-1; i++) {
sourceFiles.push_back(req.args.at(i));
}
std::string jobID = "NO LONGER EXISTS";
m_userApi.archive(requester, sourceFiles, destinationPath);
std::ostringstream responseSS;
responseSS << "[OK] Requested archival of the following files:\n";
......@@ -118,8 +117,7 @@ int XrdProFilesystem::executeArchiveCommand(const ParsedRequest &req, XrdOucErrI
responseSS << "[OK]\t" << *it << "\n";
}
responseSS << "[OK] To the following directory:\n";
responseSS << "[OK]\t" << destinationPath << "\n";
responseSS << "[OK] JobID: " << jobID;
responseSS << "[OK]\t" << destinationPath;
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
......@@ -140,26 +138,87 @@ int XrdProFilesystem::executeArchiveCommand(const ParsedRequest &req, XrdOucErrI
}
//------------------------------------------------------------------------------
// executeGetArchivalJobsCommand
// executeLsArchiveJobsCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeGetArchivalJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 1) {
int XrdProFilesystem::executeLsArchiveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 0 && req.args.size() != 1) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
std::list<cta::ArchivalJob> jobs = m_userApi.getArchivalJobs(requester, req.args.at(0));
if(req.args.size() == 1) {
std::list<cta::ArchivalJob> jobs = m_userApi.getArchivalJobs(requester, req.args.at(0));
std::ostringstream responseSS;
responseSS << "[OK] List of archive jobs for tape pool " << req.args.at(0) << ":\n";
for(std::list<cta::ArchivalJob>::const_iterator it = jobs.begin(); it != jobs.end(); it++) {
responseSS << "[OK]\t" << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getStateStr()
<< " " << it->getSrcUrl()
<< " " << it->getDstPath() << "\n";
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
}
else {
std::map<cta::TapePool, std::list<cta::ArchivalJob> > pools = m_userApi.getArchivalJobs(requester);
std::ostringstream responseSS;
for(std::map<cta::TapePool, std::list<cta::ArchivalJob> >::const_iterator pool=pools.begin(); pool!=pools.end(); pool++) {
responseSS << "[OK] List of archive jobs for tape pool " << (pool->first).getName() << ":\n";
for(std::list<cta::ArchivalJob>::const_iterator it = (pool->second).begin(); it != (pool->second).end(); it++) {
responseSS << "[OK]\t" << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getStateStr()
<< " " << it->getSrcUrl()
<< " " << it->getDstPath() << "\n";
}
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
}
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeRetrieveCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeRetrieveCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() < 2) {
std::string response = "[ERROR] Too few arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
std::list<std::string> sourceFiles;
std::string destinationPath = req.args.at(req.args.size()-1);
for(size_t i=0; i<req.args.size()-1; i++) {
sourceFiles.push_back(req.args.at(i));
}
m_userApi.retrieve(requester, sourceFiles, destinationPath);
std::ostringstream responseSS;
responseSS << "[OK] List of archive jobs for tape pool " << req.args.at(0) << ":\n";
for(std::list<cta::ArchivalJob>::iterator it = jobs.begin(); it != jobs.end(); it++) {
responseSS << "[OK]\t" << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getStateStr()
<< " " << it->getSrcUrl()
<< " " << it->getDstPath() << "\n";
responseSS << "[OK] Requested retrieval of the following files:\n";
for(std::list<std::string>::iterator it = sourceFiles.begin(); it != sourceFiles.end(); it++) {
responseSS << "[OK]\t" << *it << "\n";
}
responseSS << "[OK] To the following directory:\n";
responseSS << "[OK]\t" << destinationPath;
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
......@@ -179,6 +238,65 @@ int XrdProFilesystem::executeGetArchivalJobsCommand(const ParsedRequest &req, Xr
}
}
//------------------------------------------------------------------------------
// executeLsRetrieveJobsCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeLsRetrieveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 0 && req.args.size() != 1) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
if(req.args.size() != 1) {
std::list<cta::RetrievalJob> jobs = m_userApi.getRetrievalJobs(requester, req.args.at(0));
std::ostringstream responseSS;
responseSS << "[OK] List of retrieve jobs for vid " << req.args.at(0) << ":\n";
for(std::list<cta::RetrievalJob>::const_iterator it = jobs.begin(); it != jobs.end(); it++) {
responseSS << "[OK]\t" << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getStateStr()
<< " " << it->getSrcPath()
<< " " << it->getDstUrl() << "\n";
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
}
else {
std::map<cta::Tape, std::list<cta::RetrievalJob> > tapes = m_userApi.getRetrievalJobs(requester);
std::ostringstream responseSS;
for(std::map<cta::Tape, std::list<cta::RetrievalJob> >::const_iterator tape=tapes.begin(); tape!=tapes.end(); tape++) {
responseSS << "[OK] List of retrieve jobs for vid " << (tape->first).getVid() << ":\n";
for(std::list<cta::RetrievalJob>::const_iterator it = (tape->second).begin(); it != (tape->second).end(); it++) {
responseSS << "[OK]\t" << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getStateStr()
<< " " << it->getSrcPath()
<< " " << it->getDstUrl() << "\n";
}
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
}
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeMkclassCommand
//------------------------------------------------------------------------------
......@@ -1155,9 +1273,17 @@ int XrdProFilesystem::dispatchRequest(const XrdSfsFSctl &args, XrdOucErrInfo &eI
{
return executeArchiveCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/getarchivejobs") == 0)
else if(strcmp(req.cmd.c_str(), "/lsarchivejobs") == 0)
{
return executeLsArchiveJobsCommand(req, eInfo, requester);
}
if(strcmp(req.cmd.c_str(), "/retrieve") == 0)
{
return executeRetrieveCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/lsretrievejobs") == 0)
{
return executeGetArchivalJobsCommand(req, eInfo, requester);
return executeLsRetrieveJobsCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/mkclass") == 0)
{
......
......@@ -85,7 +85,27 @@ protected:
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeGetArchivalJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
int executeLsArchiveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeRetrieveCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeLsRetrieveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
......
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