Requests -> RequestSchedulers
This commit is contained in:
parent
4f13304181
commit
e636eb8810
|
@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router'
|
||||||
|
|
||||||
import { AdminComponent } from './admin.component'
|
import { AdminComponent } from './admin.component'
|
||||||
import { FriendsRoutes } from './friends'
|
import { FriendsRoutes } from './friends'
|
||||||
import { RequestsRoutes } from './requests'
|
import { RequestSchedulersRoutes } from './request-schedulers'
|
||||||
import { UsersRoutes } from './users'
|
import { UsersRoutes } from './users'
|
||||||
import { VideoAbusesRoutes } from './video-abuses'
|
import { VideoAbusesRoutes } from './video-abuses'
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ const adminRoutes: Routes = [
|
||||||
pathMatch: 'full'
|
pathMatch: 'full'
|
||||||
},
|
},
|
||||||
...FriendsRoutes,
|
...FriendsRoutes,
|
||||||
...RequestsRoutes,
|
...RequestSchedulersRoutes,
|
||||||
...UsersRoutes,
|
...UsersRoutes,
|
||||||
...VideoAbusesRoutes
|
...VideoAbusesRoutes
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { NgModule } from '@angular/core'
|
||||||
import { AdminComponent } from './admin.component'
|
import { AdminComponent } from './admin.component'
|
||||||
import { AdminRoutingModule } from './admin-routing.module'
|
import { AdminRoutingModule } from './admin-routing.module'
|
||||||
import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends'
|
import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends'
|
||||||
import { RequestsComponent, RequestStatsComponent, RequestService } from './requests'
|
import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers'
|
||||||
import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users'
|
import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users'
|
||||||
import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
|
import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
|
||||||
import { SharedModule } from '../shared'
|
import { SharedModule } from '../shared'
|
||||||
|
@ -21,8 +21,8 @@ import { SharedModule } from '../shared'
|
||||||
FriendAddComponent,
|
FriendAddComponent,
|
||||||
FriendListComponent,
|
FriendListComponent,
|
||||||
|
|
||||||
RequestsComponent,
|
RequestSchedulersComponent,
|
||||||
RequestStatsComponent,
|
RequestSchedulersStatsComponent,
|
||||||
|
|
||||||
UsersComponent,
|
UsersComponent,
|
||||||
UserAddComponent,
|
UserAddComponent,
|
||||||
|
@ -38,7 +38,7 @@ import { SharedModule } from '../shared'
|
||||||
|
|
||||||
providers: [
|
providers: [
|
||||||
FriendService,
|
FriendService,
|
||||||
RequestService,
|
RequestSchedulersService,
|
||||||
UserService
|
UserService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1 @@
|
||||||
export * from './friends'
|
|
||||||
export * from './requests'
|
|
||||||
export * from './users'
|
|
||||||
export * from './admin-routing.module'
|
|
||||||
export * from './admin.module'
|
export * from './admin.module'
|
||||||
export * from './admin.component'
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './request-schedulers-stats'
|
||||||
|
export * from './shared'
|
||||||
|
export * from './request-schedulers.component'
|
||||||
|
export * from './request-schedulers.routes'
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './request-schedulers-stats.component'
|
|
@ -2,22 +2,22 @@ import { Component, OnInit, OnDestroy } from '@angular/core'
|
||||||
|
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
|
|
||||||
import { RequestService, RequestSchedulerStatsAttributes } from '../shared'
|
import { RequestSchedulersService, RequestSchedulerStatsAttributes } from '../shared'
|
||||||
import { RequestScheduler } from '../../../../../../shared'
|
import { RequestSchedulerStats } from '../../../../../../shared'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-request-stats',
|
selector: 'my-request-schedulers-stats',
|
||||||
templateUrl: './request-stats.component.html',
|
templateUrl: './request-schedulers-stats.component.html',
|
||||||
styleUrls: [ './request-stats.component.scss' ]
|
styleUrls: [ './request-schedulers-stats.component.scss' ]
|
||||||
})
|
})
|
||||||
export class RequestStatsComponent implements OnInit, OnDestroy {
|
export class RequestSchedulersStatsComponent implements OnInit, OnDestroy {
|
||||||
statsTitles = {
|
statsTitles = {
|
||||||
requestScheduler: 'Basic request scheduler',
|
requestScheduler: 'Basic request scheduler',
|
||||||
requestVideoEventScheduler: 'Video events request scheduler',
|
requestVideoEventScheduler: 'Video events request scheduler',
|
||||||
requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
|
requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
|
||||||
}
|
}
|
||||||
|
|
||||||
stats: RequestScheduler
|
stats: RequestSchedulerStats
|
||||||
|
|
||||||
private intervals: { [ id: string ]: number } = {
|
private intervals: { [ id: string ]: number } = {
|
||||||
requestScheduler: null,
|
requestScheduler: null,
|
||||||
|
@ -33,7 +33,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private requestService: RequestService
|
private requestService: RequestSchedulersService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
|
@ -3,5 +3,5 @@ import { Component } from '@angular/core'
|
||||||
@Component({
|
@Component({
|
||||||
template: '<router-outlet></router-outlet>'
|
template: '<router-outlet></router-outlet>'
|
||||||
})
|
})
|
||||||
export class RequestsComponent {
|
export class RequestSchedulersComponent {
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
import { Routes } from '@angular/router'
|
import { Routes } from '@angular/router'
|
||||||
|
|
||||||
import { RequestsComponent } from './requests.component'
|
import { RequestSchedulersComponent } from './request-schedulers.component'
|
||||||
import { RequestStatsComponent } from './request-stats'
|
import { RequestSchedulersStatsComponent } from './request-schedulers-stats'
|
||||||
|
|
||||||
export const RequestsRoutes: Routes = [
|
export const RequestSchedulersRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'requests',
|
path: 'requests',
|
||||||
component: RequestsComponent,
|
component: RequestSchedulersComponent,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
|
@ -15,7 +15,7 @@ export const RequestsRoutes: Routes = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'stats',
|
path: 'stats',
|
||||||
component: RequestStatsComponent,
|
component: RequestSchedulersStatsComponent,
|
||||||
data: {
|
data: {
|
||||||
meta: {
|
meta: {
|
||||||
title: 'Request stats'
|
title: 'Request stats'
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './request-schedulers-stats-attributes.model'
|
||||||
|
export * from './request-schedulers.service'
|
|
@ -1,11 +1,11 @@
|
||||||
import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared'
|
import { RequestSchedulerStatsAttributes as FormatedRequestSchedulerStatsAttributes } from '../../../../../../shared'
|
||||||
|
|
||||||
export interface Request {
|
export interface Request {
|
||||||
request: any
|
request: any
|
||||||
to: any
|
to: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerAttributes {
|
export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerStatsAttributes {
|
||||||
requestsLimitPods: number
|
requestsLimitPods: number
|
||||||
requestsLimitPerPod: number
|
requestsLimitPerPod: number
|
||||||
milliSecondsInterval: number
|
milliSecondsInterval: number
|
|
@ -3,27 +3,27 @@ import { Observable } from 'rxjs/Observable'
|
||||||
import 'rxjs/add/operator/catch'
|
import 'rxjs/add/operator/catch'
|
||||||
import 'rxjs/add/operator/map'
|
import 'rxjs/add/operator/map'
|
||||||
|
|
||||||
import { RequestScheduler } from '../../../../../../shared'
|
import { RequestSchedulerStats } from '../../../../../../shared'
|
||||||
import { AuthHttp, RestExtractor } from '../../../shared'
|
import { AuthHttp, RestExtractor } from '../../../shared'
|
||||||
import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model'
|
import { RequestSchedulerStatsAttributes } from './request-schedulers-stats-attributes.model'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RequestService {
|
export class RequestSchedulersService {
|
||||||
private static BASE_REQUEST_URL = API_URL + '/api/v1/requests/'
|
private static BASE_REQUEST_URL = API_URL + '/api/v1/request-schedulers/'
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: AuthHttp,
|
private authHttp: AuthHttp,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getStats (): Observable<RequestScheduler> {
|
getStats (): Observable<RequestSchedulerStats> {
|
||||||
return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
|
return this.authHttp.get(RequestSchedulersService.BASE_REQUEST_URL + 'stats')
|
||||||
.map(this.restExtractor.extractDataGet)
|
.map(this.restExtractor.extractDataGet)
|
||||||
.map(this.buildRequestObjects)
|
.map(this.buildRequestObjects)
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
.catch((res) => this.restExtractor.handleError(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildRequestObjects (data: RequestScheduler) {
|
private buildRequestObjects (data: RequestSchedulerStats) {
|
||||||
const requestSchedulers = {}
|
const requestSchedulers = {}
|
||||||
|
|
||||||
Object.keys(data).forEach(requestSchedulerName => {
|
Object.keys(data).forEach(requestSchedulerName => {
|
|
@ -1,4 +0,0 @@
|
||||||
export * from './request-stats'
|
|
||||||
export * from './shared'
|
|
||||||
export * from './requests.component'
|
|
||||||
export * from './requests.routes'
|
|
|
@ -1 +0,0 @@
|
||||||
export * from './request-stats.component'
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from './request-stats-attributes.model'
|
|
||||||
export * from './request.service'
|
|
|
@ -6,7 +6,7 @@ import { clientsRouter } from './clients'
|
||||||
import { configRouter } from './config'
|
import { configRouter } from './config'
|
||||||
import { podsRouter } from './pods'
|
import { podsRouter } from './pods'
|
||||||
import { remoteRouter } from './remote'
|
import { remoteRouter } from './remote'
|
||||||
import { requestsRouter } from './requests'
|
import { requestSchedulerRouter } from './request-schedulers'
|
||||||
import { usersRouter } from './users'
|
import { usersRouter } from './users'
|
||||||
import { videosRouter } from './videos'
|
import { videosRouter } from './videos'
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ apiRouter.use('/clients', clientsRouter)
|
||||||
apiRouter.use('/config', configRouter)
|
apiRouter.use('/config', configRouter)
|
||||||
apiRouter.use('/pods', podsRouter)
|
apiRouter.use('/pods', podsRouter)
|
||||||
apiRouter.use('/remote', remoteRouter)
|
apiRouter.use('/remote', remoteRouter)
|
||||||
apiRouter.use('/requests', requestsRouter)
|
apiRouter.use('/request-schedulers', requestSchedulerRouter)
|
||||||
apiRouter.use('/users', usersRouter)
|
apiRouter.use('/users', usersRouter)
|
||||||
apiRouter.use('/videos', videosRouter)
|
apiRouter.use('/videos', videosRouter)
|
||||||
apiRouter.use('/ping', pong)
|
apiRouter.use('/ping', pong)
|
||||||
|
|
|
@ -8,29 +8,29 @@ import {
|
||||||
getRequestVideoEventScheduler
|
getRequestVideoEventScheduler
|
||||||
} from '../../lib'
|
} from '../../lib'
|
||||||
import { authenticate, ensureIsAdmin } from '../../middlewares'
|
import { authenticate, ensureIsAdmin } from '../../middlewares'
|
||||||
import { RequestSchedulerAttributes } from '../../../shared'
|
import { RequestSchedulerStatsAttributes } from '../../../shared'
|
||||||
|
|
||||||
const requestsRouter = express.Router()
|
const requestSchedulerRouter = express.Router()
|
||||||
|
|
||||||
requestsRouter.get('/stats',
|
requestSchedulerRouter.get('/stats',
|
||||||
authenticate,
|
authenticate,
|
||||||
ensureIsAdmin,
|
ensureIsAdmin,
|
||||||
getStatsRequests
|
getRequestSchedulersStats
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
requestsRouter
|
requestSchedulerRouter
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function getStatsRequests (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function getRequestSchedulersStats (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
parallel({
|
parallel({
|
||||||
requestScheduler: buildRequestSchedulerFunction(getRequestScheduler()),
|
requestScheduler: buildRequestSchedulerStats(getRequestScheduler()),
|
||||||
requestVideoQaduScheduler: buildRequestSchedulerFunction(getRequestVideoQaduScheduler()),
|
requestVideoQaduScheduler: buildRequestSchedulerStats(getRequestVideoQaduScheduler()),
|
||||||
requestVideoEventScheduler: buildRequestSchedulerFunction(getRequestVideoEventScheduler())
|
requestVideoEventScheduler: buildRequestSchedulerStats(getRequestVideoEventScheduler())
|
||||||
}, function (err, result) {
|
}, function (err, result) {
|
||||||
if (err) return next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ function getStatsRequests (req: express.Request, res: express.Response, next: ex
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function buildRequestSchedulerFunction (requestScheduler: AbstractRequestScheduler) {
|
function buildRequestSchedulerStats (requestScheduler: AbstractRequestScheduler) {
|
||||||
return function (callback) {
|
return function (callback) {
|
||||||
requestScheduler.remainingRequestsCount(function (err, count) {
|
requestScheduler.remainingRequestsCount(function (err, count) {
|
||||||
if (err) return callback(err)
|
if (err) return callback(err)
|
||||||
|
|
||||||
const result: RequestSchedulerAttributes = {
|
const result: RequestSchedulerStatsAttributes = {
|
||||||
totalRequests: count,
|
totalRequests: count,
|
||||||
requestsLimitPods: requestScheduler.limitPods,
|
requestsLimitPods: requestScheduler.limitPods,
|
||||||
requestsLimitPerPod: requestScheduler.limitPerPod,
|
requestsLimitPerPod: requestScheduler.limitPerPod,
|
|
@ -4,7 +4,7 @@
|
||||||
require('./pods')
|
require('./pods')
|
||||||
require('./remotes')
|
require('./remotes')
|
||||||
require('./users')
|
require('./users')
|
||||||
require('./requests')
|
require('./request-schedulers')
|
||||||
require('./videos')
|
require('./videos')
|
||||||
require('./video-abuses')
|
require('./video-abuses')
|
||||||
require('./video-blacklists')
|
require('./video-blacklists')
|
||||||
|
|
|
@ -9,8 +9,8 @@ const loginUtils = require('../../utils/login')
|
||||||
const usersUtils = require('../../utils/users')
|
const usersUtils = require('../../utils/users')
|
||||||
const serversUtils = require('../../utils/servers')
|
const serversUtils = require('../../utils/servers')
|
||||||
|
|
||||||
describe('Test requests API validators', function () {
|
describe('Test request schedulers stats API validators', function () {
|
||||||
const path = '/api/v1/requests/stats'
|
const path = '/api/v1/request-schedulers/stats'
|
||||||
let server = null
|
let server = null
|
||||||
let userAccessToken = null
|
let userAccessToken = null
|
||||||
|
|
|
@ -9,6 +9,6 @@ require('./single-pod')
|
||||||
require('./video-abuse')
|
require('./video-abuse')
|
||||||
require('./video-blacklist')
|
require('./video-blacklist')
|
||||||
require('./multiple-pods')
|
require('./multiple-pods')
|
||||||
require('./requests')
|
require('./request-schedulers')
|
||||||
require('./friends-advanced')
|
require('./friends-advanced')
|
||||||
require('./video-transcoder')
|
require('./video-transcoder')
|
||||||
|
|
|
@ -12,9 +12,9 @@ const podsUtils = require('../utils/pods')
|
||||||
const serversUtils = require('../utils/servers')
|
const serversUtils = require('../utils/servers')
|
||||||
const videosUtils = require('../utils/videos')
|
const videosUtils = require('../utils/videos')
|
||||||
|
|
||||||
describe('Test requests stats', function () {
|
describe('Test requests schedulers stats', function () {
|
||||||
const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ]
|
const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ]
|
||||||
const path = '/api/v1/requests/stats'
|
const path = '/api/v1/request-schedulers/stats'
|
||||||
let servers = []
|
let servers = []
|
||||||
|
|
||||||
function uploadVideo (server, callback) {
|
function uploadVideo (server, callback) {
|
|
@ -13,7 +13,7 @@ const loginUtils = require('../utils/login')
|
||||||
const podsUtils = require('../utils/pods')
|
const podsUtils = require('../utils/pods')
|
||||||
const serversUtils = require('../utils/servers')
|
const serversUtils = require('../utils/servers')
|
||||||
const videosUtils = require('../utils/videos')
|
const videosUtils = require('../utils/videos')
|
||||||
const requestStatsUtils = require('../utils/requests-stats')
|
const requestSchedulersUtils = require('../utils/request-schedulers')
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-c, --create [weight]', 'Weight for creating videos')
|
.option('-c, --create [weight]', 'Weight for creating videos')
|
||||||
|
@ -344,7 +344,7 @@ function isThereAwaitingRequests (servers, callback) {
|
||||||
|
|
||||||
// Check is each server has awaiting requestq
|
// Check is each server has awaiting requestq
|
||||||
each(servers, function (server, callbackEach) {
|
each(servers, function (server, callbackEach) {
|
||||||
requestStatsUtils.getRequestsStats(server, server.accessToken, function (err, res) {
|
requestSchedulersUtils.getRequestsStats(server, server.accessToken, function (err, res) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
|
||||||
const stats = res.body
|
const stats = res.body
|
||||||
|
|
|
@ -4,7 +4,7 @@ export type RequestVideoQaduType = 'likes' | 'dislikes' | 'views'
|
||||||
|
|
||||||
export type RequestVideoEventType = 'likes' | 'dislikes' | 'views'
|
export type RequestVideoEventType = 'likes' | 'dislikes' | 'views'
|
||||||
|
|
||||||
export type RequestSchedulerAttributes = {
|
export type RequestSchedulerStatsAttributes = {
|
||||||
totalRequests: number
|
totalRequests: number
|
||||||
requestsLimitPods: number
|
requestsLimitPods: number
|
||||||
requestsLimitPerPod: number
|
requestsLimitPerPod: number
|
||||||
|
@ -12,8 +12,8 @@ export type RequestSchedulerAttributes = {
|
||||||
milliSecondsInterval: number
|
milliSecondsInterval: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequestScheduler {
|
export interface RequestSchedulerStats {
|
||||||
requestScheduler: RequestSchedulerAttributes
|
requestScheduler: RequestSchedulerStatsAttributes
|
||||||
requestVideoQaduScheduler: RequestSchedulerAttributes
|
requestVideoQaduScheduler: RequestSchedulerStatsAttributes
|
||||||
requestVideoEventScheduler: RequestSchedulerAttributes
|
requestVideoEventScheduler: RequestSchedulerStatsAttributes
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue