Fix redundancy exceeding the limit
This commit is contained in:
parent
e2600d8b26
commit
0b353d1d8a
|
@ -15,6 +15,10 @@
|
||||||
"target": "http://localhost:9000",
|
"target": "http://localhost:9000",
|
||||||
"secure": false
|
"secure": false
|
||||||
},
|
},
|
||||||
|
"/lazy-static": {
|
||||||
|
"target": "http://localhost:9000",
|
||||||
|
"secure": false
|
||||||
|
},
|
||||||
"/socket.io": {
|
"/socket.io": {
|
||||||
"target": "ws://localhost:9000",
|
"target": "ws://localhost:9000",
|
||||||
"secure": false,
|
"secure": false,
|
||||||
|
|
|
@ -105,7 +105,10 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
private async extendsRedundancy (redundancyModel: VideoRedundancyModel) {
|
private async extendsRedundancy (redundancyModel: VideoRedundancyModel) {
|
||||||
const redundancy = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy)
|
const redundancy = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy)
|
||||||
// Redundancy strategy disabled, remove our redundancy instead of extending expiration
|
// Redundancy strategy disabled, remove our redundancy instead of extending expiration
|
||||||
if (!redundancy) await removeVideoRedundancy(redundancyModel)
|
if (!redundancy) {
|
||||||
|
await removeVideoRedundancy(redundancyModel)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
await this.extendsExpirationOf(redundancyModel, redundancy.minLifetime)
|
await this.extendsExpirationOf(redundancyModel, redundancy.minLifetime)
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,23 +325,45 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
|
||||||
|
|
||||||
static async getTotalDuplicated (strategy: VideoRedundancyStrategy) {
|
static async getTotalDuplicated (strategy: VideoRedundancyStrategy) {
|
||||||
const actor = await getServerActor()
|
const actor = await getServerActor()
|
||||||
|
const redundancyInclude = {
|
||||||
|
attributes: [],
|
||||||
|
model: VideoRedundancyModel,
|
||||||
|
required: true,
|
||||||
|
where: {
|
||||||
|
actorId: actor.id,
|
||||||
|
strategy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const query: FindOptions = {
|
const queryFiles: FindOptions = {
|
||||||
|
include: [ redundancyInclude ]
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryStreamingPlaylists: FindOptions = {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
attributes: [],
|
attributes: [],
|
||||||
model: VideoRedundancyModel,
|
model: VideoModel.unscoped(),
|
||||||
required: true,
|
required: true,
|
||||||
where: {
|
include: [
|
||||||
actorId: actor.id,
|
{
|
||||||
strategy
|
attributes: [],
|
||||||
}
|
model: VideoStreamingPlaylistModel.unscoped(),
|
||||||
|
include: [
|
||||||
|
redundancyInclude
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return VideoFileModel.aggregate('size', 'SUM', query)
|
return Promise.all([
|
||||||
.then(result => parseAggregateResult(result))
|
VideoFileModel.aggregate('size', 'SUM', queryFiles),
|
||||||
|
VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists)
|
||||||
|
]).then(([ r1, r2 ]) => {
|
||||||
|
return parseAggregateResult(r1) + parseAggregateResult(r2)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async listLocalExpired () {
|
static async listLocalExpired () {
|
||||||
|
|
|
@ -508,10 +508,8 @@ describe('Test multiple servers', function () {
|
||||||
|
|
||||||
await wait(1000)
|
await wait(1000)
|
||||||
|
|
||||||
await Promise.all([
|
await viewVideo(servers[2].url, localVideosServer3[0])
|
||||||
viewVideo(servers[2].url, localVideosServer3[0]),
|
await viewVideo(servers[2].url, localVideosServer3[0])
|
||||||
viewVideo(servers[2].url, localVideosServer3[0])
|
|
||||||
])
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue