public static NodeCache startAppIdWatcher ( Environment env ) { try { CuratorFramework curator = env . getSharedResources ( ) . getCurator ( ) ; byte [ ] uuidBytes = curator . getData ( ) . forPath ( ZookeeperPath . CONFIG_FLUO_APPLICATION_ID ) ; if ( uuidBytes == null ) { Halt . halt ( "Fluo Application UUID not found" ) ; throw new RuntimeException ( ) ; // make findbugs happy } final String uuid = new String ( uuidBytes , StandardCharsets . UTF_8 ) ; final NodeCache nodeCache = new NodeCache ( curator , ZookeeperPath . CONFIG_FLUO_APPLICATION_ID ) ; nodeCache . getListenable ( ) . addListener ( ( ) -> { ChildData node = nodeCache . getCurrentData ( ) ; if ( node == null || ! uuid . equals ( new String ( node . getData ( ) , StandardCharsets . UTF_8 ) ) ) { Halt . halt ( "Fluo Application UUID has changed or disappeared" ) ; } } ) ; nodeCache . start ( ) ; return nodeCache ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Start watching the fluo app uuid . If it changes or goes away then halt the process .