public function preInsert(PropelPDO $con = null) { // set the dc ONLY if it wasnt initialized // this is required in the special case of file_sync import jobs which are created on one dc but run from the other // all other jobs run from the same datacenter they were created on. // setting the dc later results in a race condition were the job is picked up by the current datacenter before the dc value is changed if (is_null($this->dc) || !$this->isColumnModified(BatchJobPeer::DC)) { // by default set the dc to the current data center. However whenever a batch job is operating on an entry, we rather run it // in the DC where the file sync of the entry exists. Since the batch job doesnt refer to a flavor (we only have an entry id member) // we check the file sync of the source flavor asset (if one exists) $dc = kDataCenterMgr::getCurrentDcId(); $this->setDc($dc); } // if the status not set upon creation if (is_null($this->status) || !$this->isColumnModified(BatchJobPeer::STATUS)) { //echo "sets the status to " . self::BATCHJOB_STATUS_PENDING . "\n"; $this->setStatus(self::BATCHJOB_STATUS_PENDING); } return parent::preInsert($con); }