package Ġde . f aw e izz . topic service . service . joined . execution Ċ Ċ import Ġde . f aw e izz . topic service . Actor Ċ import Ġde . f aw e izz . topic service . persistence . Mongo Ċ import Ġde . f aw e izz . topic service . service . audit logging . Audit Logger Ċ import Ġde . f aw e izz . topic service . service . client . Client Service Ċ import Ġde . f aw e izz . topic service . service . joined . resource . Code Execution Ċ import Ġde . f aw e izz . topic service . service . messaging . Messaging Service Ċ import Ġde . f aw e izz . topic service . service . polling . Polling Service Ċ import Ġde . f aw e izz . topic service . service . resource . Access Level Ċ import Ġde . f aw e izz . topic service . service . resource . Resource Service Ċ import Ġorg . apache . avro . Schema Ċ import Ġjava . util .* Ċ Ċ class ĠJo ined Resource Code Execution Service ( ĊĠĠĠ Ġprivate Ġval Ġmongo : ĠMongo , ĊĠĠĠ Ġprivate Ġval Ġmessaging Service : ĠMessaging Service , ĊĠĠĠ Ġprivate Ġval Ġresource Service : ĠResource Service , ĊĠĠĠ Ġprivate Ġval Ġclient Service : ĠClient Service , ĊĠĠĠ Ġprivate Ġval Ġdeployment Service : ĠDeployment Service , ĊĠĠĠ Ġprivate Ġval Ġaudit Logger : ĠAudit Logger Ċ ) Ġ: ĠPol ling Service < Code Execution Poll > Ġ{ ĊĊĠĠĠ Ġfun Ġcreate Code Execution Request ( actor : ĠActor , Ġcode Execution Request : ĠCode Execution Request ): ĠCode Execution Poll Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresource Ġ= Ġmongo . find Joined Resource ByName ( code Execution Request . resourceName ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠException (" Unknown Ġresource ") ĊĊĠĠĠĠĠĠĠ Ġif Ġ(! resource . own ing Actor Ids . contains ( actor . name )) Ġthrow ĠException (" Actor Ġnot Ġowner Ġof Ġshared Ġresource ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpoll Ġ= ĠCode Execution Poll ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequest er Ġ= Ġactor . name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresource Name Ġ= Ġresource . resourceId , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Ġ= Ġcode Execution Request . comment , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġcode Execution Request . name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgit Url Ġ= Ġcode Execution Request . git Url , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcommit Hash Ġ= Ġcode Execution Request . commit Hash , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactors To Accept Ġ= Ġ( resource . own ing Actor Ids Ġ- ĠlistOf ( actor . name )). toSet () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġmongo . save Code Execution Poll ( poll ) ĊĠĠĠĠĠĠĠ Ġmessaging Service . send Code Execution Poll ( resource , Ġpoll ) ĊĊĠĠĠĠĠĠĠ Ġaudit Logger . log Joined Resource Compute Request ( poll . id , Ġactor . name , Ġpoll . actors To Accept . toList ()) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġpoll ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Poll able ById ( poll able Id : ĠString ): ĠCode Execution Poll Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġmongo . find Code Execution Poll ById ( poll able Id ) Ġ?: Ġthrow ĠException (" Unknown Ġpoll ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġupdate Poll able ( poll able : ĠCode Execution Poll ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmongo . update Code Execution Poll ById ( poll able ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġon Accepted ( poll able : ĠCode Execution Poll ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjoined Resource Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmongo . find Joined Resource ByName ( poll able . resourceName ) Ġ?: Ġthrow ĠException (" Unknown Ġresource ") ĊĠĠĠĠĠĠĠ Ġval Ġtarget ResourceName Ġ= Ġ"${ poll able . resourceName }_${ poll able . name }_${ poll able . commit Hash }" ĊĠĠĠĠĠĠĠ Ġval Ġtarget Resource Ġ= Ġresource Service . create Resource ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfully QualifiedName Ġ= Ġtarget ResourceName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġow ning Actor Ids Ġ= Ġjoined Resource . own ing Actor Ids , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccess Level Ġ= ĠAccess Level . READ , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġschema Ġ= ĠSchema . Parser (). parse ( joined Resource . schema ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdescription Ġ= Ġ" Target - Resource Ġfor Ġcustom Ġcode Ġexecution Ġ${ poll able . name }" ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcode Execution Client Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient Service . create Client ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠUUID . randomUUID (). toString (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( poll able . resourceName ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( target Resource . id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcode Execution Ġ= ĠCode Execution ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġpoll able . name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubmitted By Actor Ġ= Ġpoll able . requester , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgit lab Repository Url Ġ= Ġpoll able . git Url , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcommit Hash Ġ= Ġpoll able . commit Hash , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient Name Ġ= Ġcode Execution Client . name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient Secret Ġ= Ġcode Execution Client . secret , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient Consumer Group Ġ= Ġcode Execution Client . consumer Group , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinput Topic Ġ= Ġpoll able . resourceName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoutput Topic Ġ= Ġtarget ResourceName ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġjoined Resource . code Execution s Ġ+= Ġcode Execution ĊĊĠĠĠĠĠĠĠ Ġmongo . update Joined Resource ( joined Resource ) ĊĠĠĠĠĠĠĠ Ġdeployment Service . deploy ( code Execution ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġaccept ( actor : ĠActor , Ġpoll able Id : ĠString ): ĠCode Execution Poll Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġaccept Ġ= Ġsuper . accept ( actor , Ġpoll able Id ) ĊĠĠĠĠĠĠĠ Ġaudit Logger . log Joined Resource Compute Request Accept ( poll able Id , Ġactor . name ) ĊĠĠĠĠĠĠĠ Ġreturn Ġaccept ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġdecl ine ( actor : ĠActor , Ġpoll able Id : ĠString ): ĠCode Execution Poll Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdecl ine Ġ= Ġsuper . decl ine ( actor , Ġpoll able Id ) ĊĠĠĠĠĠĠĠ Ġaudit Logger . log Joined Resource Compute Request Decl ine ( poll able Id , Ġactor . name ) ĊĠĠĠĠĠĠĠ Ġreturn Ġdecl ine ĊĠĠĠ Ġ} Ċ }