本文整理汇总了PHP中kMemoryManager类的典型用法代码示例。如果您正苦于以下问题:PHP kMemoryManager类的具体用法?PHP kMemoryManager怎么用?PHP kMemoryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了kMemoryManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addInstanceToPool
/**
* Adds the supplied XML object to the instance pool.
*
* @param string $entryId
* @param SimpleXMLElement $xml
*/
protected static function addInstanceToPool($entryId, SimpleXMLElement $xml)
{
if (self::isInstancePoolingEnabled()) {
self::$instancesPool[$entryId] = $xml;
kMemoryManager::registerPeer('kMrssManager');
}
}
开发者ID:DBezemer,项目名称:server,代码行数:13,代码来源:kMrssManager.php
示例2: getFeedAction
/**
* @action getFeed
* @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
* @param int $distributionProfileId
* @param string $hash
* @return file
*/
public function getFeedAction($distributionProfileId, $hash)
{
if (!$this->getPartnerId() || !$this->getPartner()) {
throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
}
$profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
if (!$profile || !$profile instanceof SynacorHboDistributionProfile) {
throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
}
if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
}
if ($profile->getUniqueHashForFeedUrl() != $hash) {
throw new KalturaAPIException(SynacorHboDistributionErrors::INVALID_FEED_URL);
}
// "Creates advanced filter on distribution profile
$distributionAdvancedSearch = new ContentDistributionSearchFilter();
$distributionAdvancedSearch->setDistributionProfileId($profile->getId());
$distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
$distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
$distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE);
$distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false);
//Creates entry filter with advanced filter
$entryFilter = new entryFilter();
$entryFilter->setStatusEquel(entryStatus::READY);
$entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
$entryFilter->setPartnerSearchScope($this->getPartnerId());
$entryFilter->setAdvancedSearch($distributionAdvancedSearch);
$baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
$baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
$entryFilter->attachToCriteria($baseCriteria);
$entries = entryPeer::doSelect($baseCriteria);
$feed = new SynacorHboFeed('synacor_hbo_feed_template.xml');
$feed->setDistributionProfile($profile);
$counter = 0;
foreach ($entries as $entry) {
/* @var $entry entry */
$entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId());
if (!$entryDistribution) {
KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']');
continue;
}
$fields = $profile->getAllFieldValues($entryDistribution);
$flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
$thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds()));
$additionalAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getAssetIds()));
$feed->addItem($fields, $entry, $flavorAssets, $thumbAssets, $additionalAssets);
$counter++;
//to avoid the cache exceeding the memory size
if ($counter >= 100) {
kMemoryManager::clearMemory();
$counter = 0;
}
}
header('Content-Type: text/xml');
echo $feed->getXml();
die;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:65,代码来源:SynacorHboService.php
示例3: updateSunStatusAction
/**
* updates entry distribution sun status in the search engine
*
* @action updateSunStatus
*/
function updateSunStatusAction()
{
$updatedEntries = array();
// serach all records that their sun status changed to after sunset
$criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
$criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::READY);
$criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::AFTER_SUNSET, Criteria::NOT_EQUAL);
$crit1 = $criteria->getNewCriterion(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_THAN);
$criteria->add($crit1);
$entryDistributions = EntryDistributionPeer::doSelect($criteria);
foreach ($entryDistributions as $entryDistribution) {
/* @var $entryDistribution EntryDistribution */
$entryId = $entryDistribution->getEntryId();
if (isset($updatedEntries[$entryId])) {
continue;
}
$updatedEntries[$entryId] = true;
kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
// raise the updated events to trigger index in search engine (sphinx)
kEventsManager::flushEvents();
// save entry changes to sphinx
kMemoryManager::clearMemory();
}
$updatedEntries = array();
// serach all records that their sun status changed to after sunrise
$criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
$criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::QUEUED);
$criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::BEFORE_SUNRISE);
$criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_THAN);
$entryDistributions = EntryDistributionPeer::doSelect($criteria);
foreach ($entryDistributions as $entryDistribution) {
/* @var $entryDistribution EntryDistribution */
$entryId = $entryDistribution->getEntryId();
if (isset($updatedEntries[$entryId])) {
continue;
}
$updatedEntries[$entryId] = true;
kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
// raise the updated events to trigger index in search engine (sphinx)
kEventsManager::flushEvents();
// save entry changes to sphinx
kMemoryManager::clearMemory();
}
}
开发者ID:DBezemer,项目名称:server,代码行数:49,代码来源:ContentDistributionBatchService.php
示例4: getFeedAction
/**
* @action getFeed
* @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
* @param int $distributionProfileId
* @param string $hash
* @return file
*/
public function getFeedAction($distributionProfileId, $hash)
{
if (!$this->getPartnerId() || !$this->getPartner()) {
throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
}
$profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
if (!$profile || !$profile instanceof AttUverseDistributionProfile) {
throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
}
if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
}
if ($profile->getUniqueHashForFeedUrl() != $hash) {
throw new KalturaAPIException(AttUverseDistributionErrors::INVALID_FEED_URL);
}
// "Creates advanced filter on distribution profile
$distributionAdvancedSearch = new ContentDistributionSearchFilter();
$distributionAdvancedSearch->setDistributionProfileId($profile->getId());
$distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
$distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
$distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE);
$distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false);
//Creates entry filter with advanced filter
$entryFilter = new entryFilter();
$entryFilter->setStatusEquel(entryStatus::READY);
$entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
$entryFilter->setPartnerSearchScope($this->getPartnerId());
$entryFilter->setAdvancedSearch($distributionAdvancedSearch);
$baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
$baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
$entryFilter->attachToCriteria($baseCriteria);
$entries = entryPeer::doSelect($baseCriteria);
$feed = new AttUverseDistributionFeedHelper('feed_template.xml', $profile);
$channelTitle = $profile->getChannelTitle();
$counter = 0;
foreach ($entries as $entry) {
/* @var $entry entry */
/* @var $entryDistribution Entrydistribution */
$entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId());
if (!$entryDistribution) {
KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']');
continue;
}
$fields = $profile->getAllFieldValues($entryDistribution);
//flavors assets and remote flavor asset file urls
$flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS)));
$remoteAssetFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS));
//thumb assets and remote thumb asset file urls
$thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS)));
$remoteThumbailFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS));
//thumb assets and remote thumb asset file urls
$captionAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS)));
$feed->addItem($fields, $flavorAssets, $remoteAssetFileUrls, $thumbAssets, $remoteThumbailFileUrls, $captionAssets);
$counter++;
//to avoid the cache exceeding the memory size
if ($counter >= 100) {
kMemoryManager::clearMemory();
$counter = 0;
}
}
//set channel title
if (isset($fields)) {
$channelTitle = $fields[AttUverseDistributionField::CHANNEL_TITLE];
}
$feed->setChannelTitle($channelTitle);
header('Content-Type: text/xml');
echo str_replace('&', '&', html_entity_decode($feed->getXml(), ENT_QUOTES, 'UTF-8'));
die;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:76,代码来源:AttUverseService.php
示例5: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param LiveChannelSegment $value A LiveChannelSegment object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(LiveChannelSegment $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
// if key === null
self::$instances[$key] = $obj;
kMemoryManager::registerPeer('LiveChannelSegmentPeer');
}
}
开发者ID:DBezemer,项目名称:server,代码行数:23,代码来源:BaseLiveChannelSegmentPeer.php
示例6: writeBulkUploadLogFile
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
*/
public static function writeBulkUploadLogFile($batchJob)
{
if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadCsvType::CSV)) {
return;
}
header("Content-Type: text/plain; charset=UTF-8");
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
die("Log file is not ready");
}
$STDOUT = fopen('php://output', 'w');
$data = $batchJob->getData();
/* @var $data kBulkUploadJobData */
//Add header row to the output CSV only if partner level permission for it exists
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
if (PermissionPeer::isValidForPartner(self::FEATURE_CSV_HEADER_ROW, $partnerId)) {
$headerRow = $data->getColumns();
$headerRow[] = "resultStatus";
$headerRow[] = "objectId";
$headerRow[] = "objectStatus";
$headerRow[] = "errorDescription";
fputcsv($STDOUT, $headerRow);
}
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$values = str_getcsv($bulkUploadResult->getRowData());
// switch ($bulkUploadResult->getObjectType())
// {
// case BulkUploadObjectType::ENTRY:
// $values = self::writeEntryBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::CATEGORY:
// $values = self::writeCategoryBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::CATEGORY_USER:
// $values = self::writeCategoryUserBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::USER:
// $values = self::writeUserBulkUploadResults($bulkUploadResult, $data);
// break;
// default:
//
// break;
// }
$values[] = $bulkUploadResult->getStatus();
$values[] = $bulkUploadResult->getObjectId();
$values[] = $bulkUploadResult->getObjectStatus();
$values[] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription());
fputcsv($STDOUT, $values);
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
fclose($STDOUT);
kFile::closeDbConnections();
exit;
}
开发者ID:kubrickfr,项目名称:server,代码行数:72,代码来源:BulkUploadCsvPlugin.php
示例7: handleMultiRequest
public function handleMultiRequest()
{
// arrange the parameters by request index
$commonParams = array();
$listOfRequests = array();
$dependencies = array();
$allDependencies = array();
$pastResults = array();
foreach ($this->params as $paramName => $paramValue) {
$explodedName = explode(':', $paramName, 2);
if (count($explodedName) <= 1 || !is_numeric($explodedName[0])) {
$commonParams[$paramName] = $paramValue;
continue;
}
$requestIndex = (int) $explodedName[0];
$paramName = $explodedName[1];
if (!array_key_exists($requestIndex, $listOfRequests)) {
$listOfRequests[$requestIndex] = array();
}
$listOfRequests[$requestIndex][$paramName] = $paramValue;
$matches = array();
if (preg_match('/\\{([0-9]*)\\:result\\:?(.*)?\\}/', $paramValue, $matches)) {
$pastResultsIndex = $matches[0];
$resultIndex = $matches[1];
$resultKey = $matches[2];
if (!isset($dependencies[$requestIndex][$pastResultsIndex])) {
$dependencies[$resultIndex][$pastResultsIndex] = $resultKey;
}
$allDependencies[$pastResultsIndex] = true;
}
}
// process the requests
$results = array();
for ($i = 1; isset($listOfRequests[$i]); $i++) {
$currentParams = $listOfRequests[$i];
if (!isset($currentParams["service"]) || !isset($currentParams["action"])) {
break;
}
kCurrentContext::$multiRequest_index = $i;
$currentService = $currentParams["service"];
$currentAction = $currentParams["action"];
// copy derived common params to current params
if (isset($commonParams['clientTag']) && !isset($currentParams['clientTag'])) {
$currentParams['clientTag'] = $commonParams['clientTag'];
}
if (isset($commonParams['ks']) && !isset($currentParams['ks'])) {
$currentParams['ks'] = $commonParams['ks'];
}
if (isset($commonParams['partnerId']) && !isset($currentParams['partnerId'])) {
$currentParams['partnerId'] = $commonParams['partnerId'];
}
// check if we need to replace params with prev results
foreach ($currentParams as $key => &$val) {
if (isset($pastResults[$val])) {
$val = $pastResults[$val];
} else {
if (isset($allDependencies[$val])) {
$val = null;
}
}
}
// cached parameters should be different when the request is part of a multirequest
// as part of multirequest - the cached data is a serialized php object
// when not part of multirequest - the cached data is the actual response
$currentParams['multirequest'] = true;
unset($currentParams['format']);
$cache = new KalturaResponseCacher($currentParams);
$success = true;
$errorCode = null;
$this->onRequestStart($currentService, $currentAction, $currentParams, $i, true);
$cachedResult = $cache->checkCache('X-Kaltura-Part-Of-MultiRequest');
if ($cachedResult) {
$currentResult = unserialize($cachedResult);
} else {
if ($i != 1) {
kMemoryManager::clearMemory();
KalturaCriterion::clearTags();
}
try {
$currentResult = $this->dispatcher->dispatch($currentService, $currentAction, $currentParams);
} catch (Exception $ex) {
$success = false;
$errorCode = $ex->getCode();
$currentResult = $this->getExceptionObject($ex, $currentService, $currentAction);
}
$cache->storeCache($currentResult, "", true);
}
$this->onRequestEnd($success, $errorCode, $i);
if (isset($dependencies[$i])) {
foreach ($dependencies[$i] as $currentDependency => $dependencyName) {
if (strlen(trim($dependencyName)) > 0) {
$resultPathArray = explode(":", $dependencyName);
} else {
$resultPathArray = array();
}
$currValue = $this->getValueFromObject($currentResult, $resultPathArray);
$pastResults[$currentDependency] = $currValue;
}
}
$results[$i] = $this->serializer->serialize($currentResult);
//.........这里部分代码省略.........
开发者ID:kubrickfr,项目名称:server,代码行数:101,代码来源:KalturaFrontController.php
示例8: execute
public function execute()
{
$jobId = $this->getRequestParameter("id");
$partnerId = $this->getRequestParameter("pid");
$type = $this->getRequestParameter("type");
$c = new Criteria();
$c->addAnd(BatchJobPeer::ID, $jobId);
$c->addAnd(BatchJobPeer::PARTNER_ID, $partnerId);
$c->addAnd(BatchJobPeer::JOB_TYPE, BatchJobType::BULKUPLOAD);
$batchJob = BatchJobPeer::doSelectOne($c);
if (!$batchJob) {
die("File not found");
}
header("Content-Type: text/plain; charset=UTF-8");
if ($type == "log") {
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $jobId);
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
die("Log file is not ready");
}
$STDOUT = fopen('php://output', 'w');
$data = $batchJob->getData();
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
foreach ($bulkUploadResults as $bulkUploadResult) {
$values = array($bulkUploadResult->getTitle(), $bulkUploadResult->getDescription(), $bulkUploadResult->getTags(), $bulkUploadResult->getUrl(), $bulkUploadResult->getContentType());
if ($data instanceof kBulkUploadCsvJobData && $data->getCsvVersion() > 1) {
$values[] = $bulkUploadResult->getConversionProfileId();
$values[] = $bulkUploadResult->getAccessControlProfileId();
$values[] = $bulkUploadResult->getCategory();
$values[] = $bulkUploadResult->getScheduleStartDate('Y-m-d\\TH:i:s');
$values[] = $bulkUploadResult->getScheduleEndDate('Y-m-d\\TH:i:s');
$values[] = $bulkUploadResult->getThumbnailUrl();
$values[] = $bulkUploadResult->getPartnerData();
}
$values[] = $bulkUploadResult->getEntryId();
$values[] = $bulkUploadResult->getEntryStatus();
$values[] = $bulkUploadResult->getErrorDescription();
fputcsv($STDOUT, $values);
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
fclose($STDOUT);
} else {
$syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
if (kFileSyncUtils::file_exists($syncKey, true)) {
$content = kFileSyncUtils::file_get_contents($syncKey, true);
echo $content;
die;
} else {
die("File not found");
}
}
die;
// no template needed
}
开发者ID:DBezemer,项目名称:server,代码行数:65,代码来源:bulkuploadfileAction.class.php
示例9: deleteOldVersionedFileSyncs
//.........这里部分代码省略.........
case FileSyncObjectType::ASSET:
if ($objectSubType != asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET) {
return array();
}
$join = new Join();
$join->addCondition(FileSyncPeer::OBJECT_ID, assetPeer::ID);
$join->addCondition(FileSyncPeer::VERSION, assetPeer::VERSION, Criteria::NOT_EQUAL);
$join->setJoinType(Criteria::LEFT_JOIN);
$criteria->addJoinObject($join);
$criteria->add(assetPeer::VERSION, null, Criteria::ISNOTNULL);
break;
case FileSyncObjectType::UICONF:
$join = new Join();
$join->addCondition(FileSyncPeer::OBJECT_ID, uiConfPeer::ID);
$join->addCondition(FileSyncPeer::VERSION, uiConfPeer::VERSION, Criteria::NOT_EQUAL);
$join->setJoinType(Criteria::LEFT_JOIN);
$criteria->addJoinObject($join);
$criteria->add(uiConfPeer::VERSION, null, Criteria::ISNOTNULL);
break;
case FileSyncObjectType::ENTRY:
$join = new Join();
$join->addCondition(FileSyncPeer::OBJECT_ID, entryPeer::ID);
switch ($objectSubType) {
case entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB:
$join->addCondition(FileSyncPeer::VERSION, entryPeer::THUMBNAIL, Criteria::NOT_EQUAL);
$criteria->add(entryPeer::THUMBNAIL, null, Criteria::ISNOTNULL);
break;
case entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA:
case entry::FILE_SYNC_ENTRY_SUB_TYPE_DOWNLOAD:
$join->addCondition(FileSyncPeer::VERSION, entryPeer::DATA, Criteria::NOT_EQUAL);
$criteria->add(entryPeer::DATA, null, Criteria::ISNOTNULL);
break;
default:
return array();
}
$join->setJoinType(Criteria::LEFT_JOIN);
$criteria->addJoinObject($join);
break;
case FileSyncObjectType::METADATA:
$join = new Join();
$join->addCondition(FileSyncPeer::OBJECT_ID, MetadataPeer::ID);
$join->addCondition(FileSyncPeer::VERSION, MetadataPeer::VERSION, Criteria::NOT_EQUAL);
$join->setJoinType(Criteria::LEFT_JOIN);
$criteria->addJoinObject($join);
$criteria->add(MetadataPeer::VERSION, null, Criteria::ISNOTNULL);
break;
case FileSyncObjectType::METADATA_PROFILE:
$join = new Join();
$join->addCondition(FileSyncPeer::OBJECT_ID, MetadataProfilePeer::ID);
switch ($objectSubType) {
case MetadataProfile::FILE_SYNC_METADATA_DEFINITION:
$join->addCondition(FileSyncPeer::VERSION, MetadataProfilePeer::FILE_SYNC_VERSION, Criteria::NOT_EQUAL);
$criteria->add(MetadataProfilePeer::FILE_SYNC_VERSION, null, Criteria::ISNOTNULL);
break;
case MetadataProfile::FILE_SYNC_METADATA_VIEWS:
$join->addCondition(FileSyncPeer::VERSION, MetadataProfilePeer::VIEWS_VERSION, Criteria::NOT_EQUAL);
$criteria->add(MetadataProfilePeer::VIEWS_VERSION, null, Criteria::ISNOTNULL);
break;
default:
return array();
}
$join->setJoinType(Criteria::LEFT_JOIN);
$criteria->addJoinObject($join);
break;
default:
return array();
}
$criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
$criteria->add(FileSyncPeer::OBJECT_TYPE, $objectType);
$criteria->add(FileSyncPeer::OBJECT_SUB_TYPE, $objectSubType);
$criteria->add(FileSyncPeer::STATUS, array(FileSync::FILE_SYNC_STATUS_DELETED, FileSync::FILE_SYNC_STATUS_PURGED), Criteria::NOT_IN);
$nextCriteria = clone $criteria;
$criteria->add(FileSyncPeer::UPDATED_AT, self::$oldVersionsStartUpdatedAt[$objectType], Criteria::GREATER_EQUAL);
$criteria->addAnd(FileSyncPeer::UPDATED_AT, self::$oldVersionsEndUpdatedAt[$objectType], Criteria::LESS_EQUAL);
$criteria->addAscendingOrderByColumn(FileSyncPeer::UPDATED_AT);
$criteria->setLimit(self::$queryLimit);
$fileSyncs = FileSyncPeer::doSelect($criteria);
if (count($fileSyncs)) {
foreach ($fileSyncs as $fileSync) {
/* @var $fileSync FileSync */
self::deleteFileSync($fileSync);
if ($fileSync->getUpdatedAt(null)) {
self::$oldVersionsNextStartUpdatedAt[$objectType] = $fileSync->getUpdatedAt(null);
}
}
} else {
self::$oldVersionsNextStartUpdatedAt[$objectType] = self::$oldVersionsStartUpdatedAt[$objectType];
$nextCriteria->add(FileSyncPeer::UPDATED_AT, self::$oldVersionsStartUpdatedAt[$objectType], Criteria::GREATER_THAN);
$nextCriteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
$stmt = FileSyncPeer::doSelectStmt($nextCriteria);
$mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (count($mins)) {
$oldVersionsNextStartUpdatedAt = reset($mins);
if (!is_null($oldVersionsNextStartUpdatedAt)) {
self::$oldVersionsNextStartUpdatedAt[$objectType] = $oldVersionsNextStartUpdatedAt;
}
}
}
kMemoryManager::clearMemory();
}
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:deleteOldContent.php
示例10: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param PartnerLoad $value A PartnerLoad object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(PartnerLoad $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = serialize(array((string) $obj->getJobType(), (string) $obj->getJobSubType(), (string) $obj->getPartnerId(), (string) $obj->getDc()));
}
if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
self::$instances[$key] = $obj;
kMemoryManager::registerPeer('PartnerLoadPeer');
}
}
}
开发者ID:DBezemer,项目名称:server,代码行数:24,代码来源:BasePartnerLoadPeer.php
示例11: getBulkUploadMrssXml
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
* @return SimpleXMLElement
*/
public static function getBulkUploadMrssXml($batchJob)
{
$actionsMap = array(BulkUploadAction::ADD => 'add', BulkUploadAction::UPDATE => 'update', BulkUploadAction::DELETE => 'delete');
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
return null;
}
header("Content-Type: text/xml; charset=UTF-8");
$data = $batchJob->getData();
$xmlElement = new SimpleXMLElement('<mrss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>');
$xmlElement->addAttribute('version', '2.0');
$channel = $xmlElement->addChild('channel');
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
// insert all entries to instance pool
$pks = array();
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$pks[] = $bulkUploadResult->getEntryId();
}
entryPeer::retrieveByPKs($pks);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$item = $channel->addChild('item');
$result = $item->addChild('result');
$result->addChild('errorDescription', self::stringToSafeXml($bulkUploadResult->getErrorDescription()));
// $result->addChild('entryStatus', self::stringToSafeXml($bulkUploadResult->getEntryStatus()));
// $result->addChild('entryStatusName', self::stringToSafeXml($title));
$action = isset($actionsMap[$bulkUploadResult->getAction()]) ? $actionsMap[$bulkUploadResult->getAction()] : $actionsMap[BulkUploadAction::ADD];
$item->addChild('action', $action);
$entry = $bulkUploadResult->getObject();
if (!$entry) {
continue;
}
kMrssManager::getEntryMrssXml($entry, $item);
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
return $xmlElement;
}
开发者ID:DBezemer,项目名称:server,代码行数:55,代码来源:BulkUploadXmlPlugin.php
示例12: updateBulkUploadResultsAction
/**
* batch updateBulkUploadResults action adds KalturaBulkUploadResult to the DB
*
* @action updateBulkUploadResults
* @param int $bulkUploadJobId The id of the bulk upload job
* @return int the number of unclosed entries
*/
function updateBulkUploadResultsAction($bulkUploadJobId)
{
$unclosedEntriesCount = 0;
$errorObjects = 0;
$unclosedEntries = array();
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $bulkUploadJobId);
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUpload = BatchJobPeer::retrieveByPK($bulkUploadJobId);
if ($bulkUpload) {
$handledResults = 0;
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$status = $bulkUploadResult->updateStatusFromObject();
if ($status == BulkUploadResultStatus::IN_PROGRESS) {
$unclosedEntriesCount++;
}
if ($status == BulkUploadResultStatus::ERROR) {
$errorObjects++;
}
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
$data = $bulkUpload->getData();
if ($data && $data instanceof kBulkUploadJobData) {
//TODO: find some better alternative, find out why the bulk upload result which reports error is
// returning objectId "null" for failed entry assets, rather than the entryId to which they pertain.
//$data->setNumOfEntries(BulkUploadResultPeer::countWithEntryByBulkUploadId($bulkUploadJobId));
$data->setNumOfObjects(BulkUploadResultPeer::countWithObjectTypeByBulkUploadId($bulkUploadJobId, $data->getBulkUploadObjectType()));
$data->setNumOfErrorObjects($errorObjects);
$bulkUpload->setData($data);
$bulkUpload->save();
}
}
return $unclosedEntriesCount;
}
开发者ID:AdiTal,项目名称:server,代码行数:52,代码来源:BatchService.php
示例13: handleMultiRequest
//.........这里部分代码省略.........
// remove the request number
$requestKey = implode(":", $keyArray);
/* remarked by Dor - 13/10/2010
* There is no need to remove service and action from the params in case of multirequest
* while they are needed in KalturaResponseCacher
if (in_array($requestKey, array("service", "action"))) // don't add service name and action name to the params
continue;
*/
$listOfRequests[$i]["params"][$requestKey] = $val;
// store the param
}
}
// clientTag param might be used in KalturaResponseCacher
if (isset($this->params['clientTag']) && !isset($listOfRequests[$i]["params"]['clientTag'])) {
$listOfRequests[$i]["params"]['clientTag'] = $this->params['clientTag'];
}
// if ks is not set for a specific request, copy the ks from the top params
$currentKs = isset($listOfRequests[$i]["params"]["ks"]) ? $listOfRequests[$i]["params"]["ks"] : null;
if (!$currentKs) {
$mainKs = isset($this->params["ks"]) ? $this->params["ks"] : null;
if ($mainKs) {
$listOfRequests[$i]["params"]["ks"] = $mainKs;
}
}
$currentPartner = isset($listOfRequests[$i]["params"]["partnerId"]) ? $listOfRequests[$i]["params"]["partnerId"] : null;
if (!$currentPartner) {
$mainPartner = isset($this->params["partnerId"]) ? $this->params["partnerId"] : null;
if ($mainPartner) {
$listOfRequests[$i]["params"]["partnerId"] = $mainPartner;
}
}
$i++;
} else {
// will break the loop
}
}
$i = 1;
foreach ($listOfRequests as $currentRequest) {
kCurrentContext::$multiRequest_index = $i;
$currentService = $currentRequest["service"];
$currentAction = $currentRequest["action"];
$currentParams = $currentRequest["params"];
// check if we need to replace params with prev results
foreach ($currentParams as $key => &$val) {
$matches = array();
// keywords: multirequest, result, depend, pass
// figuring out if requested params should be extracted from previous result
// example: if you want to use KalturaPlaylist->playlistContent result from the first request
// in your second request, the second request will contain the following value:
// {1:result:playlistContent}
if (preg_match('/\\{([0-9]*)\\:result\\:?(.*)?\\}/', $val, $matches)) {
$resultIndex = $matches[1];
$resultKey = $matches[2];
if (count($results) >= $resultIndex) {
if (strlen(trim($resultKey)) > 0) {
$resultPathArray = explode(":", $resultKey);
} else {
$resultPathArray = array();
}
$val = $this->getValueFromObject($results[$resultIndex], $resultPathArray);
}
}
}
// cached parameters should be different when the request is part of a multirequest
// as part of multirequest - the cached data is a serialized php object
// when not part of multirequest - the cached data is the actual response
$currentParams['multirequest'] = true;
unset($currentParams['format']);
$cache = new KalturaResponseCacher($currentParams);
if (!isset($currentParams['ks']) && kCurrentContext::$ks) {
$cache->setKS(kCurrentContext::$ks);
}
$success = true;
$errorCode = null;
$this->onRequestStart($currentService, $currentAction, $currentParams, $i, true);
$cachedResult = $cache->checkCache('X-Kaltura-Part-Of-MultiRequest');
if ($cachedResult) {
$currentResult = unserialize($cachedResult);
} else {
if ($i != 1) {
kMemoryManager::clearMemory();
KalturaCriterion::clearTags();
}
try {
$currentResult = $this->dispatcher->dispatch($currentService, $currentAction, $currentParams);
} catch (Exception $ex) {
$success = false;
$errorCode = $ex->getCode();
$currentResult = $this->getExceptionObject($ex);
}
$cache->storeCache($currentResult, "", true);
}
$this->onRequestEnd($success, $errorCode, $i);
$results[$i] = $currentResult;
$i++;
}
return $results;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:101,代码来源:KalturaFrontController.php
示例14: writeBulkUploadLogFile
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
*/
public static function writeBulkUploadLogFile($batchJob)
{
if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadFilterType::FILTER)) {
return;
}
//TODO:
header("Content-Type: text/plain; charset=UTF-8");
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
die("Log file is not ready");
}
$STDOUT = fopen('php://output', 'w');
$data = $batchJob->getData();
/* @var $data kBulkUploadFilterJobData */
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
foreach ($bulkUploadResults as $bulkUploadResult) {
$values = array();
$values['bulkUploadResultStatus'] = $bulkUploadResult->getStatus();
$values['objectId'] = $bulkUploadResult->getObjectId();
$values['objectStatus'] = $bulkUploadResult->getObjectStatus();
$values['errorDescription'] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription());
fwrite($STDOUT, print_r($values, true));
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
fclose($STDOUT);
kFile::closeDbConnections();
exit;
}
开发者ID:DBezemer,项目名称:server,代码行数:44,代码来源:BulkUploadFilterPlugin.php
示例15: handleMultiRequest
public function handleMultiRequest()
{
// arrange the parameters by request inde
|
请发表评论