本文整理匯總了PHP中FileSyncPeer::clearInstancePool方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileSyncPeer::clearInstancePool方法的具體用法?PHP FileSyncPeer::clearInstancePool怎麽用?PHP FileSyncPeer::clearInstancePool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileSyncPeer
的用法示例。
在下文中一共展示了FileSyncPeer::clearInstancePool方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clearMemory
public function clearMemory()
{
accessControlPeer::clearInstancePool();
BatchJobPeer::clearInstancePool();
BulkUploadResultPeer::clearInstancePool();
categoryPeer::clearInstancePool();
EmailIngestionProfilePeer::clearInstancePool();
entryPeer::clearInstancePool();
FileSyncPeer::clearInstancePool();
flavorAssetPeer::clearInstancePool();
flavorParamsConversionProfilePeer::clearInstancePool();
flavorParamsOutputPeer::clearInstancePool();
flavorParamsPeer::clearInstancePool();
kshowPeer::clearInstancePool();
mediaInfoPeer::clearInstancePool();
moderationFlagPeer::clearInstancePool();
moderationPeer::clearInstancePool();
notificationPeer::clearInstancePool();
roughcutEntryPeer::clearInstancePool();
SchedulerConfigPeer::clearInstancePool();
SchedulerPeer::clearInstancePool();
SchedulerStatusPeer::clearInstancePool();
SchedulerWorkerPeer::clearInstancePool();
StorageProfilePeer::clearInstancePool();
syndicationFeedPeer::clearInstancePool();
TrackEntryPeer::clearInstancePool();
uiConfPeer::clearInstancePool();
UploadTokenPeer::clearInstancePool();
// TODO clear default filters
// TODO call all memory cleaner plugins
if (function_exists('gc_collect_cycles')) {
// php 5.3 and above
gc_collect_cycles();
}
}
示例2: lockPendingFileSyncsAction
/**
* batch lockPendingFileSyncs action locks file syncs for import by the file sync periodic worker
*
* @action lockPendingFileSyncs
* @param KalturaFileSyncFilter $filter
* @param int $workerId The id of the file sync import worker
* @param int $sourceDc The id of the DC from which the file syncs should be pulled
* @param int $maxCount The maximum number of file syncs that should be returned
* @param int $maxSize The maximum total size of file syncs that should be returned, this limit may be exceeded by one file sync
* @return KalturaLockFileSyncsResponse
*/
function lockPendingFileSyncsAction(KalturaFileSyncFilter $filter, $workerId, $sourceDc, $maxCount, $maxSize = null)
{
// need to explicitly disable the cache since this action may not perform any queries
kApiCache::disableConditionalCache();
// for dual dc deployments, if source dc is not specified, set it to the remote dc
if ($sourceDc < 0) {
$sourceDc = 1 - kDataCenterMgr::getCurrentDcId();
}
// get caches
$keysCache = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_QUERY_CACHE_KEYS);
if (!$keysCache) {
throw new KalturaAPIException(MultiCentersErrors::GET_KEYS_CACHE_FAILED);
}
$lockCache = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_LOCK_KEYS);
if (!$lockCache) {
throw new KalturaAPIException(MultiCentersErrors::GET_LOCK_CACHE_FAILED);
}
// get the max id / last id
$maxId = $keysCache->get(self::MAX_FILESYNC_ID_PREFIX . $sourceDc);
if (!$maxId) {
throw new KalturaAPIException(MultiCentersErrors::GET_MAX_FILESYNC_ID_FAILED, $sourceDc);
}
$initialLastId = $keysCache->get(self::LAST_FILESYNC_ID_PREFIX . $workerId);
KalturaLog::info("got lastId [{$initialLastId}] for worker [{$workerId}]");
$lastId = $initialLastId ? $initialLastId : $maxId;
// created at less than handled explicitly
$createdAtLessThanOrEqual = $filter->createdAtLessThanOrEqual;
$filter->createdAtLessThanOrEqual = null;
// build the criteria
$fileSyncFilter = new FileSyncFilter();
$filter->toObject($fileSyncFilter);
$baseCriteria = new Criteria();
$fileSyncFilter->attachToCriteria($baseCriteria);
$baseCriteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_PENDING);
$baseCriteria->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_FILE);
$baseCriteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
$baseCriteria->addAscendingOrderByColumn(FileSyncPeer::ID);
$baseCriteria->setLimit(self::MAX_FILESYNCS_PER_CHUNK);
$lockedFileSyncs = array();
$lockedFileSyncsSize = 0;
$limitReached = false;
$selectCount = 0;
$lastSelectId = 0;
$done = false;
while (!$done && $selectCount < self::MAX_FILESYNC_QUERIES_PER_CALL) {
// make sure last id is always increasing
if ($lastId <= $lastSelectId) {
KalturaLog::info("last id was decremented {$lastId} <= {$lastSelectId}, stopping");
break;
}
$lastSelectId = $lastId;
// clear the instance pool every once in a while (not clearing every time since
// some objects repeat between selects)
$selectCount++;
if ($selectCount % 5 == 0) {
FileSyncPeer::clearInstancePool();
}
// get a chunk of file syncs
// Note: starting slightly before the last id, because the ids may arrive out of order in the mysql replication
$c = clone $baseCriteria;
$idCriterion = $c->getNewCriterion(FileSyncPeer::ID, $lastId - 100, Criteria::GREATER_THAN);
$idCriterion->addAnd($c->getNewCriterion(FileSyncPeer::ID, $maxId, Criteria::LESS_THAN));
$c->addAnd($idCriterion);
// Note: disabling the criteria because it accumulates more and more criterions, and the status was already explicitly added
// once that bug is fixed, this can be removed
FileSyncPeer::setUseCriteriaFilter(false);
$fileSyncs = FileSyncPeer::doSelect($c);
FileSyncPeer::setUseCriteriaFilter(true);
if (!$fileSyncs) {
$lastId = $maxId;
break;
}
// if we got less than the limit no reason to perform any more queries
if (count($fileSyncs) < self::MAX_FILESYNCS_PER_CHUNK) {
$done = true;
}
$lastFileSync = end($fileSyncs);
$lastId = $lastFileSync->getId();
// filter by source dc
foreach ($fileSyncs as $index => $fileSync) {
if ($fileSync->getOriginalDc() != $sourceDc) {
unset($fileSyncs[$index]);
}
}
// filter by object type / sub type
$fileSyncs = array_filter($fileSyncs, array('FileSyncImportBatchService', 'shouldSyncFileObjectType'));
if (!$fileSyncs) {
continue;
}
//.........這裏部分代碼省略.........
示例3: doDelete
/**
* Method perform a DELETE on the database, given a FileSync or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or FileSync object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(FileSyncPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
FileSyncPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FileSync) {
// it's a model object
// invalidate the cache for this single object
FileSyncPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else {
// it's a primary key, or an array of pks
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(FileSyncPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
FileSyncPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0;
// initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
FileSyncPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例4: convertLinksToFiles
/**
* gets a source file of current DC, will make sure all links points to that source
* are converted to files on all DCs
*
* @param FileSyncKey $key
* @return void
*/
protected static function convertLinksToFiles(FileSync $fileSync)
{
$linkTotalCount = 0;
/* @var $fileSync FileSync */
// for each source, find its links and fix them
$c = new Criteria();
$c->add(FileSyncPeer::DC, $fileSync->getDc());
$c->add(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_LINK, FileSync::FILE_SYNC_FILE_TYPE_URL), Criteria::IN);
$c->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
$c->addAscendingOrderByColumn(FileSyncPeer::PARTNER_ID);
//relink the links into groups of 100 links
$c->setLimit(100);
$links = FileSyncPeer::doSelect($c);
//check if any links were returned in the do select if not no need to continue
if (!count($links)) {
return;
}
// choose the first link and convert it to file
$firstLink = array_shift($links);
/* @var $firstLink FileSync */
if ($firstLink) {
$firstLink->setStatus($fileSync->getStatus());
$firstLink->setFileSize($fileSync->getFileSize());
$firstLink->setFileRoot($fileSync->getFileRoot());
$firstLink->setFilePath($fileSync->getFilePath());
$firstLink->setFileType($fileSync->getFileType());
$firstLink->setLinkedId(0);
// keep it zero instead of null, that's the only way to know it used to be a link.
$firstLink->setIsDir($fileSync->getIsDir());
if (!is_null($fileSync->getOriginalDc())) {
$firstLink->setOriginalDc($fileSync->getOriginalDc());
$firstLink->unsetOriginalId();
// recalculate the original id when importing the file sync
}
$firstLink->save();
}
while (count($links)) {
// change all the rest of the links to point on the new file sync
foreach ($links as $link) {
$linkTotalCount += count($links);
/* @var $link FileSync */
$link->setStatus($fileSync->getStatus());
$link->setLinkedId($firstLink->getId());
$link->save();
}
FileSyncPeer::clearInstancePool();
$links = FileSyncPeer::doSelect($c);
}
if ($firstLink) {
$firstLink->setLinkCount($linkTotalCount);
$firstLink->save();
}
}
示例5: convertLinksToFiles
/**
* gets a source file of current DC, will make sure all links points to that source
* are converted to files on all DCs
*
* @param FileSyncKey $key
* @return void
*/
public static function convertLinksToFiles(FileSyncKey $key)
{
// fetch sources from all DCs
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$fileSyncList = FileSyncPeer::doSelect($c);
foreach ($fileSyncList as $fileSync) {
/* @var $fileSync FileSync */
// for each source, find its links and fix them
$c = new Criteria();
$c->add(FileSyncPeer::DC, $fileSync->getDc());
$c->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_LINK);
$c->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
$c->addAscendingOrderByColumn(FileSyncPeer::PARTNER_ID);
//relink the links into groups of 100 links
$c->setLimit(100);
$links = FileSyncPeer::doSelect($c);
while (count($links)) {
// choose the first link and convert it to file
$firstLink = array_shift($links);
/* @var $firstLink FileSync */
if ($firstLink) {
$firstLink->setStatus($fileSync->getStatus());
$firstLink->setFileSize($fileSync->getFileSize());
$firstLink->setFileRoot($fileSync->getFileRoot());
$firstLink->setFilePath($fileSync->getFilePath());
$firstLink->setWamsAssetId($fileSync->getWamsAssetId());
$firstLink->setWamsUrl($fileSync->getWamsUrl());
$firstLink->setFileType(FileSync::FILE_SYNC_FILE_TYPE_FILE);
$firstLink->setLinkedId(0);
// keep it zero instead of null, that's the only way to know it used to be a link.
$firstLink->setLinkCount(count($links));
$firstLink->save();
}
// change all the rest of the links to point on the new file sync
foreach ($links as $link) {
/* @var $link FileSync */
$link->setStatus($fileSync->getStatus());
$link->setLinkedId($firstLink->getId());
$link->save();
}
FileSyncPeer::clearInstancePool();
$links = FileSyncPeer::doSelect($c);
}
}
}
示例6: clearMemory
private function clearMemory()
{
entryPeer::clearInstancePool();
flavorAssetPeer::clearInstancePool();
FileSyncPeer::clearInstancePool();
categoryPeer::clearInstancePool();
if (class_exists('MetadataPeer')) {
MetadataPeer::clearInstancePool();
MetadataProfilePeer::clearInstancePool();
}
}
示例7: clearMemory
public static function clearMemory()
{
accessControlPeer::clearInstancePool();
kuserPeer::clearInstancePool();
kshowPeer::clearInstancePool();
entryPeer::clearInstancePool();
// kvotePeer::clearInstancePool();
// commentPeer::clearInstancePool();
// flagPeer::clearInstancePool();
// favoritePeer::clearInstancePool();
// KshowKuserPeer::clearInstancePool();
// MailJobPeer::clearInstancePool();
SchedulerPeer::clearInstancePool();
SchedulerWorkerPeer::clearInstancePool();
SchedulerStatusPeer::clearInstancePool();
SchedulerConfigPeer::clearInstancePool();
ControlPanelCommandPeer::clearInstancePool();
BatchJobPeer::clearInstancePool();
// PriorityGroupPeer::clearInstancePool();
BulkUploadResultPeer::clearInstancePool();
// blockedEmailPeer::clearInstancePool();
// conversionPeer::clearInstancePool();
// flickrTokenPeer::clearInstancePool();
PuserKuserPeer::clearInstancePool();
// PuserRolePeer::clearInstancePool();
PartnerPeer::clearInstancePool();
// WidgetLogPeer::clearInstancePool();
// adminKuserPeer::clearInstancePool();
// notificationPeer::clearInstancePool();
moderationPeer::clearInstancePool();
moderationFlagPeer::clearInstancePool();
roughcutEntryPeer::clearInstancePool();
// widgetPeer::clearInstancePool();
uiConfPeer::clearInstancePool();
// PartnerStatsPeer::clearInstancePool();
// PartnerActivityPeer::clearInstancePool();
ConversionProfilePeer::clearInstancePool();
// ConversionParamsPeer::clearInstancePool();
// KceInstallationErrorPeer::clearInstancePool();
FileSyncPeer::clearInstancePool();
accessControlPeer::clearInstancePool();
mediaInfoPeer::clearInstancePool();
assetParamsPeer::clearInstancePool();
assetParamsOutputPeer::clearInstancePool();
assetPeer::clearInstancePool();
conversionProfile2Peer::clearInstancePool();
flavorParamsConversionProfilePeer::clearInstancePool();
categoryPeer::clearInstancePool();
syndicationFeedPeer::clearInstancePool();
TrackEntryPeer::clearInstancePool();
// SystemUserPeer::clearInstancePool();
StorageProfilePeer::clearInstancePool();
// EmailIngestionProfilePeer::clearInstancePool();
UploadTokenPeer::clearInstancePool();
// invalidSessionPeer::clearInstancePool();
DynamicEnumPeer::clearInstancePool();
UserLoginDataPeer::clearInstancePool();
PermissionPeer::clearInstancePool();
UserRolePeer::clearInstancePool();
PermissionItemPeer::clearInstancePool();
PermissionToPermissionItemPeer::clearInstancePool();
KuserToUserRolePeer::clearInstancePool();
$pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaMemoryCleaner');
foreach ($pluginInstances as $pluginInstance) {
$pluginInstance->cleanMemory();
}
if (function_exists('gc_collect_cycles')) {
// php 5.3 and above
gc_collect_cycles();
}
}