示例#1
0
void ASCHandler::chunk_file(std::string path)
{
	int flag = get_cost_time();
	int fd = open(path.c_str(), O_RDONLY);
	unsigned char buf[8192];
	int count;
	Chunker chunker;

	while ((count = read (fd, buf, 8192))>0)
	{
		chunker.chunk_data (buf, count);
	}
	chunker.stop ();

	std::string pa = "/tmp/asc_handler_" + SysOperation::get_type(path);

	for (unsigned i=0; i<chunker.chunk_vector().size(); i++)
	{
		chunk *c = chunker.chunk_vector()[i];
		SegInfo seg(c->hash(),									//hash
					SysOperation::get_type(path),				//type
					c->pos(),									//pos
					c->count(),									//size
					path);										//path
		write_seg_into_file(seg, pa);
		type.insert(std::make_pair(seg.type, 0)).first->second ++;
	}
	close(fd);
	chunk_time += get_cost_time() - flag;
}
示例#2
0
double ASCHandler::get_der_rate(std::string type)
{
	int flag = get_cost_time();
	DBCtrl::create_table("asc_" + type);
//	std::cout << DBCtrl::sum_of_size("asc_" + type, type) << std::endl;
	DBCtrl::load_infile("/tmp/asc_handler_" + type, "asc_" + type);
	double sum = DBCtrl::sum_of_size("asc_" + type, type);
	db_time += get_cost_time() - flag;
//	std::cout << sum << std::endl;
	dedup_size.insert(std::make_pair(type, sum)).first->second = sum;
	if(sum == 0) return -1;
	else return 1.0 * origin_size[type] / dedup_size[type];
}
示例#3
0
void HttpContext::print_access_log(std::string &client_ip) {
    std::string http_method = this->_req->_line.get_method();
    std::string request_url = this->_req->_line.get_request_url();
    int cost_time = get_cost_time();
    LOG_INFO("access_log %s %s status_code:%d cost_time:%d us, body_size:%d, client_ip:%s",
            http_method.c_str(), request_url.c_str(), _res->_code_msg.status_code,
            cost_time, _res->_body.size(), client_ip.c_str());
}