Instance marshall ( InstanceInfo instanceInfo ) { String hostname = instanceInfo . getHostName ( ) ; final String managementPort = instanceInfo . getMetadata ( ) . get ( "management.port" ) ; String port = managementPort == null ? String . valueOf ( instanceInfo . getPort ( ) ) : managementPort ; String cluster = getClusterName ( instanceInfo ) ; Boolean status = parseInstanceStatus ( instanceInfo . getStatus ( ) ) ; if ( hostname != null && cluster != null && status != null ) { Instance instance = getInstance ( hostname , port , cluster , status ) ; Map < String , String > metadata = instanceInfo . getMetadata ( ) ; boolean securePortEnabled = instanceInfo . isPortEnabled ( InstanceInfo . PortType . SECURE ) ; String securePort = String . valueOf ( instanceInfo . getSecurePort ( ) ) ; addMetadata ( instance , hostname , port , securePortEnabled , securePort , metadata ) ; // add amazon metadata String asgName = instanceInfo . getASGName ( ) ; if ( asgName != null ) { instance . getAttributes ( ) . put ( ASG_KEY , asgName ) ; } DataCenterInfo dcInfo = instanceInfo . getDataCenterInfo ( ) ; if ( dcInfo != null && dcInfo . getName ( ) . equals ( DataCenterInfo . Name . Amazon ) ) { AmazonInfo amznInfo = ( AmazonInfo ) dcInfo ; instance . getAttributes ( ) . putAll ( amznInfo . getMetadata ( ) ) ; } return instance ; } else { return null ; } }
Private helper that marshals the information from each instance into something that Turbine can understand . Override this method for your own implementation for parsing Eureka info .