private @ Nonnull LoadBalancerHealthCheck toLoadBalancerHealthCheck ( JSONObject ob ) throws JSONException , InternalException , CloudException { LoadBalancerHealthCheck . HCProtocol protocol = fromOSProtocol ( ob . getString ( "type" ) ) ; int count = ob . getInt ( "max_retries" ) ; int port = - 1 ; String path = ob . optString ( "url_path" , null ) ; JSONArray pools = ob . optJSONArray ( "pools" ) ; for ( int i = 0 ; i < pools . length ( ) ; i ++ ) { String lbId = pools . getJSONObject ( i ) . getString ( "pool_id" ) ; LoadBalancer lb = getLoadBalancer ( lbId ) ; if ( lb != null ) { LbListener [ ] listeners = lb . getListeners ( ) ; if ( listeners != null && listeners . length > 0 ) { port = listeners [ 0 ] . getPrivatePort ( ) ; break ; } } } String id = ob . getString ( "id" ) ; int timeout = ob . getInt ( "timeout" ) ; int interval = ob . getInt ( "delay" ) ; LoadBalancerHealthCheck lbhc = LoadBalancerHealthCheck . getInstance ( id , protocol , port , path , interval , timeout , count , count ) ; for ( int i = 0 ; i < pools . length ( ) ; i ++ ) { lbhc . addProviderLoadBalancerId ( pools . getJSONObject ( i ) . getString ( "pool_id" ) ) ; } return lbhc ; }
Convert OpenStack health_monitor object to Dasein LoadBalancerHealthCheck