本文整理汇总了C++中StatusMessage::get_status方法的典型用法代码示例。如果您正苦于以下问题:C++ StatusMessage::get_status方法的具体用法?C++ StatusMessage::get_status怎么用?C++ StatusMessage::get_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatusMessage
的用法示例。
在下文中一共展示了StatusMessage::get_status方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_command
CliManager::cli_parse_status CliManager::parse_command(std::string command){
ActionMessage m;
m.from_string(command);
StatusMessage response = LocalCommands::parse_local_command(m);
std::cout << response.to_string() << std::endl;
if (response.get_status() == "ok"){
return PARSE_OK;
}
if (response.get_status() == "command"){
if (response.get<std::string>("action") == "exit"){
return PARSE_EXIT;
}
}
return PARSE_ERROR;
}
示例2: rm_no_replicate_block_from_ns
int rm_no_replicate_block_from_ns(const char* ns_addr, const uint64_t block_id)
{
int ret = TFS_SUCCESS;
ClientCmdMessage req_cc_msg;
req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
req_cc_msg.set_value3(block_id);
req_cc_msg.set_value4(tfs::nameserver::HANDLE_DELETE_BLOCK_FLAG_ONLY_RELATION);
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* rsp = NULL;
if((ret = send_msg_to_server(Func::get_host_ip(ns_addr), client, &req_cc_msg, rsp)) != TFS_SUCCESS)
{
TBSYS_LOG(ERROR, "send remove block from ns command failed. block_id: %" PRI64_PREFIX "u, ret: %d", block_id, ret);
}
else
{
assert(NULL != rsp);
if (STATUS_MESSAGE == rsp->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
if (STATUS_MESSAGE_OK == sm->get_status())
{
TBSYS_LOG(INFO, "remove block from ns success, ns_addr: %s, blockid: %" PRI64_PREFIX "u", ns_addr, block_id);
}
else
{
TBSYS_LOG(ERROR, "remove block from ns fail, ns_addr: %s, blockid: %" PRI64_PREFIX "u, ret: %d",
ns_addr, block_id, sm->get_status());
ret = sm->get_status();
}
}
else
{
TBSYS_LOG(ERROR, "remove block from ns: %s fail, blockid: %" PRI64_PREFIX "u, unkonw msg type", ns_addr, block_id);
ret = EXIT_UNKNOWN_MSGTYPE;
}
}
NewClientManager::get_instance().destroy_client(client);
return ret;
}
示例3: update_block_info
int OpManager::update_block_info(const BlockInfoV2& block_info, const common::UpdateBlockInfoType type)
{
int ret = TFS_SUCCESS;
DsRuntimeGlobalInformation& ds_info = DsRuntimeGlobalInformation::instance();
create_msg_ref(UpdateBlockInfoMessageV2, req_msg);
req_msg.set_block_info(block_info);
req_msg.set_type(type);
req_msg.set_server_id(ds_info.information_.id_);
NewClient* client = NewClientManager::get_instance().create_client();
if (NULL == client)
{
ret = EXIT_CLIENT_MANAGER_CREATE_CLIENT_ERROR;
}
else
{
tbnet::Packet* ret_msg = NULL;
ret = send_msg_to_server(ds_info.ns_vip_port_, client, &req_msg, ret_msg);
if (TFS_SUCCESS == ret)
{
if (STATUS_MESSAGE == ret_msg->getPCode())
{
StatusMessage* smsg = dynamic_cast<StatusMessage*>(ret_msg);
ret = smsg->get_status();
TBSYS_LOG(DEBUG, "update block info. blockid: %"PRI64_PREFIX"u, status: %d %s",
block_info.block_id_, smsg->get_status(), smsg->get_error());
}
else
{
ret = EXIT_COMMIT_BLOCK_UPDATE_ERROR;
}
}
NewClientManager::get_instance().destroy_client(client);
}
return ret;
}
示例4: write_index
int TranBlock::write_index()
{
int ret = TFS_SUCCESS;
WriteInfoBatchMessage req_wib_msg;
req_wib_msg.set_block_id(seg_data_.seg_info_.block_id_);
req_wib_msg.set_offset(0);
req_wib_msg.set_length(dest_raw_meta_.size());
req_wib_msg.set_raw_meta_list(&dest_raw_meta_);
req_wib_msg.set_block_info(&dest_block_info_);
req_wib_msg.set_cluster(COPY_BETWEEN_CLUSTER);
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* rsp = NULL;
if(TFS_SUCCESS != send_msg_to_server(dest_ds_id_, client, &req_wib_msg, rsp))
{
rsp = NULL;
}
if (NULL == rsp)
{
TBSYS_LOG(ERROR, "write index failed, blockid: %u, length: %zd, ret: %d",
seg_data_.seg_info_.block_id_, dest_raw_meta_.size(), ret);
ret = TFS_ERROR;
}
else
{
if (STATUS_MESSAGE == rsp->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
if (STATUS_MESSAGE_OK != sm->get_status())
{
TBSYS_LOG(ERROR, "write raw index to ds: %s fail, blockid: %u, file count: %d, ret: %d",
tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, static_cast<int32_t>(dest_raw_meta_.size()), sm->get_status());
ret = TFS_ERROR;
}
}
else
{
TBSYS_LOG(ERROR, "write raw index to ds: %s fail, blockid: %u, file count: %d, unkonw msg type",
tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, static_cast<int32_t>(dest_raw_meta_.size()));
ret = TFS_ERROR;
}
}
NewClientManager::get_instance().destroy_client(client);
return ret;
}
示例5: register_peer
StatusMessage LocalCommands::register_peer(ActionMessage& pt){
ActionMessage m("register-peer");
std::string ip_address = pt.get<std::string>("ip-address");
AsyncRequestClient c(ip_address);
SerializableList<FileInfo> file_list = ConnectionManager::list_files();
m.push_back(std::make_pair("file-list", file_list.get_ptree()));
StatusMessage response = c.send_message(m);
if (response.get_status() == "ok"){
if (ConnectionManager::registered_peers.find(response.get_peer_id()) == ConnectionManager::registered_peers.end()){
ConnectionManager::register_peer(response.get_peer_id(), response.get<std::string>("ip-address"));
boost::property_tree::ptree ptr = response.get_ptree();
BOOST_FOREACH(const boost::property_tree::ptree::value_type& child, ptr.get_child("file-list")) {
boost::shared_ptr<FileInfo> f(new FileInfo);
f -> from_ptree(child.second.get_child(""));
ConnectionManager::register_extern_file(f);
}
}
}
示例6: rm_block_from_ns
int TranBlock::rm_block_from_ns(uint64_t ds_id)
{
int ret = TFS_SUCCESS;
ClientCmdMessage req_cc_msg;
req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
req_cc_msg.set_value1(ds_id);
req_cc_msg.set_value3(seg_data_.seg_info_.block_id_);
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* rsp = NULL;
if((ret = send_msg_to_server(Func::get_host_ip(dest_ns_addr_.c_str()), client, &req_cc_msg, rsp)) != TFS_SUCCESS)
{
TBSYS_LOG(ERROR, "send remove block from ns command failed. block_id: %u, ret: %d", seg_data_.seg_info_.block_id_, ret);
rsp = NULL;
}
else
{
if (rsp != NULL && STATUS_MESSAGE == rsp->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
if (STATUS_MESSAGE_OK == sm->get_status())
{
TBSYS_LOG(INFO, "remove block from ns success, ds_addr: %s, blockid: %u",
tbsys::CNetUtil::addrToString(ds_id).c_str(), seg_data_.seg_info_.block_id_);
}
else
{
TBSYS_LOG(ERROR, "remove block from ns fail, ds_addr: %s, blockid: %u, ret: %d",
tbsys::CNetUtil::addrToString(ds_id).c_str(), seg_data_.seg_info_.block_id_, sm->get_status());
ret = TFS_ERROR;
}
}
else
{
TBSYS_LOG(ERROR, "remove block from ns: %s fail, blockid: %u, unkonw msg type",
tbsys::CNetUtil::addrToString(ds_id).c_str(), seg_data_.seg_info_.block_id_);
ret = TFS_ERROR;
}
}
NewClientManager::get_instance().destroy_client(client);
return ret;
}
示例7: get_file_tcp
StatusMessage LocalCommands::get_file_tcp(ActionMessage& pt){
ActionMessage m("request-download");
std::string file_name = pt.get<std::string>("file-name");
boost::shared_ptr<FileInfo> file = ConnectionManager::get_extern_file_by_id(pt.get<std::string>("file-id"));
if (file){
boost::shared_ptr<DatadInfo> server = ConnectionManager::get_peer_by_id(file -> get_peer_id());
if (server){
m.put<std::string>("file-id", pt.get<std::string>("file-id"));
boost::shared_ptr<AsyncRequestClient> c = ConnectionManager::get_request_client_by_id(server -> get_id());
if (c){
StatusMessage response = c -> send_message(m);
std::string download_id = response.get<std::string>("download-id");
if (response.get_status() == "ok"){
ConnectionManager::tcp_file_client_session(server, file, file_name ,download_id);
return(response);
}
}
}
}
StatusMessage response("error");
response.put<std::string>("message", "Error starting download");
return(response);
}
示例8: write_data
int TranBlock::write_data()
{
int block_len = dest_content_buf_.getDataLen();
int cur_write_offset = 0;
int cur_len = 0;
int ret = TFS_SUCCESS;
while (block_len > 0)
{
int64_t remainder_retrys = RETRY_TIMES;
while (remainder_retrys > 0)
{
cur_len = std::min(static_cast<int64_t>(block_len), TRAN_BUFFER_SIZE);
WriteRawDataMessage req_wrd_msg;
req_wrd_msg.set_block_id(seg_data_.seg_info_.block_id_);
req_wrd_msg.set_offset(cur_write_offset);
req_wrd_msg.set_length(cur_len);
req_wrd_msg.set_data(dest_content_buf_.getData());
//new block
if (0 == cur_write_offset)
{
req_wrd_msg.set_new_block(1);
}
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* rsp = NULL;
if(TFS_SUCCESS != send_msg_to_server(dest_ds_id_, client, &req_wrd_msg, rsp))
{
rsp = NULL;
}
if (NULL == rsp)
{
TBSYS_LOG(ERROR, "write data failed, blockid: %u, dest_ds: %s, cur_write_offset: %d, cur_len: %d, ret: %d",
seg_data_.seg_info_.block_id_, tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), cur_write_offset, cur_len, ret);
ret = TFS_ERROR;
}
else
{
if (STATUS_MESSAGE == rsp->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(rsp);
if (STATUS_MESSAGE_OK != sm->get_status())
{
TBSYS_LOG(ERROR, "write raw data to ds: %s fail, blockid: %u, offset: %d, ret: %d",
tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, cur_write_offset, sm->get_status());
ret = TFS_ERROR;
}
}
else
{
TBSYS_LOG(ERROR, "write raw data to ds: %s fail, blockid: %u, offset: %d, unkonw msg type",
tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_, cur_write_offset);
ret = TFS_ERROR;
}
dest_content_buf_.drainData(cur_len);
block_len = dest_content_buf_.getDataLen();
cur_write_offset += cur_len;
NewClientManager::get_instance().destroy_client(client);
if (NULL == rsp)
{
--remainder_retrys;
continue;
}
else
{
if (cur_len != TRAN_BUFFER_SIZE)
{
// quit
block_len = 0;
}
TBSYS_LOG(INFO, "write raw data to ds: %s successful, blockid: %u",
tbsys::CNetUtil::addrToString(dest_ds_id_).c_str(), seg_data_.seg_info_.block_id_);
break;
}
}
}
if (TFS_SUCCESS != ret)
{
break;
}
}
return ret;
}
示例9: req_update_block_info
int Requester::req_update_block_info(const uint32_t block_id, const UpdateBlockType repair)
{
UpdateBlockType tmp_repair = repair;
BlockInfo* blk = NULL;
if (UPDATE_BLOCK_MISSING != tmp_repair)
{
int32_t visit_count = 0;
int ret = data_management_->get_block_info(block_id, blk, visit_count);
if (EXIT_NO_LOGICBLOCK_ERROR == ret)
{
tmp_repair = UPDATE_BLOCK_MISSING;
}
else
{
if (NULL == blk)
{
TBSYS_LOG(ERROR, "blockid: %u can not find block info.", block_id);
tmp_repair = UPDATE_BLOCK_REPAIR;
}
else
{
TBSYS_LOG(
INFO,
"req update block info, blockid: %u, version: %d, file count: %d, size: %d, delfile count: %d, del_size: %d, seqno: %d\n",
blk->block_id_, blk->version_, blk->file_count_, blk->size_, blk->del_file_count_, blk->del_size_, blk->seq_no_);
}
}
}
int ret = TFS_ERROR;
UpdateBlockInfoMessage ub_msg;
ub_msg.set_block_id(block_id);
ub_msg.set_block(blk);
ub_msg.set_server_id(dataserver_id_);
ub_msg.set_repair(tmp_repair);
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* return_msg = NULL;
ret = send_msg_to_server(ns_ip_port_, client, &ub_msg, return_msg);
if (TFS_SUCCESS != ret)
{
NewClientManager::get_instance().destroy_client(client);
return ret;
}
int need_expire = 0;
if (STATUS_MESSAGE == return_msg->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(return_msg);
if (STATUS_MESSAGE_OK == sm->get_status())
{
ret = TFS_SUCCESS;
}
else if (STATUS_MESSAGE_REMOVE == sm->get_status())
{
need_expire = 1;
ret = TFS_SUCCESS;
}
else
{
TBSYS_LOG(ERROR, "req update block info: %s, id: %u, tmp_repair: %d\n", sm->get_error(), block_id, tmp_repair);
}
}
else
{
TBSYS_LOG(ERROR,"unknow packet pcode: %d", return_msg->getPCode());
}
NewClientManager::get_instance().destroy_client(client);
if (need_expire)
{
data_management_->del_single_block(block_id);
}
return ret;
}
示例10: req_block_write_complete
int Requester::req_block_write_complete(const uint32_t block_id,
const int32_t lease_id, const int32_t success, const UnlinkFlag unlink_flag)
{
TBSYS_LOG(DEBUG, "req block write complete begin id: %u, lease_id: %u\n", block_id, lease_id);
BlockInfo* blk = NULL;
int visit_count = 0;
int ret = data_management_->get_block_info(block_id, blk, visit_count);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "req block write complete: can not find block, id: %u, ret: %d\n", block_id, ret);
return TFS_ERROR;
}
BlockInfo tmpblk;
memcpy(&tmpblk, blk, sizeof(BlockInfo));
ret = data_management_->get_block_curr_size(block_id, tmpblk.size_);
if (TFS_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "req block write complete: can not find block, id: %u, ret: %d\n", block_id, ret);
return TFS_ERROR;
}
BlockWriteCompleteMessage bwc_msg;
bwc_msg.set_block(&tmpblk);
bwc_msg.set_server_id(dataserver_id_);
bwc_msg.set_lease_id(lease_id);
WriteCompleteStatus wc_status = WRITE_COMPLETE_STATUS_YES;
if (TFS_SUCCESS != success)
{
wc_status = WRITE_COMPLETE_STATUS_NO;
}
bwc_msg.set_success(wc_status);
bwc_msg.set_unlink_flag(unlink_flag);
NewClient* client = NewClientManager::get_instance().create_client();
tbnet::Packet* return_msg = NULL;
ret = send_msg_to_server(ns_ip_port_, client, &bwc_msg, return_msg);
if (TFS_SUCCESS != ret)
{
NewClientManager::get_instance().destroy_client(client);
return ret;
}
if (STATUS_MESSAGE == return_msg->getPCode())
{
StatusMessage* sm = dynamic_cast<StatusMessage*>(return_msg);
if (STATUS_MESSAGE_OK == sm->get_status())
{
ret = TFS_SUCCESS;
}
else
{
ret = TFS_ERROR;
TBSYS_LOG(ERROR, "rep block write complete, nsip: %s, error desc: %s, id: %u\n",
tbsys::CNetUtil::addrToString(ns_ip_port_).c_str(), sm->get_error(), block_id);
}
}
else
{
TBSYS_LOG(ERROR, "rep block write complete, blockid: %u, msg type: %d error.\n", block_id,
return_msg->getPCode());
ret = TFS_ERROR;
}
NewClientManager::get_instance().destroy_client(client);
return ret;
}
示例11: do_monitor
int do_monitor(const VSTRING& param, int32_t type)
{
int ret = TFS_SUCCESS;
string server = param[0];
uint64_t ip_port = 0;
{
char ip[MAX_CMD_SIZE+1]; // to support mutiple port in the same server, must copy
ip[MAX_CMD_SIZE] = '\0';
int32_t port = get_port(strncpy(ip, server.c_str(), MAX_CMD_SIZE));
ip_port = Func::str_to_addr(ip, port);
}
AdminCmdMessage* admin_msg = new AdminCmdMessage(type);
for (size_t i = 1; i < param.size(); i++)
{
admin_msg->set_index(param[i]);
}
NewClient* client = NewClientManager::get_instance().create_client();
if (NULL != client)
{
tbnet::Packet* message = NULL;
if (TFS_SUCCESS == (ret = send_msg_to_server(ip_port, client, admin_msg, message)))
{
if (STATUS_MESSAGE == message->getPCode())
{
StatusMessage* msg = dynamic_cast<StatusMessage*>(message);
ret = msg->get_status();
fprintf(stderr, "%s %s \033[0m\n", ret != TFS_SUCCESS ? FAIL_COLOR : SUC_COLOR, msg->get_error());
}
else if (ADMIN_CMD_MESSAGE == message->getPCode() &&
ADMIN_CMD_RESP == dynamic_cast<AdminCmdMessage*>(message)->get_cmd_type())
{
vector<MonitorStatus>* m_status = dynamic_cast<AdminCmdMessage*>(message)->get_status();
int32_t size = m_status->size();
fprintf(stderr, "\033[36m ================== %s count: %d ===================\033[0m\n",
server.c_str(), size);
// update server ==> index
VSTRING& index = g_server_map[server];
index.clear();
for (int32_t i = 0; i < size; i++)
{
(*m_status)[i].dump();
index.push_back((*m_status)[i].index_);
}
fprintf(stderr, "\033[36m-----------------------------------------------------------------------------------\033[0m\n\n");
}
else
{
fprintf(stderr, "%s unknown message recieved, op cmd fail\n \033[0m", FAIL_COLOR);
}
}
else
{
fprintf(stderr, "send message error");
}
NewClientManager::get_instance().destroy_client(client);
}
else
{
fprintf(stderr, "create client error");
ret = TFS_ERROR;
}
return ret;
}