|
PLearn 0.1
|
#include <TestClientCommand.h>


Public Member Functions | |
| TestClientCommand () | |
| virtual void | run (const std::vector< std::string > &args) |
| The actual implementation of the 'TestClientCommand' command. | |
Static Protected Attributes | |
| static PLearnCommandRegistry | reg_ |
| This allows to register the 'TestClientCommand' command in the command registry. | |
Definition at line 48 of file TestClientCommand.h.
| PLearn::TestClientCommand::TestClientCommand | ( | ) |
Definition at line 53 of file TestClientCommand.cc.
:
PLearnCommand("testclient",
"Launches plearn in test client mode",
"testclient\n"
" Launches plearn in test client mode \n"
" \n"
)
{}
| void PLearn::TestClientCommand::run | ( | const std::vector< std::string > & | args | ) | [virtual] |
The actual implementation of the 'TestClientCommand' command.
Implements PLearn::PLearnCommand.
Definition at line 66 of file TestClientCommand.cc.
References PLearn::PLearnService::availableServers(), PLearn::PDateTime::currentLocalTime(), PLearn::endl(), i, PLearn::PLearnService::instance(), j, PLearn::PLearnService::log_callback(), PLearn::pout, PLearn::PLearnService::progress_callback(), PLearn::PLearnService::reserveServers(), PLearn::tostring(), PLearn::PLearnService::waitForResult(), PLearn::PLearnService::watchServers(), and x.
{
cout << "test client run" << endl;
PLearnService& ps(PLearnService::instance());
int ns= ps.availableServers();
TVec<PP<RemotePLearnServer> > ss= ps.reserveServers(ns);
cout << "test client has servers" << endl;
TVec<int> objids(ns);
for(int i= 0; i < ns; ++i)
{
//ss[i]->newObjectAsync(1, string("MemoryVMatrix(width= 5000, length= 7000)"));
//ss[i]->newObjectAsync(string("MemoryVMatrix(width= 5000, length= 7000)"));
objids[i]= ss[i]->newObject(string("MemoryVMatrix(width= 5000, length= 7000)"));
cerr << "NEW OBJ " << i << '-' << objids[i] << endl;
}
/*
for(int i= 0; i < ns; ++i)
{
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 1 from " << j << " at " << PDateTime::currentLocalTime() << endl;
ss[j]->getResults(objids[j]);
}
*/
for(int i= 0; i < ns; ++i)
ss[i]->callMethod(objids[i], "fill", 3.21*static_cast<real>(i+1));
for(int i= 0; i < ns; ++i)
{
/*
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 2 from " << j << " at " << PDateTime::currentLocalTime() << endl;
ss[j]->getResults();
*/
ps.waitForResult()->getResults();
}
cout << "before getRow" << endl;
for(int i= 0; i < ns; ++i)
ss[i]->callMethod(objids[i], "getRow", 3);
cout << "after getRow" << endl;
for(int i= 0; i < ns; ++i)
{
cout << "bws " << i << endl;
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 3 from " << j << " at " << PDateTime::currentLocalTime() << endl;
Vec vv;
cout << "getting it" << endl;
ss[j]->getResults(vv);
cout << "got it" << endl;
pout << '\t' << vv[0] << endl;
}
cout << "before call dot" << endl;
for(int i= 0; i < ns; ++i)
ss[i]->callMethod(objids[i], "dot", 1, 3, 4500);
cout << "after call dot" << endl;
for(int i= 0; i < ns; ++i)
{
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 4 from " << j << " at " << PDateTime::currentLocalTime() << endl;
real x;
ss[j]->getResults(x);
cout << endl << '=' << x << endl;
}
cout << "before call save" << endl;
for(int i= 0; i < ns; ++i)
ss[i]->callMethod(objids[i], "savePMAT", string("/home/saintmlx/testclient/mat")+tostring(i)+string(".pmat"));
cout << "after call save" << endl;
for(int i= 0; i < ns; ++i)
{
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 5 from " << j << " at " << PDateTime::currentLocalTime() << endl;
ss[j]->getResults();
}
cout << "before delete" << endl;
for(int i= 0; i < ns; ++i)
ss[i]->deleteObjectAsync(objids[i]);
cout << "after delete" << endl;
for(int i= 0; i < ns; ++i)
{
int j= ps.watchServers(ss, PLearnService::log_callback, PLearnService::progress_callback);
cout << "result 6 from " << j << " at " << PDateTime::currentLocalTime() << endl;
ss[j]->getResults();
}
}

PLearnCommandRegistry PLearn::TestClientCommand::reg_ [static, protected] |
This allows to register the 'TestClientCommand' command in the command registry.
Definition at line 55 of file TestClientCommand.h.
1.7.4