Skip to content

Commit

Permalink
changes to support querying if entry is live omitting MARKED_FOR_DELE…
Browse files Browse the repository at this point in the history
…TION
  • Loading branch information
lilachmaliniak committed Oct 6, 2016
1 parent 171e35b commit e45483e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
20 changes: 16 additions & 4 deletions lib/BackendClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ var BackendClient = (function(){
var filter = new kalturaVO.KalturaLiveStreamEntryFilter();
filter.isLive = kalturaTypes.KalturaNullableBoolean.TRUE_VALUE;
filter.hasMediaServerHostname = mediaServerHostname;
filter.statusIn = '1,2,3';
var pager = {
pageSize : 300,
pageIndex : 1
Expand Down Expand Up @@ -270,10 +271,10 @@ var BackendClient = (function(){
return deferred.promise;
}

function getLiveEntryServerNodes(entryId) {
function getLiveEntryServerNodes(entryId, filter) {
var deferred = Q.defer();
logger.debug("[%s] Retrieve entry server node list", entryId);
var entryServerNodeFilter = new kalturaVO.KalturaEntryServerNodeFilter();
var entryServerNodeFilter = filter ? filter : new kalturaVO.KalturaEntryServerNodeFilter();
entryServerNodeFilter.entryIdEqual = entryId;
client.entryServerNode.listAction(function(result, err, headers) {

Expand All @@ -293,10 +294,21 @@ var BackendClient = (function(){
return deferred.promise;
}

BackendClient.getLiveEntryServerNodes = function(entryId) {
BackendClient.isEntryLive = function(entryId) {
let filter = new kalturaVO.KalturaLiveEntryServerNode();
filter.isLive = kalturaTypes.KalturaNullableBoolean.TRUE_VALUE;
filter.statusIn = '1,2,3';
return getLiveEntryServerNodes(entryId, filter)
.then((serverObjs) => {
return serverObjs.length > 0;
});

}

BackendClient.getLiveEntryServerNodes = function(entryId, filter) {
return createSession()
.then(function() {
return getLiveEntryServerNodes(entryId);
return getLiveEntryServerNodes(entryId, filter);
});
};

Expand Down
16 changes: 1 addition & 15 deletions lib/entry/crossDCsStreamPersistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,18 @@
*/
var persistenceFormat = require('./../../common/PersistenceFormat');
var qio = require('q-io/fs');
//var sessionManager = require('./../SessionManager');
var logger = require('../../common/logger').getLogger("CrossDCsStreamPersistence");
var config = require('./../../common/Configuration');
var ErrorUtils = require('./../utils/error-utils');
var _ = require('underscore');
var Q = require('q');
var glob = require('glob');
var path = require('path');
var backendClient = require('../BackendClientFactory.js').getBackendClient();
var PlaylistGenerator = require('./../playlistGenerator/PlaylistGenerator');
const persistenceFileName = config.get('persistenceFileName');
const persistenceCheckIntervalMillisec = 1000 * config.get('persistenceCheckIntervalSec');
const kalturaTypes = require('./../kaltura-client-lib/KalturaTypes');
const presentationEndTimeRegex = /("presentationEndTime":\s*)(\d+)/;

// todo: add sorted list according to time left for removal of presentationEndTime and expirationTime properties
// Add processEndedEntries or use processStoppedEntries to handle the removal of above for DVR support.
// Should the future time set to presentationEndTime be derived from real liveWindowDuration value?
// todo: remove the presentationEndTime and expirationTime from playlist.json in PlaylistGenerat

function playlistPath(entryId) {
return path.join(persistenceFormat.getEntryBasePath(entryId), persistenceFormat.getMasterManifestName());
Expand All @@ -37,14 +30,7 @@ class CrossDCsStreamPersistence {
streamPersistenceCheck(entryId) {
logger.debug(`[${entryId}] starting stream persistence check`);

// todo: consult with Guy whether to filter received nodes objects according to status...
//entryServerNodeFilter.statusEqual = KalturaLiveStatus.PLAYABLE or KalturaLiveStatus.BROADCASTING;
return backendClient.getLiveEntryServerNodes(entryId)
.then((serverObjs) => {
return _.reduce(serverObjs, (memo, dc) => {
return (dc.status === kalturaTypes.KalturaEntryServerNodeStatus.PLAYABLE) || memo;
}, false);
})
return backendClient.isEntryLive(entryId)
.then((isLive) => {
return this.playlistUpdate(entryId, isLive);
})
Expand Down
4 changes: 2 additions & 2 deletions lib/playlistGenerator/PlaylistGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _ = require('underscore');
var fsUtils = require('./../utils/fs-utils');
var ErrorUtils = require('./../utils/error-utils');
var EventEmitter = require('events').EventEmitter;
const MILLS_IN_YEAR = 1000 * 60 * 60 * 24 * 365;
const MILLISEC_IN_YEAR = 1000 * 60 * 60 * 24 * 365;
const expirationTimeWindowMilliSec = 1000 * config.get('expirationTimeWindowSec');


Expand Down Expand Up @@ -81,7 +81,7 @@ var setPlayList = function (playlist){
that.playlistImp.playListLimits = that.playListLimits;
that.playlistImp.getCurrentTime = Date.now;
// set presentation end time to 10 years ahead
that.playlistImp.inner.presentationEndTime = that.playlistImp.getCurrentTime() + MILLS_IN_YEAR * 10;
that.playlistImp.inner.presentationEndTime = that.playlistImp.getCurrentTime() + MILLISEC_IN_YEAR * 10;
if(that.playListLimits.manifestTimeWindowInMsec) {
that.playlistImp.inner.liveWindowDuration = Math.ceil(that.playListLimits.manifestTimeWindowInMsec / hlsStoreFilefactor);
}
Expand Down

0 comments on commit e45483e

Please sign in to comment.