@ Override protected List < Instance > getInstancesForApp ( String serviceId ) throws Exception { List < Instance > instances = new ArrayList <> ( ) ; log . info ( "Fetching instances for app: " + serviceId ) ; Application app = eurekaClient . getApplication ( serviceId ) ; if ( app == null ) { log . warn ( "Eureka returned null for app: " + serviceId ) ; return instances ; } try { List < InstanceInfo > instancesForApp = app . getInstances ( ) ; if ( instancesForApp != null ) { log . info ( "Received instance list for app: " + serviceId + ", size=" + instancesForApp . size ( ) ) ; for ( InstanceInfo iInfo : instancesForApp ) { Instance instance = marshall ( iInfo ) ; if ( instance != null ) { instances . add ( instance ) ; } } } } catch ( Exception e ) { log . warn ( "Failed to retrieve instances from Eureka" , e ) ; } return instances ; }
Private helper that fetches the Instances for each application .