-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add live Recorder support * Add live Recorder support * Adding flavors to data file * Add task status updates * remove filter by prefix and change operatio order in recording manager * LiveController code for live-clipping * Add catch and change enum * Add validation check and protect against file descriptor leaks * Add support for multi clips in the live entry playlist * Move get absolute time function from playlist to playlistGenerator * move validation check to recording manager
- Loading branch information
1 parent
008206c
commit 73b914a
Showing
15 changed files
with
409 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Created by david.winder on 04/15/2018. | ||
*/ | ||
|
||
const util = require('util'); | ||
const BackendClient = require('./BackendClientFactory').getBackendClient(); | ||
const KalturaTypes = require('./kaltura-client-lib/KalturaTypes'); | ||
const kalturaVO = require('./kaltura-client-lib/KalturaVO'); | ||
const logger = require('../common/logger').getLogger('TaskManager'); | ||
const config = require('../common/Configuration'); | ||
const pushManager = require('./PushManager').PushManager; | ||
|
||
const interval = config.get('tasksPollingIntervalInSeconds'); | ||
const partnerId = config.get('backendClient').partnerId; | ||
|
||
class TaskManager { | ||
|
||
constructor() | ||
{ | ||
this.callbackMap = {}; | ||
this.mediaServerIdPromise = BackendClient.getMediaServerId(); | ||
this.mediaServerIdPromise.then(serverNodeId => { | ||
setTimeout(()=>{this._updateList(serverNodeId);}, interval * 1000); | ||
}); | ||
} | ||
|
||
register(entryServerNodeType, templateName, callback) | ||
{ | ||
this.callbackMap[entryServerNodeType] = callback; | ||
this.mediaServerIdPromise.then(serverNodeId => { | ||
logger.debug("Register to Task with for " + templateName + " [" + entryServerNodeType + "] for partner: " + partnerId); | ||
pushManager.registerObjectToPush(partnerId, templateName, templateName, {'serverNodeId': serverNodeId}, (...args) => this._pushMessageReceived(...args)); | ||
pushManager.setObjectEnabled(templateName, true); | ||
}); | ||
} | ||
|
||
_execIfCan(task) | ||
{ | ||
if (this.callbackMap[task.serverType]) | ||
return this.callbackMap[task.serverType](task); | ||
logger.info('Task with ID [' + task.id + '] cannot be execute - No callback in map'); | ||
} | ||
|
||
_pushMessageReceived(msg) | ||
{ | ||
if (!Array.isArray(msg) || msg.length < 1) | ||
return logger.error('Got un-valid massage from push server: ' + msg); | ||
|
||
let task = msg[0]; | ||
BackendClient.getEntryServerNode(task.id).then(entryServerNode => { | ||
if (entryServerNode && entryServerNode.status == KalturaTypes.KalturaEntryServerNodeStatus.TASK_PENDING) | ||
return this._execIfCan(task); | ||
logger.info('Task with ID [' + task.id + '] should no executed'); | ||
}); | ||
} | ||
|
||
static _getEntryServerNodesList(serverNodeId, interval) | ||
{ | ||
let filter = new kalturaVO.KalturaEntryServerNodeFilter(); | ||
filter.serverNodeIdEqual = serverNodeId; | ||
filter.statusIn = KalturaTypes.KalturaEntryServerNodeStatus.TASK_PENDING; | ||
filter.createdAtLessThanOrEqual = - interval; | ||
return BackendClient.getLiveEntryServerNodes(null, filter); | ||
} | ||
|
||
_updateList(serverNodeId) | ||
{ | ||
TaskManager._getEntryServerNodesList(serverNodeId, interval).then(entryServerNodes => { | ||
for (var i = 0; i < entryServerNodes.length; i++) | ||
this._execIfCan(entryServerNodes[i]); | ||
}).finally(() => { | ||
setTimeout(()=>{this._updateList(serverNodeId);}, interval * 1000); | ||
}); | ||
} | ||
|
||
} | ||
|
||
module.exports.TaskManager = new TaskManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.