package Ġuk . gov . d wp . data works . k af k ato hbase . re conc iliation . configuration Ċ Ċ import Ġorg . apache . hadoop . hbase . H Base Configuration Ċ import Ġorg . apache . hadoop . hbase . H Constants Ċ import Ġorg . apache . hadoop . hbase . client . Connection Ċ import Ġorg . apache . hadoop . hbase . client . ConnectionFactory Ċ import Ġorg . springframework . boot . context . properties . Configuration Properties Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . context . annotation . Profile Ċ import Ġuk . gov . d wp . data works . logging . Data works Logger Ċ Ċ @ Configuration Ċ @ Configuration Properties ( prefix Ġ= Ġ" hbase ") Ċ @ Profile (" H BASE ") Ċ data Ġclass ĠH Base Configuration ( ĊĠĠĠ Ġvar Ġz ookeeper Parent : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġz ookeeper Qu orum : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġz ookeeper Port : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġclient Scanner Timeout Period Ms : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġclient Operation Timeout Ms : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġclient Meta Operation Timeout Ms : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġrpc Timeout Ms : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġrpc Read Timeout Ms : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġretries : ĠString ? Ġ= Ġ" NOT _ SET ", ĊĠĠĠ Ġvar Ġreplication Factor : ĠString ? Ġ= Ġ" NOT _ SET " Ċ ) Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlogger Ġ= ĠData works Logger . getLogger ( H Base Configuration :: class . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġh base Configuration (): Ġorg . apache . hadoop . conf . Configuration Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġconfiguration Ġ= Ġorg . apache . hadoop . conf . Configuration (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset ( H Constants . Z OO KE E PER _ Z NODE _ PARENT , Ġz ookeeper Parent Ġ?: Ġ" NO PE ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset ( H Constants . Z OO KE E PER _ QU OR UM , Ġz ookeeper Qu orum Ġ?: Ġ" NO PE ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int (" hbase . zookeeper . port ", Ġz ookeeper Port ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ CLIENT _ SCAN NER _ TIMEOUT _ PERIOD , Ġclient Scanner Timeout Period Ms ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ CLIENT _ OPERATION _ TIMEOUT , Ġclient Operation Timeout Ms ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ CLIENT _ META _ OPERATION _ TIMEOUT , Ġclient Meta Operation Timeout Ms ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ RPC _ WRITE _ TIMEOUT _ KEY , Ġrpc Timeout Ms ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ RPC _ READ _ TIMEOUT _ KEY , Ġrpc Read Timeout Ms ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Int ( H Constants . H BASE _ CLIENT _ RE TR IES _ NUMBER , Ġretries ?. toInt OrNull () Ġ?: Ġ 6 6 6 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġlogger . info (" Timeout Ġconfiguration ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" scanner " Ġto Ġconfiguration . get ( H Constants . H BASE _ CLIENT _ SCAN NER _ TIMEOUT _ PERIOD ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" rpc " Ġto Ġconfiguration . get ( H Constants . H BASE _ RPC _ WRITE _ TIMEOUT _ KEY ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" rpc _ read " Ġto Ġconfiguration . get ( H Constants . H BASE _ RPC _ READ _ TIMEOUT _ KEY ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" client " Ġto Ġconfiguration . get ( H Constants . H BASE _ CLIENT _ OPERATION _ TIMEOUT ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" client _ meta " Ġto Ġconfiguration . get ( H Constants . H BASE _ CLIENT _ META _ OPERATION _ TIMEOUT )) ĊĊĠĠĠĠĠĠĠ Ġlogger . info (" H Base ĠConfiguration Ġloaded ", Ġ" hbase _ configuration " Ġto Ġconfiguration . toString ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġconfiguration ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġh base Connection (): ĠConnection Ġ{ ĊĠĠĠĠĠĠĠ Ġlogger . info (" Est ablish ing Ġconnection Ġwith ĠH Base ") ĊĠĠĠĠĠĠĠ Ġval Ġconfiguration Ġ= Ġh base Configuration () ĊĠĠĠĠĠĠĠ Ġlogger . info (" H base Ġconnection Ġconfiguration ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠH Constants . Z OO KE E PER _ Z NODE _ PARENT Ġto Ġconfiguration . get ( H Constants . Z OO KE E PER _ Z NODE _ PARENT ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠH Constants . Z OO KE E PER _ QU OR UM Ġto Ġconfiguration . get ( H Constants . Z OO KE E PER _ QU OR UM ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" hbase . zookeeper . port " Ġto Ġconfiguration . get (" hbase . zookeeper . port ")) ĊĠĠĠĠĠĠĠ Ġval Ġconnection Ġ= ĠConnection Factory . create Connection ( H Base Configuration . create ( configuration )) ĊĠĠĠĠĠĠĠ Ġadd Shutdown Hook ( connection ) ĊĠĠĠĠĠĠĠ Ġlogger . info (" Est ab lished Ġconnection Ġwith ĠH Base ") ĊĊĠĠĠĠĠĠĠ Ġreturn Ġconnection ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġreplication Factor () Ġ= Ġreplication Factor ?. toInt OrNull () Ġ?: Ġ- 1 ĊĊĠĠĠ Ġprivate Ġfun Ġadd Shutdown Hook ( connection : ĠConnection ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlogger . info (" Adding ĠH Base Ġshutdown Ġhook ") ĊĠĠĠĠĠĠĠ ĠRuntime . get Runtime (). add Shutdown Hook ( object Ġ: ĠThread () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġrun () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . info (" H Base Ġshutdown Ġhook Ġrunning Ġ- Ġclosing Ġconnection ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconnection . close () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġlogger . info (" Added ĠH Base Ġshutdown Ġhook ") ĊĠĠĠ Ġ} Ċ } Ċ