private static function lockObjects(kExclusiveLockKey $lockKey, array $objects, $max_execution_time)
 {
     $exclusive_objects_ids = array();
     // make sure the objects where not taken -
     $con = Propel::getConnection();
     $not_exclusive_count = 0;
     foreach ($objects as $object) {
         $lock_version = $object->getVersion();
         $criteria_for_exclusive_update = new Criteria();
         $criteria_for_exclusive_update->add(BatchJobLockPeer::ID, $object->getId());
         $criteria_for_exclusive_update->add(BatchJobLockPeer::VERSION, $lock_version);
         $update = new Criteria();
         // increment the lock_version - this will make sure it's exclusive
         $update->add(BatchJobLockPeer::VERSION, $lock_version + 1);
         // increment the execution_attempts
         $update->add(BatchJobLockPeer::EXECUTION_ATTEMPTS, $object->getExecutionAttempts() + 1);
         $update->add(BatchJobLockPeer::SCHEDULER_ID, $lockKey->getSchedulerId());
         $update->add(BatchJobLockPeer::WORKER_ID, $lockKey->getWorkerId());
         $update->add(BatchJobLockPeer::BATCH_INDEX, $lockKey->getBatchIndex());
         $expiration = time() + $max_execution_time;
         $update->add(BatchJobLockPeer::EXPIRATION, $expiration);
         $affectedRows = BasePeer::doUpdate($criteria_for_exclusive_update, $update, $con);
         KalturaLog::log("Lock update affected rows [{$affectedRows}] on job id [" . $object->getId() . "] lock version [{$lock_version}]");
         if ($affectedRows == 1) {
             // fix the object to reflect what is in the DB
             $object->setVersion($lock_version + 1);
             $object->setExecutionAttempts($object->getExecutionAttempts() + 1);
             $object->setSchedulerId($lockKey->getSchedulerId());
             $object->setWorkerId($lockKey->getWorkerId());
             $object->setBatchIndex($lockKey->getBatchIndex());
             $object->setExpiration($expiration);
             KalturaLog::log("Job id [" . $object->getId() . "] locked and returned");
             PartnerLoadPeer::updatePartnerLoad($object->getPartnerId(), $object->getJobType(), $object->getJobSubType(), $con);
             $exclusive_objects_ids[] = $object->getId();
         } else {
             $not_exclusive_count++;
             KalturaLog::log("Object not exclusive: [" . get_class($object) . "] id [" . $object->getId() . "]");
         }
     }
     return BatchJobPeer::postLockUpdate($lockKey, $exclusive_objects_ids, $con);
 }