本文整理汇总了C++中ObString::write方法的典型用法代码示例。如果您正苦于以下问题:C++ ObString::write方法的具体用法?C++ ObString::write怎么用?C++ ObString::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObString
的用法示例。
在下文中一共展示了ObString::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tester
TEST(ObRootServer2Test2, init_report)
{
ObRootServer2* root_server;
ObRootWorkerForTest worker;
root_server = worker.get_root_server();
ASSERT_TRUE(root_server->init("./root_server.conf", 100, &worker));
ObRootServerTester tester(root_server);
tester.get_wait_init_time() = 3 * 1000000;
ObServer server(ObServer::IPV4, "10.10.10.1", 1001);
ObServer server2(ObServer::IPV4, "10.10.10.2", 1001);
ASSERT_TRUE(!(server == server2));
int64_t time_stamp = 0;
root_server->start_threads();
int status;
sleep(3);
int ret = root_server->regist_server(server, false, status);
ASSERT_EQ(ret, OB_SUCCESS);
ret = root_server->regist_server(server2, false, status);
ASSERT_EQ(ret, OB_SUCCESS);
// now we have two cs
tester.get_lease_duration() = 100 * 1000 * 1000;
TBSYS_LOG(INFO, "will start test");
//tester.init_root_table_by_report();
//while (worker.start_new_send_times < 2)
//{
// TBSYS_LOG(INFO, "wait send start_new_schema now %d have sended",worker.start_new_send_times);
// sleep(1);
//}
TBSYS_LOG(INFO, "over send start_new_schema now %d have sended",worker.start_new_send_times);
//all commond sended.
//mimic report
char buf1[10][30];
char buf2[10][30];
//const common::ObTabletInfo& tablet, const common::ObTabletLocation& location)
ObTabletReportInfoList report_list1;
ObTabletReportInfoList report_list2;
ObTabletReportInfo report_info;
ObTabletInfo info1;
ObTabletLocation location;
location.tablet_version_ = 0;
info1.range_.table_id_ = 10001;
info1.range_.border_flag_.set_inclusive_end();
info1.range_.border_flag_.unset_inclusive_start();
info1.range_.border_flag_.set_min_value();
info1.range_.border_flag_.unset_max_value();
info1.range_.start_key_.assign_buffer(buf1[0], 30);
info1.range_.end_key_.assign_buffer(buf2[0], 30);
info1.range_.start_key_.write("aa1", 3);
info1.range_.end_key_.write("ba1", 3);
location.chunkserver_ = server;
report_info.tablet_info_ = info1;
report_info.tablet_location_ = location;
report_list1.add_tablet(report_info);
//ASSERT_EQ(0,root_server.got_reported(info1, location)); //(,"ba1"] server
info1.range_.border_flag_.unset_min_value();
info1.range_.start_key_.assign_buffer(buf1[1], 30);
info1.range_.end_key_.assign_buffer(buf2[1], 30);
info1.range_.start_key_.write("ba1", 3);
info1.range_.end_key_.write("ca1", 3);
report_info.tablet_info_ = info1;
report_info.tablet_location_ = location;
report_list1.add_tablet(report_info);
ret = root_server->report_tablets(server, report_list1,time_stamp);
ASSERT_EQ(OB_SUCCESS, ret);
location.chunkserver_ = server2;
info1.range_.start_key_.assign_buffer(buf1[3], 30);
info1.range_.end_key_.assign_buffer(buf2[3], 30);
info1.range_.start_key_.write("da1", 3);
info1.range_.end_key_.write("ea1", 3);
report_info.tablet_info_ = info1;
report_info.tablet_location_ = location;
report_list2.add_tablet(report_info);
info1.range_.start_key_.assign_buffer(buf1[2], 30);
info1.range_.end_key_.assign_buffer(buf2[2], 30);
info1.range_.start_key_.write("ca1", 3);
info1.range_.end_key_.write("da1", 3);
report_info.tablet_info_ = info1;
report_info.tablet_location_ = location;
report_list2.add_tablet(report_info);
info1.range_.start_key_.assign_buffer(buf1[4], 30);
info1.range_.end_key_.assign_buffer(buf2[4], 30);
info1.range_.start_key_.write("ea1", 3);
info1.range_.end_key_.write("fa1", 3);
//.........这里部分代码省略.........
示例2: receive_file_pre
int ObFileService::receive_file_pre(ObFileAppender& file_appender,
int64_t& file_size, ObString& file_path, ObString& tmp_file_path,
easy_request_t* request, ObDataBuffer& in_buffer,
ObDataBuffer& out_buffer, int32_t& response_cid, const int64_t session_id)
{
int err = OB_SUCCESS;
if (OB_SUCCESS == err)
{
err = serialization::decode_i64(in_buffer.get_data(),
in_buffer.get_capacity(), in_buffer.get_position(), &file_size);
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "Decode file_info failed: err=[%d]", err);
}
}
char dest_dir_buf[OB_MAX_FILE_NAME_LENGTH];
ObString dest_dir;
dest_dir.assign_buffer(dest_dir_buf, sizeof(dest_dir_buf));
if (OB_SUCCESS == err)
{
err = dest_dir.deserialize(in_buffer.get_data(), in_buffer.get_capacity(),
in_buffer.get_position());
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "Decode dest_dir failed:err=[%d]", err);
}
}
char dest_file_name_buf[OB_MAX_FILE_NAME_LENGTH];
ObString dest_file_name;
dest_file_name.assign_buffer(dest_file_name_buf, sizeof(dest_file_name_buf));
if (OB_SUCCESS == err)
{
err = dest_file_name.deserialize(in_buffer.get_data(),
in_buffer.get_capacity(), in_buffer.get_position());
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "Decode dest_file_name failed:err=[%d]", err);
}
}
// check dir
if (OB_SUCCESS == err)
{
err = check_dir(dest_dir, file_size);
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "Check dir failed:err=[%d]", err);
}
}
// generate tmp_file_path and file_path
char file_path_buf[OB_MAX_FILE_NAME_LENGTH];
char tmp_file_path_buf[OB_MAX_FILE_NAME_LENGTH];
if (OB_SUCCESS == err)
{
const char tmp_file_prefix[]= "tmp_";
int64_t count = 0;
count = snprintf(file_path_buf, OB_MAX_FILE_NAME_LENGTH, "%.*s/%.*s",
dest_dir.length(), dest_dir.ptr(), dest_file_name.length(), dest_file_name.ptr());
if (count<0 || count >= OB_MAX_FILE_NAME_LENGTH)
{
err = OB_SIZE_OVERFLOW;
TBSYS_LOG(WARN, "snprintf file name failed, return[%ld] [%.*s]/[%.*s]",
count, dest_dir.length(), dest_dir.ptr(), dest_file_name.length(), dest_file_name.ptr());
}
count = file_path.write(file_path_buf,
static_cast<ObString::obstr_size_t>(strlen(file_path_buf)));
if (count != static_cast<int>(strlen(file_path_buf)))
{
err = OB_SIZE_OVERFLOW;
TBSYS_LOG(WARN, "Write file_path_buf to ObString failed");
}
count = snprintf(tmp_file_path_buf, OB_MAX_FILE_NAME_LENGTH, "%.*s/%s%.*s",
dest_dir.length(), dest_dir.ptr(), tmp_file_prefix, dest_file_name.length(), dest_file_name.ptr());
if (count <0 || count >= OB_MAX_FILE_NAME_LENGTH)
{
err = OB_SIZE_OVERFLOW;
TBSYS_LOG(WARN, "snprintf tmp file name failed, return[%ld] [%.*s]/[%s][%.*s]",
count, dest_dir.length(), dest_dir.ptr(), tmp_file_prefix, dest_file_name.length(), dest_file_name.ptr());
}
count = tmp_file_path.write(tmp_file_path_buf,
static_cast<ObString::obstr_size_t>(strlen(tmp_file_path_buf)));
if (count != static_cast<int>(strlen(tmp_file_path_buf)))
{
err = OB_SIZE_OVERFLOW;
TBSYS_LOG(WARN, "Write tmp_file_path_buf to ObString failed");
}
}
// check if the tmp_file and the dest file exist already
if (OB_SUCCESS == err)
{
if (0 == access(tmp_file_path_buf, F_OK))
//.........这里部分代码省略.........