Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:08

0001 #include "FWCore/SharedMemory/interface/ControllerChannel.h"
0002 #include "FWCore/SharedMemory/interface/WorkerChannel.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 #include <memory>
0006 #include <string>
0007 #include <stdio.h>
0008 #include <cassert>
0009 #include <thread>
0010 
0011 #include "controller.h"
0012 #include "worker.h"
0013 namespace {
0014   const char* jobType(bool isWorker) {
0015     if (isWorker) {
0016       return "Worker";
0017     }
0018     return "Controller";
0019   }
0020 }  // namespace
0021 
0022 int main(int argc, char** argv) {
0023   bool isWorker = true;
0024   int retValue = 0;
0025   try {
0026     if (argc > 1) {
0027       retValue = worker(argc, argv, WorkerType::kStartupTimeout);
0028     } else {
0029       isWorker = false;
0030       retValue = controller(argc, argv, 5);
0031     }
0032   } catch (cms::Exception const& iException) {
0033     if (iException.category() != "ExternalFailure") {
0034       throw;
0035     } else {
0036       std::cout << "expected failure occurred\n";
0037       return 0;
0038     }
0039   } catch (std::exception const& iException) {
0040     std::cerr << "Caught exception\n" << iException.what() << "\n";
0041     if (isWorker) {
0042       std::cerr << "in worker\n";
0043     } else {
0044       std::cerr << "in controller\n";
0045     }
0046     return 1;
0047   }
0048   if (0 == retValue) {
0049     std::cout << jobType(isWorker) << " success" << std::endl;
0050   } else {
0051     std::cout << jobType(isWorker) << " failed" << std::endl;
0052   }
0053   return 1;
0054 }