34 std::string constr =
"`cmsGetFnConnect frontier://smallfiles`";
43 std::cout <<
"SherpackFetcher: Trying to fetch the Sherpack " << sherpack << std::endl;
46 std::cout <<
"SherpackFetcher: Fetching of Sherpack did not succeed, terminating" << std::endl;
49 std::cout <<
"SherpackFetcher: Fetching successful" << std::endl;
52 std::ifstream my_file(sherpack.c_str());
55 std::cout <<
"SherpackFetcher: No Sherpack found" << std::endl;
59 std::cout <<
"SherpackFetcher: Sherpack found" << std::endl;
64 for (
int k=0;
k<33;
k++){
66 std::cout <<
"SherpackFetcher: failure, calculated and specified checksums differ!" << std::endl;
70 std::cout <<
"SherpackFetcher: Calculated checksum of the Sherpack is " << md5checksum <<
" and matches" << std::endl;
72 std::cout <<
"SherpackFetcher: Ignoring Checksum" << std::endl;
76 std::cout <<
"SherpackFetcher: Trying to unzip the Sherpack" << std::endl;
79 std::cout <<
"SherpackFetcher: Decompressing failed " << std::endl;
82 std::cout <<
"SherpackFetcher: Decompressing successful " << std::endl;
84 FILE *
file = fopen(const_cast<char*>(sherpackunzip.c_str()),
"r");
86 std::cout <<
"SherpackFetcher: Decompressed Sherpack exists with name " << sherpackunzip <<
" starting to untar it"<<std::endl;
89 std::cout <<
"SherpackFetcher: Could not open decompressed Sherpack" << std::endl;
99 unsigned long channel;
105 auto slc = std::make_shared<edm::serviceregistry::ServiceWrapper<edm::SiteLocalConfig> >(slcptr);
117 if(frontier_init(malloc,free)!=0)
119 fprintf(stderr,
"Error initializing frontier client: %s\n",frontier_getErrorMsg());
124 config=frontierConfig_get(connectstr.c_str(),
"",&ec);
127 fprintf(stderr,
"Error getting frontierConfig object: %s\n",frontier_getErrorMsg());
130 channel=frontier_createChannel2(config,&ec);
133 fprintf(stderr,
"Error creating frontier channel: %s\n",frontier_getErrorMsg());
139 FrontierRSBlob *frsb;
143 const char *localname;
145 const char *
path=pathstring.c_str();
146 snprintf(uribuf,
sizeof(uribuf)-1,
"Frontier/type=frontier_file:1:DEFAULT&encoding=BLOB&p1=%s",path);
147 ec=frontier_getRawData(channel,uribuf);
150 fprintf(stderr,
"Error getting data for %s: %s\n",path,frontier_getErrorMsg());
153 frsb=frontierRSBlob_open(channel,0,1,&ec);
156 fprintf(stderr,
"Error opening result blob for %s: %s\n",path,frontier_getErrorMsg());
160 (void)frontierRSBlob_getByte(frsb,&ec);
163 fprintf(stderr,
"Error getting result type for %s: %s\n",path,frontier_getErrorMsg());
166 n=frontierRSBlob_getInt(frsb,&ec);
169 fprintf(stderr,
"Error getting result size for %s: %s\n",path,frontier_getErrorMsg());
172 p=frontierRSBlob_getByteArray(frsb,n,&ec);
175 fprintf(stderr,
"Error getting result data for %s: %s\n",path,frontier_getErrorMsg());
178 localname=strrchr(path,
'/');
180 localname=pathstring.c_str();
183 fd=open(localname,O_CREAT|O_TRUNC|O_WRONLY,0666);
186 fprintf(stderr,
"Error creating %s: %s\n",localname,strerror(errno));
192 fprintf(stderr,
"Error writing to %s: %s\n",localname,strerror(errno));
198 printf(
"%d bytes written to %s\n",n,localname);
199 frontierRSBlob_close(frsb,&ec);
202 frontier_closeChannel(channel);
204 return (ec==FRONTIER_OK);
T getParameter(std::string const &) const
virtual std::string explainSelf() const
void md5_File(std::string, char *)
std::string SherpackLocation
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual std::string const lookupCalibConnect(std::string const &input) const =0
static ServiceToken createContaining(std::auto_ptr< T > iService)
create a service token that holds the service defined by iService
std::string SherpackChecksum
void Untar(FILE *, const char *)
SherpackFetcher(edm::ParameterSet const &)
int FnFileGet(std::string)
std::string SherpaProcess
int Unzip(std::string, std::string)