当前位置: 首页>>代码示例>>C++>>正文


C++ ns_sql::clear_query方法代码示例

本文整理汇总了C++中ns_sql::clear_query方法的典型用法代码示例。如果您正苦于以下问题:C++ ns_sql::clear_query方法的具体用法?C++ ns_sql::clear_query怎么用?C++ ns_sql::clear_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ns_sql的用法示例。


在下文中一共展示了ns_sql::clear_query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run_a_job

bool ns_processing_job_scheduler::run_a_job(ns_sql & sql,bool first_in_first_out_job_queue){
	//if we can't talk to the long term storage we're bound to fail, so don't try.
	image_server.image_storage.test_connection_to_long_term_storage(true);
	if (!image_server.image_storage.long_term_storage_was_recently_writeable())
		return false;
	ns_image_server_push_job_scheduler push_scheduler;

	ns_processing_job job = push_scheduler.request_job(sql,first_in_first_out_job_queue);
	
	if (job.id == 0)
		return false;
	
	//refresh flag labels from db
	ns_death_time_annotation_flag::get_flags_from_db(sql);

	if (job.maintenance_task == ns_maintenance_update_processing_job_queue){
		image_server.register_server_event(ns_image_server_event("Updating job queue"),&sql);

		sql << "DELETE from processing_jobs WHERE maintenance_task =" << ns_maintenance_update_processing_job_queue;
		sql.send_query();
		push_scheduler.report_job_as_finished(job,sql);
		push_scheduler.discover_new_jobs(sql);
		return true;		
	}

	ns_acquire_for_scope<ns_processing_job_processor> processor(
		ns_processing_job_processor_factory::generate(job,image_server,this->pipeline->pipeline));
		
	try{
		std::string rejection_reason;
		if (!processor().job_is_still_relevant(sql,rejection_reason)){
			image_server.register_server_event(ns_image_server_event("Encountered a processing job queue that had already been performed or invalidated: ") << rejection_reason << "[" << job.description() << "]",&sql);
			push_scheduler.report_job_as_finished(job,sql);
			if (processor().delete_job_after_processing())
				processor().delete_job(sql);
			processor.release();
			sql.send_query("COMMIT");
			return true;
		}
		if(idle_timer_running)
			image_server.performance_statistics.register_job_duration(ns_performance_statistics_analyzer::ns_idle,idle_timer.stop());
		idle_timer_running = false;
		ns_high_precision_timer tp;
		tp.start();

		//mark the subject as busy to prevent multiple jobs running simultaneously on the same data
		processor().mark_subject_as_busy(true,sql);
		sql.send_query("COMMIT");

		//update UI to show job is being performed, if requested.
		if (processor().flag_job_as_being_processed_before_processing())
			processor().flag_job_as_being_processed(sql);
		sql.send_query("COMMIT");

		if (processor().run_job(sql))
		processor().mark_subject_as_busy(false,sql);

		push_scheduler.report_job_as_finished(job,sql);
		sql.send_query("COMMIT");

		processor().handle_concequences_of_job_completion(sql);

		if (processor().delete_job_after_processing())
			processor().delete_job(sql);
		sql.send_query("COMMIT");

		processor.release();
		image_server.performance_statistics.register_job_duration(ns_performance_statistics_analyzer::ns_running_a_job,tp.stop());
		
		idle_timer_running = true;
		idle_timer.start();

		return true;
	}
	catch(ns_ex & ex){
		//we have found an error, handle it by registering it in the
		//host_event log, and annotate the current job (and any associated images)
		//with a reference to the error that occurred.
		sql.clear_query();
		
		processor().mark_subject_as_busy(false,sql);


		ns_64_bit error_id(push_scheduler.report_job_as_problem(job,ex,sql));
		sql.send_query("COMMIT");

		//there are a variety of problems that could cause an exception to be thrown.
		//only mark the image itself as problematic if the error doesn't come from 
		//any of the environmental problems that can crop up.
		bool problem_with_long_term_storage(!image_server.image_storage.long_term_storage_was_recently_writeable());
		if (!problem_with_long_term_storage &&
			ex.type() != ns_network_io && 
			ex.type() != ns_sql_fatal &&  
			ex.type() != ns_memory_allocation && 
			ex.type() != ns_cache)
			processor().mark_subject_as_problem(error_id,sql);

		image_server.performance_statistics.cancel_outstanding_jobs();
		if (ex.type() == ns_memory_allocation)
			throw;	//memory allocation errors can cause big, long-term problems, thus we need to pass
//.........这里部分代码省略.........
开发者ID:Ichoran,项目名称:lifespan,代码行数:101,代码来源:ns_processing_job_scheduler.cpp


注:本文中的ns_sql::clear_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。