Definition at line 78 of file mainIDashServer.cpp. References Impala::Core::IDash::VideoSetWrapper::Add(), Impala::CmdOptions::AddOption(), Impala::atol(), DoProcessAnnotationSet(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetBool(), Impala::CmdOptions::GetInstance(), Impala::Core::VideoJob::ServerProxy::GetJobState(), Impala::CmdOptions::GetNrArg(), Impala::CmdOptions::GetString(), ILOG_ERROR, ILOG_ERROR_COUNT, ILOG_INFO, ILOG_VAR, Impala::CmdOptions::Initialise(), Impala::Core::IDash::Client::IsConnected(), Impala::Core::VideoJob::ServerProxy::IsConnected(), Impala::CmdOptions::ParseArgs(), Impala::Util::IOBufferFile::Read(), Impala::Core::IDash::Client::ScheduleJob(), Impala::Core::VideoJob::ServerProxy::ScheduleJob(), Impala::Util::IOBuffer::Size(), Impala::Util::Sleep(), Impala::Util::ChannelServer::Start(), Impala::Job::State::ToString(), Impala::Core::IDash::XmlQuerySet::Valid(), and Impala::Core::IDash::XmlVideo::Valid(). Referenced by main(). 00079 { 00080 CmdOptions& options = CmdOptions::GetInstance(); 00081 options.Initialise(false, false, true); 00082 options.AddOption(0, "noIdle", "", "0"); 00083 String usageStr = "cmd, with cmd = \n\n"; 00084 usageStr += " jobstatus jobserveraddr jobid\n"; 00085 if (! options.ParseArgs(argc, argv, usageStr, 2)) 00086 return 1; 00087 00088 ILOG_VAR(Impala.Application.IDash.mainIDashServer); 00089 00090 String passwordFile = options.GetString("passwordFile"); 00091 String cmd = options.GetArg(0); 00092 if (cmd == "jobstate") 00093 { 00094 String jobServerAddr = options.GetArg(1); 00095 Core::VideoJob::ServerProxy jobServer(jobServerAddr, passwordFile, 10); 00096 if (!jobServer.IsConnected()) 00097 return 1; 00098 00099 int jobId = Impala::atol(options.GetArg(2)); 00100 Job::State::StateType state; 00101 int exitCode; 00102 String errorLog; 00103 jobServer.GetJobState(jobId, state, exitCode, errorLog); 00104 ILOG_INFO("state = " << Job::State::ToString(state)); 00105 } 00106 else if (cmd == "schedulejob") 00107 { 00108 String jobServerAddr = options.GetArg(1); 00109 Core::VideoJob::ServerProxy jobServer(jobServerAddr, passwordFile, 10); 00110 if (!jobServer.IsConnected()) 00111 return 1; 00112 00113 String cmdLine = options.GetArg(2); 00114 int res = jobServer.ScheduleJob(cmdLine, 0); 00115 ILOG_INFO("res = " << res); 00116 Util::Sleep(100); // need to stay alive a little for job to live on server 00117 } 00118 else if (cmd == "serve") 00119 { 00120 if (options.GetNrArg() < 4) 00121 { 00122 ILOG_ERROR("Need more parameters"); 00123 return 1; 00124 } 00125 int port = atol(options.GetArg(1)); 00126 int nrPorts = atol(options.GetArg(2)); 00127 String jobServerAddr = options.GetArg(3); 00128 Core::IDash::Server server(port, nrPorts, passwordFile, jobServerAddr); 00129 bool doIdle = ! options.GetBool("noIdle"); 00130 server.Start(doIdle); 00131 } 00132 else if (cmd == "processvideo") 00133 { 00134 if (options.GetNrArg() < 3) 00135 { 00136 ILOG_ERROR("Need more parameters"); 00137 return 1; 00138 } 00139 String vidArg = options.GetArg(1); 00140 Core::IDash::XmlVideo xmlVideo(vidArg); 00141 if (!xmlVideo.Valid()) 00142 return 1; 00143 String setArg = options.GetArg(2); 00144 Core::IDash::XmlQuerySet xmlQuerySet(setArg); 00145 if (!xmlQuerySet.Valid()) 00146 return 1; 00147 Core::IDash::VideoSetWrapper vidSet("idash_vds.txt"); 00148 vidSet.Add(xmlVideo, xmlQuerySet); 00149 } 00150 else if (cmd == "processqueryset") 00151 { 00152 if (options.GetNrArg() < 2) 00153 { 00154 ILOG_ERROR("Need more parameters"); 00155 return 1; 00156 } 00157 String setArg = options.GetArg(1); 00158 Core::IDash::XmlQuerySet xmlQuerySet(setArg); 00159 if (!xmlQuerySet.Valid()) 00160 return 1; 00161 Core::IDash::VideoSetWrapper vidSet("idash_vds.txt"); 00162 vidSet.Add(xmlQuerySet); 00163 } 00164 else if (cmd == "processannotationset") 00165 { 00166 if (options.GetNrArg() < 2) 00167 { 00168 ILOG_ERROR("Need more parameters"); 00169 return 1; 00170 } 00171 String setArg = options.GetArg(1); 00172 DoProcessAnnotationSet(setArg); 00173 } 00174 else if (cmd == "client") 00175 { 00176 String idashServerAddr = options.GetArg(1); 00177 Core::IDash::Client client(idashServerAddr, passwordFile); 00178 if (!client.IsConnected()) 00179 return 1; 00180 00181 String jobFileName = options.GetArg(2); 00182 00183 Util::IOBufferFile srcBuf(jobFileName, true, true); 00184 char* charBuf = new char[srcBuf.Size()]; 00185 srcBuf.Read(charBuf, srcBuf.Size()); 00186 String job(charBuf, srcBuf.Size()); 00187 00188 ILOG_INFO("Sending [" << job << "], size = " << job.size()); 00189 String ref = client.ScheduleJob("http://myserver:8080/", job); 00190 ILOG_INFO("ref = [" << ref << "]"); 00191 delete charBuf; 00192 } 00193 else 00194 { 00195 ILOG_ERROR("Unknown cmd : " << cmd); 00196 } 00197 00198 //Util::IOBufferFile srcBuf(jobServerAddr, true, true); 00199 //Core::IDash::XmlJobReference job(jobServerAddr, &srcBuf); 00200 //Util::IOBufferFile dstBuf("jobref_out.xml", false, false); 00201 //job.Export(&dstBuf); 00202 00203 return ILOG_ERROR_COUNT; 00204 }
Here is the call graph for this function:
|