/* Ċ Ġ* ĠCopyright Ġ 2 0 1 8 ĠNet flix , ĠInc . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . netflix . spin n aker . or ca . q . migration Ċ Ċ import Ġcom . fasterxml . jackson . annotation . Json TypeName Ċ import Ġcom . netflix . spin n aker . or ca . q . Abort Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Cancel Execution Ċ import Ġcom . netflix . spin n aker . or ca . q . Cancel Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Complete Execution Ċ import Ġcom . netflix . spin n aker . or ca . q . Complete Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Complete Task Ċ import Ġcom . netflix . spin n aker . or ca . q . Continue Parent Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Invalid Execution Id Ċ import Ġcom . netflix . spin n aker . or ca . q . Invalid Stage Id Ċ import Ġcom . netflix . spin n aker . or ca . q . Invalid TaskId Ċ import Ġcom . netflix . spin n aker . or ca . q . Invalid Task Type Ċ import Ġcom . netflix . spin n aker . or ca . q . No Down stream Tasks Ċ import Ġcom . netflix . spin n aker . or ca . q . Pause Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Pause Task Ċ import Ġcom . netflix . spin n aker . or ca . q . Res chedule Execution Ċ import Ġcom . netflix . spin n aker . or ca . q . Restart Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Resume Execution Ċ import Ġcom . netflix . spin n aker . or ca . q . Resume Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Resume Task Ċ import Ġcom . netflix . spin n aker . or ca . q . Run Task Ċ import Ġcom . netflix . spin n aker . or ca . q . Skip Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Start Execution Ċ import Ġcom . netflix . spin n aker . or ca . q . Start Stage Ċ import Ġcom . netflix . spin n aker . or ca . q . Start Task Ċ import Ġcom . netflix . spin n aker . or ca . q . Total Throttle Time Attribute Ċ import Ġcom . netflix . spin n aker . or ca . q . handler . Dead Message Attribute Ċ import Ġcom . netflix . spin n aker . q . Attempts Attribute Ċ import Ġcom . netflix . spin n aker . q . JSON _ NAME _ PROPERTY Ċ import Ġcom . netflix . spin n aker . q . Max Attempts Attribute Ċ import Ġcom . netflix . spin n aker . q . migration . Serialization Migr ator Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . boot . autoconfigure . condition . Conditional On Expression Ċ import Ġorg . springframework . scheduling . annotation . Scheduled Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġjava . time . Local Time Ċ import Ġjava . time . format . DateTime Formatter Ċ import Ġjava . util . concurrent . atomic . Atomic Integer Ċ Ċ @ Component Ċ @ Conditional On Expression ("\ ${ queue . migration . minimal Class TypeInfo Enabled : true }") Ċ class ĠMin imal Class TypeInfo Serialization Migr ator Ġ: ĠSerialization Migr ator Ġ{ ĊĊĠ Ġprivate Ġval Ġlog Ġ= ĠLoggerFactory . getLogger ( java Class ) ĊĊĠ Ġprivate Ġval Ġmigrated Ġ= ĠAtomicInteger ( 0 ) ĊĠ Ġprivate Ġvar Ġlast Report : ĠLocal Time ? Ġ= Ġnull ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġlog . info ("${ java Class . simple Name } Ġenabled ") ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġmigrate ( json : ĠMutable Map < String , ĠAny ?> ): ĠMutable Map < String , ĠAny ?> Ġ{ ĊĠĠĠ Ġmigrate Minimal Class ( json ) ĊĊĠĠĠ Ġif Ġ( json . containsKey (" attributes ") Ġ&& Ġjson [" attributes "] Ġis ĠList <* >) Ġ{ ĊĠĠĠĠĠ Ġ( json [" attributes "] Ġas ĠList <* >) ĊĠĠĠĠĠĠĠ Ġ. filter Is Instance < Mutable Map < String , ĠAny ? >>() ĊĠĠĠĠĠĠĠ Ġ. forEach Ġ{ Ġmigrate Minimal Class ( it ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġjson ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmigrate Minimal Class ( json : ĠMutable Map < String , ĠAny ?> ) Ġ{ ĊĠĠĠ Ġval Ġminimal Class Ġ= ĠgetClass Annotation ( json ) ĊĠĠĠ Ġif Ġ( minimal Class Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġval Ġcls Ġ= ĠM APP ING [ minimal Class ] ĊĠĠĠĠĠ Ġif Ġ( cls Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . error (" Could Ġnot Ġfind Ġminimal Ġclass Ġmapping : Ġ$ minimal Class ") ĊĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġval Ġtype Info Name Ġ= Ġcls . annotations . filter Is Instance < Json TypeName >(). first OrNull () ĊĠĠĠĠĠ Ġif Ġ( type Info Name Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . error (" Class Ġ${ cls . simple Name } Ġdoes Ġnot Ġhave ĠJson TypeName : ĠCannot Ġmigrate Ġmessage ") ĊĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġjson . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġremove ("@ c ") ĊĠĠĠĠĠĠĠ Ġremove ("@ class ") ĊĠĠĠĠĠĠĠ Ġput ( JSON _ NAME _ PROPERTY , Ġtype Info Name . value ) ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġmigrated . increment AndGet () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠgetClass Annotation ( json : ĠMutable Map < String , ĠAny ?> ) Ġ= ĊĠĠĠ Ġ( json [" @ c "] Ġ?: Ġjson [" @ class "]) Ġas ĠString ? ĊĊĠ Ġ@ Scheduled ( fixed Delay Ġ= Ġ 6 0 _ 0 0 0 ) ĊĠ Ġoverride Ġfun Ġreport () Ġ{ ĊĠĠĠ Ġlog . info ( ĊĠĠĠĠĠ Ġ" Migr ated Ġ{} Ġobjects Ġsince Ġ{}", ĊĠĠĠĠĠ Ġmigrated . get (), ĊĠĠĠĠĠ Ġif Ġ( last Report Ġ== Ġnull ) Ġ" startup " Ġelse Ġlast Report !!. format ( DateTime Formatter . ISO _ TIME ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġmigrated . set ( 0 ) ĊĠĠĠ Ġlast Report Ġ= ĠLocal Time . now () ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġval ĠM APP ING Ġ= Ġmap Of < String , ĠClass < *> >( ĊĠĠĠĠĠ Ġ". Start Task " Ġto ĠStart Task :: class . java , ĊĠĠĠĠĠ Ġ". Complete Task " Ġto ĠComplete Task :: class . java , ĊĠĠĠĠĠ Ġ". Pause Task " Ġto ĠPause Task :: class . java , ĊĠĠĠĠĠ Ġ". Resume Task " Ġto ĠResume Task :: class . java , ĊĠĠĠĠĠ Ġ". Run Task " Ġto ĠRun Task :: class . java , ĊĠĠĠĠĠ Ġ". Start Stage " Ġto ĠStart Stage :: class . java , ĊĠĠĠĠĠ Ġ". Continue Parent Stage " Ġto ĠContinue Parent Stage :: class . java , ĊĠĠĠĠĠ Ġ". Complete Stage " Ġto ĠComplete Stage :: class . java , ĊĠĠĠĠĠ Ġ". Skip Stage " Ġto ĠSkip Stage :: class . java , ĊĠĠĠĠĠ Ġ". Abort Stage " Ġto ĠAbort Stage :: class . java , ĊĠĠĠĠĠ Ġ". Pause Stage " Ġto ĠPause Stage :: class . java , ĊĠĠĠĠĠ Ġ". Restart Stage " Ġto ĠRestart Stage :: class . java , ĊĠĠĠĠĠ Ġ". Resume Stage " Ġto ĠResume Stage :: class . java , ĊĠĠĠĠĠ Ġ". Cancel Stage " Ġto ĠCancel Stage :: class . java , ĊĠĠĠĠĠ Ġ". Start Execution " Ġto ĠStart Execution :: class . java , ĊĠĠĠĠĠ Ġ". Res chedule Execution " Ġto ĠRes chedule Execution :: class . java , ĊĠĠĠĠĠ Ġ". Complete Execution " Ġto ĠComplete Execution :: class . java , ĊĠĠĠĠĠ Ġ". Resume Execution " Ġto ĠResume Execution :: class . java , ĊĠĠĠĠĠ Ġ". Cancel Execution " Ġto ĠCancel Execution :: class . java , ĊĠĠĠĠĠ Ġ". Invalid Execution Id " Ġto ĠInvalid Execution Id :: class . java , ĊĠĠĠĠĠ Ġ". Invalid Stage Id " Ġto ĠInvalid Stage Id :: class . java , ĊĠĠĠĠĠ Ġ". Invalid TaskId " Ġto ĠInvalid TaskId :: class . java , ĊĠĠĠĠĠ Ġ". Invalid Task Type " Ġto ĠInvalid Task Type :: class . java , ĊĠĠĠĠĠ Ġ". No Down stream Tasks " Ġto ĠNo Down stream Tasks :: class . java , ĊĠĠĠĠĠ Ġ". Total Throttle Time Attribute " Ġto ĠTotal Throttle Time Attribute :: class . java , ĊĠĠĠĠĠ Ġ". handler . Dead Message Attribute " Ġto ĠDead Message Attribute :: class . java , ĊĠĠĠĠĠ Ġ". Max Attempts Attribute " Ġto ĠMax Attempts Attribute :: class . java , ĊĠĠĠĠĠ Ġ". Attempts Attribute " Ġto ĠAt tempts Attribute :: class . java ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ