/**
  * Process an aggregate-type bucket.  This is MySQL specific.
  *
  * @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $oEnd);
     $rowCount = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($rowCount) {
         // We can't do bulk inserts with ON DUPLICATE.
         $aExecQueries = array();
         while ($rsData->fetch()) {
             // Get first row
             $aRow = $rsData->toArray();
             // Insert or update
             $aExecQueries[] = "SELECT bucket_update_{$sTableName}(" . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ")";
         }
         if (count($aExecQueries)) {
             foreach ($aExecQueries as $execQuery) {
                 $result = $oMainDbh->exec($execQuery);
                 if (PEAR::isError($result)) {
                     MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
             }
         }
     }
 }
 /**
  * Process an aggregate-type bucket.  This is MySQL specific.
  *
  * @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $oEnd);
     $rowCount = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($rowCount) {
         // We can't do bulk inserts with ON DUPLICATE.
         $aExecQueries = array();
         if ($rsData->fetch()) {
             // Get first row
             $aRow = $rsData->toArray();
             // Prepare INSERT
             $sInsert = "INSERT INTO {$sTableName} (" . join(',', array_keys($aRow)) . ") VALUES ";
             // Add first row data
             $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
             $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
             // Add first insert
             $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             // Deal with the other rows
             while ($rsData->fetch()) {
                 $aRow = $rsData->toArray();
                 $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
                 $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
                 $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             }
         }
         if (count($aExecQueries)) {
             // Try to disable the binlog for the inserts so we don't
             // replicate back out over our logged data.
             PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
             $result = $oMainDbh->exec('SET SQL_LOG_BIN = 0');
             if (PEAR::isError($result)) {
                 OA::debug('Unable to disable the bin log, proceeding anyway.', PEAR_LOG_WARNING);
             }
             PEAR::staticPopErrorHandling();
             foreach ($aExecQueries as $execQuery) {
                 $result = $oMainDbh->exec($execQuery);
                 if (PEAR::isError($result)) {
                     MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Keeps the reference of already installed components. In case
  * a recovery uninstall will need to be performed.
  *
  * @param Plugins_DeliveryLog $oComponent
  */
 function markComponentAsInstalled(Plugins_DeliveryLog $oComponent)
 {
     $this->aInstalledComponents[] = $oComponent->getComponentIdentifier();
 }
Example #4
0
 /**
  * Prepares a VALUES part of PostgreSQL stored procedure.
  *
  * @param array $aIgnore  List of columns to ignore (count is not included by default)
  * @return string  Comma separated VALUES list
  */
 protected function _getSPValuesList(Plugins_DeliveryLog $component, $aIgnore = array(Plugins_DeliveryLog::COUNT_COLUMN))
 {
     $values = '';
     $c = 1;
     $comma = '';
     $aColumns = $component->getBucketTableColumns();
     foreach ($aColumns as $columnName => $columnType) {
         if (in_array($columnName, $aIgnore)) {
             continue;
         }
         $values .= $comma . '$' . $c;
         $comma = ', ';
         $c++;
     }
     return $values;
 }
 function __construct()
 {
     // Conversion variable values are NOT aggregate
     $this->type = 'raw';
     parent::__construct();
 }
 public function getEarliestLoggedDataDate()
 {
     return parent::getEarliestLoggedDataDate('date_time');
 }
 public function getEarliestLoggedDataDate($sDateTimeColumn = 'date_time')
 {
     return parent::getEarliestLoggedDataDate('date_time');
 }