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


C++ LogEntry::size方法代码示例

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


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

示例1: WriteEntry

VXIlogResult OSBlog::WriteEntry(const LogEntry &entry, bool logToStdout)
{
    if (((! gblLogFile) && (! gblLogToStdout)) || (entry.size() < 1))
        return VXIlog_RESULT_SUCCESS;

    // Convert to narrow characters
    unsigned int i;
    unsigned int n = entry.size();
    const wchar_t *ptr = entry.Entry();
    char outbuf[MAX_LOG_BUFFER];
    for(i=0; i<n; i++)
        outbuf[i] = w2c(ptr[i]);
    outbuf[i] = '\0';

    // Lock and write out the log entry
    if (VXItrdMutexLock(gblLogMutex) != VXItrd_RESULT_SUCCESS)
        return VXIlog_RESULT_SYSTEM_ERROR;

    VXIlogResult rc = VXIlog_RESULT_SUCCESS;
    if (gblLogFile) {
        if (fwrite(outbuf, sizeof(char), n, gblLogFile) < 1) {
            // should disable logging.
            rc = VXIlog_RESULT_IO_ERROR;
        } else {
            // to ensure we don't lose log lines on a crash/abort
            fflush(gblLogFile);
        }
    }

    if (gblLogToStdout && logToStdout &&
            (fwrite(outbuf, sizeof(char), n, stdout) < 1 || fflush(stdout) != 0))
        rc = VXIlog_RESULT_IO_ERROR;

    if (VXItrdMutexUnlock(gblLogMutex) != VXItrd_RESULT_SUCCESS)
        rc = VXIlog_RESULT_SYSTEM_ERROR;

    return rc;
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例2: exitHandler

void
BackupRestore::logEntry(const LogEntry & tup)
{
  if (!m_restore)
    return;

  NdbTransaction * trans = m_ndb->startTransaction();
  if (trans == NULL) 
  {
    // Deep shit, TODO: handle the error
    err << "Cannot start transaction" << endl;
    exitHandler();
  } // if
  
  const NdbDictionary::Table * table = get_table(tup.m_table->m_dictTable);
  NdbOperation * op = trans->getNdbOperation(table);
  if (op == NULL) 
  {
    err << "Cannot get operation: " << trans->getNdbError() << endl;
    exitHandler();
  } // if
  
  int check = 0;
  switch(tup.m_type)
  {
  case LogEntry::LE_INSERT:
    check = op->insertTuple();
    break;
  case LogEntry::LE_UPDATE:
    check = op->updateTuple();
    break;
  case LogEntry::LE_DELETE:
    check = op->deleteTuple();
    break;
  default:
    err << "Log entry has wrong operation type."
	   << " Exiting...";
    exitHandler();
  }

  if (check != 0) 
  {
    err << "Error defining op: " << trans->getNdbError() << endl;
    exitHandler();
  } // if
  
  Bitmask<4096> keys;
  for (Uint32 i= 0; i < tup.size(); i++) 
  {
    const AttributeS * attr = tup[i];
    int size = attr->Desc->size;
    int arraySize = attr->Desc->arraySize;
    const char * dataPtr = attr->Data.string_value;
    
    if (tup.m_table->have_auto_inc(attr->Desc->attrId))
      tup.m_table->update_max_auto_val(dataPtr,size*arraySize);

    const Uint32 length = (size / 8) * arraySize;
    if (attr->Desc->m_column->getPrimaryKey())
    {
      if(!keys.get(attr->Desc->attrId))
      {
	keys.set(attr->Desc->attrId);
	check= op->equal(attr->Desc->attrId, dataPtr, length);
      }
    }
    else
      check= op->setValue(attr->Desc->attrId, dataPtr, length);
    
    if (check != 0) 
    {
      err << "Error defining op: " << trans->getNdbError() << endl;
      exitHandler();
    } // if
  }
  
  const int ret = trans->execute(NdbTransaction::Commit);
  if (ret != 0)
  {
    // Both insert update and delete can fail during log running
    // and it's ok
    // TODO: check that the error is either tuple exists or tuple does not exist?
    bool ok= false;
    NdbError errobj= trans->getNdbError();
    switch(tup.m_type)
    {
    case LogEntry::LE_INSERT:
      if(errobj.status == NdbError::PermanentError &&
	 errobj.classification == NdbError::ConstraintViolation)
	ok= true;
      break;
    case LogEntry::LE_UPDATE:
    case LogEntry::LE_DELETE:
      if(errobj.status == NdbError::PermanentError &&
	 errobj.classification == NdbError::NoDataFound)
	ok= true;
      break;
    }
    if (!ok)
    {
//.........这里部分代码省略.........
开发者ID:isleon,项目名称:Jaxer,代码行数:101,代码来源:consumer_restore.cpp


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