package Ġcom . github . ker ub istan . ker ub . planner . steps . vm . stop Ċ Ċ import Ġcom . fasterxml . jackson . annotation . Json TypeName Ċ import Ġcom . github . ker ub istan . ker ub . model . Expectation Level Ċ import Ġcom . github . ker ub istan . ker ub . model . Host Ċ import Ġcom . github . ker ub istan . ker ub . model . VirtualMachine Ċ import Ġcom . github . ker ub istan . ker ub . model . expect ations . VirtualMachine Availability Expectation Ċ import Ġcom . github . ker ub istan . ker ub . planner . Operation al State Ċ import Ġcom . github . ker ub istan . ker ub . planner . costs . Cost Ċ import Ġcom . github . ker ub istan . ker ub . planner . costs . Risk Ċ import Ġcom . github . ker ub istan . ker ub . planner . re servations . Use Host Reservation Ċ import Ġcom . github . ker ub istan . ker ub . planner . re servations . Vm Reservation Ċ import Ġcom . github . ker ub istan . ker ub . planner . steps . Abstract Operation al Step Ċ import Ġcom . github . ker ub istan . ker ub . planner . steps . vm . base . Host Step Ċ import Ġio . github . ker ub istan . k ro ki . collections . update Ċ import Ġjava . math . BigInteger Ċ Ċ /** Ċ Ġ* ĠStop Ġvirtual Ġmachine . Ċ Ġ* ĠOperation Ġcost Ġis Ġconsidered Ġne gl igible . Ċ Ġ*/ Ċ @ Json TypeName (" stop - vm ") Ċ data Ġclass ĠStop VirtualMachine ( val Ġvm : ĠVirtual Machine , Ġoverride Ġval Ġhost : ĠHost ) Ġ: ĠAbstract Operation al Step , ĠHost Step Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ val Ġscores Ġ= Ġmap Of ( Ċĉĉĉ ĉ Expectation Level . Wish Ġto Ġ 1 , Ċĉĉĉ ĉ Expectation Level . Want Ġto Ġ 1 5 , Ċĉĉĉ ĉ Expectation Level . Deal Breaker Ġto Ġ 1 0 0 Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġtake ( state : ĠOperation al State ): ĠOperation al State Ġ{ Ċĉ ĉ val Ġhost Dyn Ġ= Ġrequire NotNull ( state . hosts [ host . id ]?. dynamic ) Ċĉ ĉ return Ġstate . copy ( Ċĉĉĉ ĉ vms Ġ= Ġstate . vms . update ( vm . id ) Ġ{ Ċĉĉĉĉ ĉ it . copy ( Ċĉĉĉĉĉĉ ĉ dynamic Ġ= Ġnull Ċĉĉĉĉ ĉ ) Ċĉĉĉ ĉ }, Ċĉĉĉ ĉ hosts Ġ= Ġstate . hosts . update ( host . id ) Ġ{ Ċĉĉĉĉ ĉ it . copy ( Ċĉĉĉĉĉĉ ĉ dynamic Ġ= Ġhost Dyn . copy ( Ċĉĉĉĉĉĉĉĉ ĉ mem Free Ġ= Ġ(( host Dyn . mem Free Ġ?: ĠBigInteger . ZERO ) Ġ- Ġvm . memory . max ). coerce At Least ( Ċĉĉĉĉĉĉĉĉĉĉ ĉ BigInteger . ZERO ) Ċĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉ ĉ ) Ċĉĉĉ ĉ } Ċĉ ĉ ) ĊĊ ĉ } ĊĊ ĉ override Ġfun Ġget Cost (): ĠList < Cost > Ġ{ Ċĉ ĉ val Ġavail abl ity Expectation Ġ= Ċĉĉĉ ĉ vm . expect ations . first OrNull Ġ{ Ġit Ġis ĠVirtual Machine Availability Expectation Ġ&& Ġit . up Ġ} Ċĉĉĉĉĉ ĉ as ĠVirtual Machine Availability Expectation ? Ċĉ ĉ return Ġif Ġ( avail abl ity Expectation Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ listOf () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ listOf ( Risk ( score Ġ= Ġscore ( avail abl ity Expectation . level ), Ġcomment Ġ= Ġ"")) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġscore ( level : ĠExpect ation Level ): ĠInt Ġ= Ċĉĉ ĉ scores [ level ] Ġ?: Ġ 0 ĊĊ ĉ override Ġfun Ġre servations () Ġ= ĠlistOf ( Ċĉĉ ĉ Vm Reservation ( vm ), Ċĉĉ ĉ Use Host Reservation ( host ) Ċ ĉ ) Ċ }