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


C++ LogRecord::Play方法代码示例

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


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

示例1: syncs

void
Transaction::Commit(FILE* fp, void *data_structure, bool nondurable)
{
	LogRecord *log;
	
	/*
	  We'd like to keep a backup of the job queue log on a local
	  filesystem in case writes, flushes, or syncs to the standard
	  job queue log fail.  Here's what we do:

	  1.  If there is a LOCAL_QUEUE_BACKUP_DIR parameter that
	  contains a valid directory name, then we will create a local
	  backup file in that directory with a unique name.  In this
	  case, we will assume that we might want a backup of the job
	  queue log.  (If not, we will not make a local backup;
	  proceed to #4.)
	  
	  2.  Every operation we do to the job queue log:  writes,
	  flushes, and syncs, we will also do to the local file.  We
	  will track the first error we see writing to the job queue
	  log and will stop writing to the actual job queue log -- but
	  not EXCEPT -- when we encounter the first error.

	  3.  Once we've completed writing log records, we will
	  unlink the local backup if there were no errors writing the
	  actual job queue log, *unless* the parameter
	  LOCAL_XACT_BACKUP_FILTER is set to "ALL".

	  4.  If there was a failure writing the actual job queue log,
	  we will then report (via EXCEPT) the first error we observed
	  while writing the actual job queue log, as well as the
	  location of the local backup file, if we made one.
	*/

	/* info about a backup:  do we keep one?  where is it?  etc. */
	backup_info_t bi;
	init_backup_info(&bi, (nondurable || fp == NULL));

	/* job queue log is element 0, backup file (if any) is
	   element 1 */
	stream_with_status_t fps[2];
	/* fps[0] will be the actual job queue log and fps[1] will be
	   the local backup.  If either file pointer is NULL, then
	   operations on that stream will be no-ops.  */
	init_stream_with_status(&(fps[0]), fp);
	init_stream_with_status(&(fps[1]), bi.fp);

	/* 
	   Do we want to keep local xact backups even if we
	   successfully wrote them to the actual log?
	*/
	bool fussy = bi.filt == BF_ALL;

	ordered_op_log.Rewind();

		// We're seeing sporadic test suite failures where 
		// CommitTransaction() appears to take a long time to
		// execute. Timing the I/O operations will help us
		// narrow down the cause
	time_t before, after;

	/*
	  We only go through the log once to avoid any interactions
	  with anything that happens to the log outside of this code
	  (or with the behavior of Rewind).
	 */

	while( (log = ordered_op_log.Next()) ) {
	  for (int i=0; i<2; i++) {
	    /* This call will only write to a file until it detects
	       the first error. */
	    before = time(NULL);
	    write_with_status(log, &(fps[i]));
		after = time(NULL);
		if ( (after - before) > 5 ) {
			dprintf( D_FULLDEBUG, "Transaction::Commit(): write_with_status() took %ld seconds to run\n", after - before );
		}
	  }

	  log->Play(data_structure);
	}

	if( !nondurable ) {
	  /* Note the change from the above:  we always want to flush
	     and sync the real job queue log, but we will only flush
	     and sync the local backup if we either (1) observed a
	     failure writing the log or (2) if we are keeping ALL
	     backups.

	     Here, we're operating on the real job queue log.
	  */
	  
	  before = time(NULL);
	  fflush_with_status(&(fps[0]));
	  after = time(NULL);
	  if ( (after - before) > 5 ) {
		  dprintf( D_FULLDEBUG, "Transaction::Commit(): fflush_with_status() took %ld seconds to run\n", after - before );
	  }

	  before = time(NULL);
//.........这里部分代码省略.........
开发者ID:AlanDeSmet,项目名称:htcondor,代码行数:101,代码来源:log_transaction.cpp


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