package Ġcom . github . ker ub istan . ker ub . planner . steps . host . startup Ċ Ċ import Ġcom . github . ker ub istan . ker ub . data . dynamic . Host Dynamic Dao Ċ import Ġcom . github . ker ub istan . ker ub . host . Host Manager Ċ import Ġcom . github . ker ub istan . ker ub . host . lom . Wake On Lan Ċ import Ġcom . github . ker ub istan . ker ub . model . Host Ċ import Ġcom . github . ker ub istan . ker ub . model . dynamic . Host Status Ċ import Ġcom . github . ker ub istan . ker ub . planner . execution . Abstract Step Executor Ċ import Ġcom . github . ker ub istan . ker ub . utils . getLogger Ċ Ċ open Ġclass ĠW ake Host Executor ( Ċĉ ĉ private Ġval Ġhost Manager : ĠHost Manager , Ċĉ ĉ private Ġval Ġhost Dyn Dao : ĠHost Dynamic Dao , Ċĉ ĉ private Ġval Ġtries : ĠInt Ġ= Ġdefault Max Retries , Ċĉ ĉ private Ġval Ġwait : ĠLong Ġ= Ġdefault Wait Between T ries Ċ ) Ġ: ĠAbstract Step Executor < Abstract Wake Host , ĠUnit >() Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ private Ġval Ġlogger Ġ= Ġget Logger () Ċĉ ĉ private Ġconst Ġval Ġdefault Max Retries Ġ= Ġ 8 Ċĉ ĉ private Ġconst Ġval Ġdefault Wait Between T ries Ġ= Ġ 3 0 0 0 0 . to Long () Ċ ĉ } ĊĊ ĉ override Ġfun Ġperform ( step : ĠAbstract Wake Host ) Ġ{ Ċĉ ĉ var Ġlast Exception : ĠException ? Ġ= Ġnull Ċĉ ĉ for Ġ( nr Ġin Ġ 0 .. tri es ) Ġ{ Ċĉĉ ĉ if Ġ( host Dyn Dao [ step . host . id ]?. status Ġ== ĠHost Status . Up ) Ġ{ Ċĉĉĉ ĉ // host Ġconnected Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉĉ ĉ try Ġ{ Ċĉĉĉ ĉ logger . debug (" attempt Ġ{} Ġ- Ġw aking Ġhost Ġ{} Ġ{}", Ġnr , Ġstep . host . address , Ġstep . host . id ) Ċĉĉĉ ĉ when Ġ( step ) Ġ{ Ċĉĉĉĉ ĉ is ĠW ol Wake Host Ġ-> Ġ{ Ċĉĉĉĉĉ ĉ wake On Loan ( step . host ) Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ġ-> ĠTODO () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ logger . debug (" attempt Ġ{} Ġ- Ġconnecting Ġhost Ġ{} Ġ{}", Ġnr , Ġstep . host . address , Ġstep . host . id ) Ċĉĉĉ ĉ host Manager . connect Host ( step . host ) Ċĉĉĉ ĉ logger . debug (" attempt Ġ{} Ġ- Ġhost Ġ{} Ġ{} Ġconnected ", Ġnr , Ġstep . host . address , Ġstep . host . id ) Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ġcatch Ġ( e : ĠException ) Ġ{ Ċĉĉĉ ĉ logger . debug (" attempt Ġ{} Ġ- Ġconnecting Ġ{} Ġ{} : Ġfailed Ġ- Ġwaiting Ġ{} Ġms Ġbefore Ġretry ", Ċĉĉĉĉĉ ĉ nr , Ġstep . host . address , Ġstep . host . id , Ġwait ) Ċĉĉĉ ĉ Thread . sleep ( wait ) Ċĉĉĉ ĉ last Exception Ġ= Ġe Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ throw ĠW ake Host Exception ( Ċĉĉĉ ĉ " Could Ġnot Ġconnect Ġhost Ġ${ step . host . address } Ġ${ step . host . id } Ġin Ġ$ default Max Retries Ġattempts ", Ċĉĉĉ ĉ last Exception ) Ċ ĉ } ĊĊ ĉ internal Ġopen Ġfun Ġwake On Loan ( host : ĠHost ) Ġ{ Ċĉ ĉ Wake On Lan ( host ). on () Ċ ĉ } ĊĊ ĉ override Ġfun Ġupdate ( step : ĠAbstract Wake Host , Ġupdates : ĠUnit ) Ġ{ Ċĉ ĉ host Dyn Dao . update ( step . host . id ) Ġ{ Ġdyn Ġ-> Ċĉĉ ĉ dyn . copy ( Ċĉĉĉĉ ĉ status Ġ= ĠHost Status . Up Ċĉĉ ĉ ) Ċĉ ĉ } Ċ ĉ } Ċ Ċ }