Back to index

nordugrid-arc-nox  1.1.0~rc6
manage_jobq.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <iostream>
00006 #include "job_queue.h"
00007 
00008 static void 
00009 dump(int argc, char **argv)
00010 {
00011     if (argc != 3) {
00012         std::cerr << "Invalid argument" << std::endl;
00013         return;
00014     }
00015     Arc::JobQueue jobq;
00016     jobq.init(argv[2], "jobq");
00017     for (Arc::JobQueueIterator it = jobq.getAll(); it.hasMore(); it++) {
00018         Arc::Job *j = *it;
00019         std::cout << "-------------------" << std::endl;
00020         std::cout << (std::string)*j << std::endl;
00021     }
00022 }
00023 
00024 static void 
00025 remove (int argc, char **argv)
00026 {
00027     if (argc != 4) {
00028         std::cerr << "Invalid argument" << std::endl;
00029         return;
00030     }
00031     Arc::JobQueue jobq;
00032     jobq.init(argv[2], "jobq");
00033     std::string job_id = argv[3];
00034     jobq.remove(job_id);
00035 }
00036 
00037 int main(int argc, char **argv)
00038 {
00039     if (argc < 2) {
00040         std::cerr << "Invalid argument" << std::endl;
00041         return -1;
00042     }
00043     std::string cmd = argv[1];
00044     if (cmd == "dump") {
00045         dump(argc, argv);
00046     } else if (cmd == "remove") {
00047         remove(argc, argv);
00048     } else {
00049         std::cerr << "Unknown command: " << cmd << std::endl;
00050         return -1;
00051     }
00052     return 0;
00053 }