PSM Uploader and Encoder Flow

The PSM Uploader and Encoder components are divided into two separate and independent services: Encoder and Uploader. Each service operates through its own set of CronJobs and workflows to process and manage session recordings.

Encoder

The encoder converts video files from .guac format to .mp4. It utilizes two CronJobs that run independently to manage this conversion process.

First CronJob

  1. Initialization: Starts every 5 minutes, reads filenames from the directory.

  2. Session Polling: Passes sessions to EID using the endpoint /api/services/v1/secureaccessgateway/polling to check for closed/terminated sessions.

  3. Filtering Sessions: Retains only closed sessions.

  4. Recording Status Check: Uses the endpoint /api/services/v1/secureAccessGateway/GetRecordingProcessStatus to get the recording status and avoid duplication. Example response:

    { "PrivSessionID": "a15494e9-8568-4cc4-a055-0e40dfbe1c57", "RecordingStatus": "Processing" }
  5. Queue Management: Adds sessions with RecordingStatus: null to the sessionsQueue after verifying they don't already exist in the sessionsQueue or failedJobs array. Sessions are queued as objects to handle retries:

    {"07a44b9f-568c-47c8-bbf2-f433d7b49104": 0}

     

Second CronJob

  1. Initialization: Starts every 10 minutes, independently of the first CronJob.

  2. Failed Jobs Retrieval: Fetches failedJobs array from the cache.

  3. Session Handling: Adds first 5 sessions from failedJobs to an array. Dequeues sessions from sessionsQueue and adds them to the array until it contains 10 sessions.

  4. Worker Processing: Passes sessions to a worker thread, updating their recordingStatus to "Processing" using the endpoint /api/services/v1/secureAccessGateway/UpdateRecordingProcessStatus. Example payload:

    { "privSessionId": "81930caf-f6f7-46b3-bbab-c1faa2d29f16", "recordingStatus": "Processing" }
  5. Video Conversion: Converts videos to .mp4 using guacnec and ffmpeg utilities. Manages failed jobs by retrying up to 3 times and updating the status to "Failed" if retries are exhausted. Successfully processed sessions are marked as "Processed".

 

Untitled Diagram.drawio (7) (2).png

 

Uploader

The Uploader manages the final step of uploading processed video files. It runs a single cron job to handle this task.

  1. Initialization: Starts every 5 minutes, reads files from the /recording directory.

  2. Session Filtering: Filters out closed sessions and fetches their recording status using the endpoint /api/services/v1/secureAccessGateway/GetRecordingProcessStatus.

  3. Processing: Only sessions with the status "Processed" are considered for uploading. Fetches storage mode settings for each session from the endpoint:

  4. Queue Management: Adds sessions to the sessionsQueue after checking they don't already exist in the queue or failedJobs array.

  5. Failed Jobs Handling: Retrieves failedJobs array from the cache, processes the first 5 sessions, and combines them with dequeued sessions to form an array of 10 sessions.

  6. Worker Processing: Updates recordingStatus to "Uploading" before starting the upload. Example payload:

  7. Uploading: Uploads videos to the specified storage mode (e.g., AWS, Azure). Manages failed uploads by retrying up to 3 times and updating the status to "Failed" if retries are exhausted. Successfully uploaded sessions are marked as "Uploaded".

 

Uploader Work Flow.drawio (4).png

 

By following this structured approach, the PSM Uploader and Encoder services ensure that video sessions are efficiently converted and uploaded while handling failures and retries systematically. This workflow ensures reliability and accuracy in managing session recordings.

Â