Difference between revisions of "ARC developer guide"
(Created page with "Category:Grid == Libraries and include files == '''Include files''' "/usr/include/glibmm-2.4" "/usr/lib/sigc++-2.0/include" "/usr/lib/glib-2.0/include" "/usr/include/gli...") |
|||
Line 1: | Line 1: | ||
[[Category:Grid]] | [[Category:Grid]] | ||
+ | [[Getting started with SweGrid|< Getting started with SweGrid]] | ||
== Libraries and include files == | == Libraries and include files == | ||
Revision as of 09:37, 5 July 2011
< Getting started with SweGrid
Libraries and include files
Include files
"/usr/include/glibmm-2.4" "/usr/lib/sigc++-2.0/include" "/usr/lib/glib-2.0/include" "/usr/include/glib-2.0" "/usr/lib/glibmm-2.4/include" "/usr/include/glib-2.0" "/usr/include/sigc++-2.0" "/usr/include/libxml2"
Libraries
arcclient arccommon arcdata2 arccredential glibmm-2.4 sigc-2.0 pthread
Listing files
// -*- indent-tabs-mode: nil -*- #ifdef HAVE_CONFIG_H #include <config.h> #endif #define VERSION "JL" #include <iostream> #include <string> #include <list> #include <arc/ArcLocation.h> #include <arc/Logger.h> #include <arc/StringConv.h> #include <arc/URL.h> #include <arc/UserConfig.h> #include <arc/credential/Credential.h> #include <arc/data/DataHandle.h> #include <arc/data/DataPoint.h> #include <arc/OptionParser.h> static Arc::Logger logger(Arc::Logger::getRootLogger(), "arcls"); int main(int argc, char **argv) { // Setup logging Arc::LogStream logcerr(std::cerr); logcerr.setFormat(Arc::ShortFormat); Arc::Logger::getRootLogger().addDestination(logcerr); Arc::Logger::getRootLogger().setThreshold(Arc::WARNING); // Setup user configuration Arc::UserConfig usercfg("/home/jonas/.arc/client.conf", Arc::initializeCredentialsType::SkipCredentials); if (!usercfg) { logger.msg(Arc::ERROR, "Failed configuration initialization"); return 1; } usercfg.UtilsDirPath(Arc::UserConfig::ARCUSERDIRECTORY); // Setup URL std::string urlString = "srm://srm.swegrid.se/ops"; Arc::URL url = urlString; // Check for secure protocol if (url.IsSecureProtocol()) { usercfg.InitializeCredentials(); if (!Arc::Credential::IsCredentialsValid(usercfg)) { logger.msg(Arc::ERROR, "Unable to list content of %s: No valid credentials found", url.str()); return false; } } // Create a data handle Arc::DataHandle dataHandle(url, usercfg); if (!dataHandle) { logger.msg(Arc::ERROR, "Unsupported URL given"); return false; } dataHandle->SetSecure(false); // Check access if(true) { std::cout << urlString << " - "; if(dataHandle->Check()) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } // What information to retrieve Arc::DataPoint::DataPointInfoType verb = (Arc::DataPoint::DataPointInfoType) (Arc::DataPoint::INFO_TYPE_MINIMAL | Arc::DataPoint::INFO_TYPE_NAME | Arc::DataPoint::INFO_TYPE_STRUCT | Arc::DataPoint::INFO_TYPE_ALL | Arc::DataPoint::INFO_TYPE_TYPE | Arc::DataPoint::INFO_TYPE_TIMES | Arc::DataPoint::INFO_TYPE_CONTENT | Arc::DataPoint::INFO_TYPE_ACCESS); Arc::DataStatus res; Arc::FileInfo file; std::list<Arc::FileInfo> files; // Do file listing res = dataHandle->List(files, verb); // Check for errors if (!res) { if (files.size() == 0) { logger.msg(Arc::ERROR, "Failed listing files"); if (res.Retryable()) logger.msg(Arc::ERROR, "This seems like a temporary error, please try again later"); return false; } logger.msg(Arc::INFO, "Warning: " "Failed listing files but some information is obtained"); } // Show files std::cout << "<Name>"; std::cout << " <Type>"; std::cout << " <Size>"; std::cout << " <Creation>"; std::cout << " <Validity>"; std::cout << " <CheckSum>"; std::cout << " <Latency>"; for (std::list<Arc::FileInfo>::iterator i = files.begin(); i != files.end(); i++) { std::cout << i->GetName(); switch (i->GetType()) { case Arc::FileInfo::file_type_file: std::cout << " file"; break; case Arc::FileInfo::file_type_dir: std::cout << " dir"; break; default: std::cout << " unknown"; break; } if (i->CheckSize()) std::cout << " " << i->GetSize(); else std::cout << " (n/a)"; if (i->CheckCreated()) std::cout << " " << i->GetCreated(); else std::cout << " (n/a)"; if (i->CheckValid()) std::cout << " " << i->GetValid(); else std::cout << " (n/a)"; if (i->CheckCheckSum()) std::cout << " " << i->GetCheckSum(); else std::cout << " (n/a)"; if (i->CheckLatency()) std::cout << " " << i->GetLatency(); else std::cout << " (n/a)"; std::cout << std::endl; // Show urls for (std::list<Arc::URL>::const_iterator u = i->GetURLs().begin(); u != i->GetURLs().end(); u++) std::cout << "\t" << *u << std::endl; // Show metadata //std::map<std::string, std::string> md = i->GetMetaData(); //for (std::map<std::string, std::string>::iterator mi = md.begin(); mi != md.end(); ++mi) // std::cout<<mi->first<<":"<<mi->second<<std::endl; } }