本文整理汇总了C++中Mapper::code方法的典型用法代码示例。如果您正苦于以下问题:C++ Mapper::code方法的具体用法?C++ Mapper::code怎么用?C++ Mapper::code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper::code方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TMSVishnuException
int
solveGenerique(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string optionValueSerialized;
std::string listSerialized = "";
//IN Parameters
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, optionValueSerialized);
// reset profile to handle result
diet_profile_reset(pb, 2);
QueryParameters* options = NULL;
List* list = NULL;
try {
//To parse the object serialized
if (! vishnu::parseEmfObject(optionValueSerialized, options)) {
throw TMSVishnuException(ERRCODE_INVALID_PARAM);
}
QueryType query(authKey);
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code(query.getCommandName());
mapper->code(optionValueSerialized, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
list = query.list(options);
::ecorecpp::serializer::serializer _ser;
listSerialized = _ser.serialize_str(list);
//OUT Parameter
diet_string_set(pb,0, "success");
diet_string_set(pb,1, listSerialized);
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
delete options;
delete list;
return 0;
}
示例2: options
/**
* \brief Function to solve the jobSubmit service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveSubmitJob(diet_profile_t* pb) {
std::string scriptContent;
std::string machineId;
std::string jsonEncodedOptions;
std::string authKey;
// get profile parameters
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, scriptContent);
diet_string_get(pb,3, jsonEncodedOptions);
// reset the profile to send back result
diet_profile_reset(pb, 2);
try {
JsonObject options(jsonEncodedOptions);
std::string scriptPath = options.getStringProperty("scriptpath");
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_submit_job");
mapper->code(scriptPath, mapperkey);
mapper->code(jsonEncodedOptions, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
//FIXME: decode job and options
ServerXMS* server = ServerXMS::getInstance();
JobServer jobServer(authKey, machineId, server->getSedConfig());
jobServer.setDebugLevel(server->getDebugLevel()); // Set the debug level
std::string jobId = jobServer.submitJob(scriptContent,
& options,
server->getDefaultBatchOption());
diet_string_set(pb,0, "success");
diet_string_set(pb,1, JsonObject::serialize(jobServer.getJobInfo(jobId)));
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, jobId);
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
return 0;
}
示例3: jobOutputServer
/**
* \brief Function to solve the jobOutPutGetResult service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveJobOutPutGetResult(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string optionsSerialized;
std::string jobid;
//IN Parameters
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, optionsSerialized);
diet_string_get(pb,3, jobid);
// reset profile to handle result
diet_profile_reset(pb, 2);
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_get_job_output");
mapper->code(machineId, mapperkey);
mapper->code(optionsSerialized, mapperkey);
mapper->code(jobid, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
//Start dealing with output
JobOutputServer jobOutputServer(authKey, machineId);
JsonObject options(optionsSerialized);
TMS_Data::JobResult result = jobOutputServer.getJobOutput(&options, jobid);
std::string jobFiles = vishnu::getResultFiles(result, false) ;
std::string outputInfo = bfs::unique_path(boost::str(boost::format("%1%/vishnu-%2%-outdescr%3%")
% boost::filesystem::temp_directory_path().string()
% jobid
% "%%%%%%%")).string();
vishnu::saveInFile(outputInfo, jobFiles);
diet_string_set(pb,0, "success");
diet_string_set(pb,1, outputInfo);
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& e) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
e.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, e.what());
}
return 0;
}
示例4: queryQueues
/**
* \brief Function to solve the getListOfQueues service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveListOfQueues(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string optionSerialized;
std::string listQueuesSerialized;
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, optionSerialized);
// reset profile to handle result
diet_profile_reset(pb, 2);
TMS_Data::ListQueues_ptr listQueues = NULL;
ListQueuesServer queryQueues(authKey,
ServerXMS::getInstance()->getBatchType(),
ServerXMS::getInstance()->getBatchVersion(),
optionSerialized);
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_list_queues");
mapper->code(machineId, mapperkey);
mapper->code(optionSerialized, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
listQueues = queryQueues.list();
::ecorecpp::serializer::serializer _ser;
listQueuesSerialized = _ser.serialize_str(listQueues);
diet_string_set(pb,0, "success");
diet_string_set(pb,1, listQueuesSerialized);
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
return 0;
}
示例5: SessionServer
/**
* \brief Function to solve the File transfer stop service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveFileTransferStop(diet_profile_t* pb) {
char* sessionKey = NULL;
char* optionsSerialized = NULL;
std::string finishError ="";
int mapperkey;
std::string cmd = "";
std::string errorInfo ="";
diet_string_get(diet_parameter(pb,0), &sessionKey, NULL);
diet_string_get(diet_parameter(pb,1), &optionsSerialized, NULL);
SessionServer sessionServer = SessionServer(std::string(sessionKey));
FMS_Data::StopTransferOptions_ptr options_ptr = NULL;
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_stop_file_transfer");
mapper->code(std::string(optionsSerialized), mapperkey);
cmd = mapper->finalize(mapperkey);
if(!vishnu::parseEmfObject(std::string(optionsSerialized), options_ptr)) {
SystemException(ERRCODE_INVDATA, "solve_fileTransferStop: options object is not well built");
}
int vishnuId=ServerFMS::getInstance()->getVishnuId();
boost::shared_ptr<FileTransferServer> fileTransferServer(new FileTransferServer(sessionServer,vishnuId));
fileTransferServer->stopThread(*options_ptr);
diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE);
sessionServer.finish(cmd, FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& e) {
try {
sessionServer.finish(cmd, FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
finishError = fe.what();
finishError +="\n";
}
e.appendMsgComp(finishError);
errorInfo = e.buildExceptionString();
diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE);
}
return 0;
}
示例6: fileTransferServer
/**
* \brief Function to solve the File transfer stop service
* \param profile is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveFileTransferStop(diet_profile_t* profile) {
std::string sessionKey = "";
std::string optionsSerialized = "";
std::string cmd = "";
diet_string_get(profile,0, sessionKey);
diet_string_get(profile,1, optionsSerialized);
// reset the profile to handle result
diet_profile_reset(profile, 2);
SessionServer sessionServer = SessionServer(sessionKey);
try {
//MAPPER CREATION
int mapperkey;
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_stop_file_transfer");
mapper->code(optionsSerialized, mapperkey);
cmd = mapper->finalize(mapperkey);
FMS_Data::StopTransferOptions_ptr options_ptr = NULL;
if(! vishnu::parseEmfObject(optionsSerialized, options_ptr)) {
SystemException(ERRCODE_INVDATA, "solveFileTransferStop: options object is not well built");
}
FileTransferServer fileTransferServer(sessionServer, ServerXMS::getInstance()->getVishnuId());
fileTransferServer.stopThread(*options_ptr);
delete options_ptr;
// set success result
diet_string_set(profile, 0, "success");
diet_string_set(profile, 1, "");
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
err.appendMsgComp(fe.what());
}
// set error result
diet_string_set(profile, 0, "error");
diet_string_set(profile, 1, err.what());
}
return 0;
}
示例7: jobServer
/**
* \brief Function to solve the jobInfo service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveJobInfo(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string jobId;
//IN Parameters
diet_string_get(pb, 0, authKey);
diet_string_get(pb, 1, machineId);
diet_string_get(pb, 2, jobId);
// reset the profile to send back result
diet_profile_reset(pb, 2);
try{
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_get_job_info");
mapper->code(machineId, mapperkey);
mapper->code(jobId, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
JobServer jobServer(authKey, machineId, ServerXMS::getInstance()->getSedConfig());
std::string jobSerialized = JsonObject::serialize(jobServer.getJobInfo(jobId));
diet_string_set(pb,1, jobSerialized);
diet_string_set(pb,0, "success");
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& e) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
e.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, e.what());
}
return 0;
}
示例8: solveChangeGroup
/* Returns the n first line of the file to the client application. */
int solveChangeGroup (diet_profile_t* profile) {
std::string localPath, userKey="", acLogin, machineName;
std::string path = "";
std::string host = "";
std::string sessionKey = "";
std::string group = "";
std::string cmd = "";
diet_string_get(profile, 0, sessionKey);
diet_string_get(profile, 1, path);
diet_string_get(profile, 2, host);
diet_string_get(profile, 3, group);
// reset the profile to handle result
diet_profile_reset(profile, 2);
localPath = path;
SessionServer sessionServer (sessionKey);
try {
int mapperkey;
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_chgrp");
mapper->code(group, mapperkey);
mapper->code(host + ":" + path, mapperkey);
cmd = mapper->finalize(mapperkey);
sessionServer.check();
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(host);
MachineServer machineServer(machine);
// check the machine
machineServer.checkMachine();
machineName = machineServer.getMachineName();
delete machine;
// get the acLogin
acLogin = UserServer(sessionServer).getUserAccountLogin(host);
FileFactory fileFactory;
fileFactory.setSSHServer(machineName);
boost::scoped_ptr<File> file (fileFactory.getFileServer(sessionServer,localPath, acLogin, userKey));
file->chgrp(group);
// set success result
diet_string_set(profile, 0, "success");
diet_string_set(profile, 1, "");
//To register the command
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
err.appendMsgComp(fe.what());
}
// set error result
diet_string_set(profile, 0, "error");
diet_string_set(profile, 1, err.what());
}
return 0;
}
示例9: solveTailFile
/* Returns the n last lines of a file to the client application. */
int solveTailFile(diet_profile_t* profile) {
std::string localPath;
std::string userKey;
std::string acLogin;
std::string machineName;
std::string path = "";
std::string host = "";
std::string sessionKey = "";
std::string optionsSerialized = "";
std::string cmd = "";
diet_string_get(profile, 0, sessionKey);
diet_string_get(profile, 1, path);
diet_string_get(profile, 2, host);
diet_string_get(profile, 3, optionsSerialized);
// reset the profile to handle result
diet_profile_reset(profile, 2);
localPath = path;
SessionServer sessionServer (sessionKey);
try {
sessionServer.check();
//MAPPER CREATION
int mapperkey;
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_tail_of_file");
mapper->code(host + ":" + path, mapperkey);
mapper->code(optionsSerialized, mapperkey);
cmd = mapper->finalize(mapperkey);
// Check machine
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(host);
MachineServer machineServer(machine);
machineServer.checkMachine();
machineName = machineServer.getMachineName();
delete machine;
// get the acLogin
acLogin = UserServer(sessionServer).getUserAccountLogin(host);
FileFactory ff;
ff.setSSHServer(machineName);
boost::scoped_ptr<File> file (ff.getFileServer(sessionServer,localPath, acLogin, userKey));
FMS_Data::TailOfFileOptions_ptr options_ptr= NULL;
if(!vishnu::parseEmfObject(optionsSerialized, options_ptr )) {
throw SystemException(ERRCODE_INVDATA, "solve_Tail: TailOfFileOptions object is not well built");
}
// set success result
diet_string_set(profile, 1, file->tail(*options_ptr));
diet_string_set(profile, 0, "success");
delete options_ptr;
//To register the command
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
err.appendMsgComp(fe.what());
}
// set error result
diet_string_set(profile, 0, "error");
diet_string_set(profile, 1, err.what());
}
return 0;
}
示例10: sessionServer
/* The function returns all the information about a file:
* - The local owner
* - The local group
* - The local uid & gid
* - The creation, modification and acces time.
* - The file type.
*/
int
solveGetInfos(diet_profile_t* profile) {
std::string path = "";
std::string host = "";
std::string sessionKey = "";
std::string localPath, userKey, machineName;
std::string cmd = "";
std::string fileStatSerialized = "";
diet_string_get(profile, 0, sessionKey);
diet_string_get(profile, 1, path);
diet_string_get(profile, 2, host);
// reset the profile to handle result
diet_profile_reset(profile, 2);
localPath = path;
SessionServer sessionServer (sessionKey);
try {
int mapperkey;
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_stat");
mapper->code(host + ":" + path, mapperkey);
cmd = mapper->finalize(mapperkey);
// check the sessionKey
sessionServer.check();
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(host);
MachineServer machineServer(machine);
// check the machine
machineServer.checkMachine();
// get the machineName
machineName = machineServer.getMachineName();
delete machine;
std::string acLogin = UserServer(sessionServer).getUserAccountLogin(host);
FileFactory ff;
ff.setSSHServer(machineName);
boost::scoped_ptr<File> file (ff.getFileServer(sessionServer,localPath, acLogin, userKey));
boost::scoped_ptr<FMS_Data::FileStat> fileStat_ptr (new FMS_Data::FileStat());
if ( file->exists()) {
*fileStat_ptr=file->getFileStat();
::ecorecpp::serializer::serializer _ser;
fileStatSerialized = _ser.serialize_str(const_cast<FMS_Data::FileStat_ptr>(fileStat_ptr.get()));
} else {
throw FMSVishnuException(ERRCODE_RUNTIME_ERROR, static_cast<SSHFile*>(file.get())->getErrorMsg());
}
// set success result
diet_string_set(profile, 1, fileStatSerialized);
diet_string_set(profile, 0, "success");
//To register the command
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
err.appendMsgComp(fe.what());
}
// set error result
diet_string_set(profile, 0, "error");
diet_string_set(profile, 1, err.what());
}
return 0;
}
示例11: UMSVishnuException
int
solveGenerique(diet_profile_t* profile) {
std::string sessionKey = "";
std::string optionValueSerialized = "";
std::string listSerialized = "";
std::string errorInfo;
std::string cmd;
std::string finishError ="";
//IN Parameters
diet_string_get(profile,0, sessionKey);
diet_string_get(profile,1, optionValueSerialized);
// reset profile to handle result
diet_profile_reset(profile, 2);
SessionServer sessionServer = SessionServer(sessionKey);
QueryParameters* options = NULL;
List* list = NULL;
try {
int mapperkey;
//To parse the object serialized
if (!vishnu::parseEmfObject(optionValueSerialized, options)) {
throw UMSVishnuException(ERRCODE_INVALID_PARAM);
}
QueryType query(sessionKey);
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
mapperkey = mapper->code(query.getCommandName());
mapper->code(optionValueSerialized, mapperkey);
cmd = mapper->finalize(mapperkey);
// perform the query
list = query.list(options);
::ecorecpp::serializer::serializer _ser;
listSerialized = _ser.serialize_str(const_cast<List*>(list));
//OUT Parameter
diet_string_set(profile, 0, "success");
diet_string_set(profile, 1, listSerialized.c_str());
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& e) {
try {
sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
finishError = fe.what();
finishError +="\n";
}
e.appendMsgComp(finishError);
errorInfo = e.buildExceptionString();
//OUT Parameter
// set error result
diet_string_set(profile, 0, "error");
diet_string_set(profile, 1, errorInfo);
}
delete options;
delete list;
return 0;
}
示例12: solveChangeGroup
/* Returns the n first line of the file to the client application. */
int solveChangeGroup (diet_profile_t* profile) {
string localPath, localUser,userKey="", acLogin, machineName;
char* path, *user, *host,*sessionKey, *group, *errMsg = NULL;
std::string finishError ="";
int mapperkey;
std::string cmd = "";
diet_string_get(diet_parameter(profile, 0), &sessionKey, NULL);
diet_string_get(diet_parameter(profile, 1), &path, NULL);
diet_string_get(diet_parameter(profile, 2), &user, NULL);
diet_paramstring_get(diet_parameter(profile, 3), &host, NULL);
diet_string_get(diet_parameter(profile, 4), &group, NULL);
localUser = user;
localPath = path;
SessionServer sessionServer (sessionKey);
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_chgrp");
mapper->code(group, mapperkey);
mapper->code(std::string(host)+":"+std::string(path), mapperkey);
cmd = mapper->finalize(mapperkey);
// check the sessionKey
sessionServer.check();
//
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(host);
MachineServer machineServer(machine);
// check the machine
machineServer.checkMachine();
// get the machineName
machineName = machineServer.getMachineName();
delete machine;
// get the acLogin
acLogin = UserServer(sessionServer).getUserAccountLogin(host);
FileFactory::setSSHServer(machineName);
boost::scoped_ptr<File> file (FileFactory::getFileServer(sessionServer,localPath, acLogin, userKey));
file->chgrp(group);
//To register the command
sessionServer.finish(cmd, FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
finishError = fe.what();
finishError +="\n";
}
err.appendMsgComp(finishError);
errMsg = strdup(err.buildExceptionString().c_str());
}
if (errMsg==NULL) {
errMsg = strdup("");
}
diet_string_set(diet_parameter(profile, 5), errMsg, DIET_VOLATILE);
return 0;
}
示例13: tailFile
/* Returns the n last lines of a file to the client application. */
int tailFile(diet_profile_t* profile) {
string localPath, localUser, userKey, tail, acLogin, machineName;
char* path, *user, *host,*sessionKey, *errMsg = NULL, *result = NULL, *optionsSerialized= NULL;
std::string finishError ="";
int mapperkey;
std::string cmd = "";
diet_string_get(diet_parameter(profile, 0), &sessionKey, NULL);
diet_string_get(diet_parameter(profile, 1), &path, NULL);
diet_string_get(diet_parameter(profile, 2), &user, NULL);
diet_paramstring_get(diet_parameter(profile, 3), &host, NULL);
diet_string_get(diet_parameter(profile, 4),&optionsSerialized, NULL);
localUser = user;
localPath = path;
SessionServer sessionServer (sessionKey);
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_tail");
mapper->code(std::string(host)+":"+std::string(path), mapperkey);
mapper->code(optionsSerialized, mapperkey);
cmd = mapper->finalize(mapperkey);
// check the sessionKey
sessionServer.check();
//
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(host);
MachineServer machineServer(machine);
// check the machine
machineServer.checkMachine();
// get the machineName
machineName = machineServer.getMachineName();
delete machine;
// get the acLogin
acLogin = UserServer(sessionServer).getUserAccountLogin(host);
FileFactory::setSSHServer(machineName);
boost::scoped_ptr<File> file (FileFactory::getFileServer(sessionServer,localPath, acLogin, userKey));
TailOfFileOptions_ptr options_ptr= NULL;
if(!vishnu::parseEmfObject(std::string(optionsSerialized), options_ptr )) {
throw SystemException(ERRCODE_INVDATA, "solve_Tail: TailOfFileOptions object is not well built");
}
tail = file->tail(*options_ptr);
result = strdup(tail.c_str());
//To register the command
sessionServer.finish(cmd, FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& err) {
try {
sessionServer.finish(cmd, FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
finishError = fe.what();
finishError +="\n";
}
err.appendMsgComp(finishError);
result = strdup("");
errMsg = strdup(err.buildExceptionString().c_str());
}
if (errMsg==NULL){
errMsg = strdup("");
}
else {
result = strdup("");
}
diet_string_set(diet_parameter(profile, 5), result, DIET_VOLATILE);
diet_string_set(diet_parameter(profile, 6), errMsg, DIET_VOLATILE);
return 0;
}
示例14: sessionServer
int
solveTransferRemoteFile(diet_profile_t* profile){
std::string srcPath = "";
std::string destUser = "";
std::string srcHost = "";
std::string sessionKey = "";
std::string destHost = "";
std::string destPath = "";
std::string optionsSerialized = "";
std::string srcUserKey = "";
std::string srcUserLogin = "";
std::string srcMachineName = "";
std::string errMsg = "";
std::string finishError = "";
std::string fileTransferSerialized = "";
std::string cmd = "";
diet_string_get(profile, 0, sessionKey);
diet_string_get(profile, 1, srcHost);
diet_string_get(profile, 2, srcPath);
diet_string_get(profile, 3, destHost);
diet_string_get(profile, 4, destPath);
diet_string_get(profile, 5, optionsSerialized);
// reset profile to handle result
diet_profile_reset(profile, 2);
SessionServer sessionServer (sessionKey);
try {
int mapperkey;
std::string destUserLogin(destUser);
std::string destMachineName(destHost);
SessionServer sessionServer (sessionKey);
// check the source machine
// and get the source machine if applied
if (destHost != "localhost"){
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(destHost);
MachineServer destMachineServer(machine);
destMachineServer.checkMachine();
destMachineName = destMachineServer.getMachineName();
delete machine;
} else {
destMachineName = destHost;
}
// get the source machine user login
if (destHost != "localhost"){
destUserLogin = UserServer(sessionServer).getUserAccountLogin(destHost);
} else {
destUserLogin = destUser;
}
//MAPPER CREATION
std::string destCpltPath = destPath;
if (destUser.empty()) {
destCpltPath = destHost + ":" + destPath;
}
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME);
if (transferMode == File::sync) {
if(transferType == File::copy) {
mapperkey = mapper->code("vishnu_cp");
}
if(transferType == File::move) {
mapperkey = mapper->code("vishnu_mv");
}
} else{
if (transferType == File::copy) {
mapperkey = mapper->code("vishnu_acp");
}
if (transferType == File::move) {
mapperkey = mapper->code("vishnu_amv");
}
}
mapper->code(srcHost + ":" + srcPath, mapperkey);
mapper->code(destCpltPath, mapperkey);
mapper->code(optionsSerialized, mapperkey);
cmd = mapper->finalize(mapperkey);
// check the sessionKey
sessionServer.check();
// get the source Vishnu machine
UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
machine->setMachineId(srcHost);
MachineServer srcMachineServer(machine);
// check the source machine
if (srcHost != "localhost"){
srcMachineServer.checkMachine();
srcMachineName = srcMachineServer.getMachineName();
} else {
srcMachineName = srcHost;
}
//.........这里部分代码省略.........