public MetadataV3 fetchRoute ( int version , MetadataV3 docs ) { Route route = null ; if ( docs . path != null && docs . http_method != null ) { try { route = RequestServer . lookupRoute ( new RequestUri ( docs . http_method , docs . path ) ) ; } catch ( MalformedURLException e ) { route = null ; } } else { // Linear scan for the route, plus each route is asked for in-order // during doc-gen leading to an O(n^2) execution cost. if ( docs . path != null ) try { docs . num = Integer . parseInt ( docs . path ) ; } catch ( NumberFormatException e ) { /* path is not a number, it's ok */ } if ( docs . num >= 0 && docs . num < RequestServer . numRoutes ( ) ) route = RequestServer . routes ( ) . get ( docs . num ) ; // Crash-n-burn if route not found (old code thru an AIOOBE), so we // something similarly bad. docs . routes = new RouteV3 [ ] { new RouteV3 ( route ) } ; } if ( route == null ) return null ; Schema sinput , soutput ; if ( route . _handler_class . equals ( water . api . ModelBuilderHandler . class ) || route . _handler_class . equals ( water . api . GridSearchHandler . class ) ) { // GridSearchHandler uses the same logic as ModelBuilderHandler because there are no separate // ${ALGO}GridSearchParametersV3 classes, instead each field in ${ALGO}ParametersV3 is marked as either gridable // or not. String ss [ ] = route . _url . split ( "/" ) ; String algoURLName = ss [ 3 ] ; // {}/{3}/{ModelBuilders}/{gbm}/{parameters} String algoName = ModelBuilder . algoName ( algoURLName ) ; // gbm -> GBM; deeplearning -> DeepLearning String schemaDir = ModelBuilder . schemaDirectory ( algoURLName ) ; int version2 = Integer . valueOf ( ss [ 1 ] ) ; try { String inputSchemaName = schemaDir + algoName + "V" + version2 ; // hex.schemas.GBMV3 sinput = ( Schema ) TypeMap . getTheFreezableOrThrow ( TypeMap . onIce ( inputSchemaName ) ) ; } catch ( java . lang . ClassNotFoundException e ) { // Not very pretty, but for some routes such as /99/Grid/glm we want to map to GLMV3 (because GLMV99 does not // exist), yet for others such as /99/Grid/svd we map to SVDV99 (because SVDV3 does not exist). sinput = ( Schema ) TypeMap . theFreezable ( TypeMap . onIce ( schemaDir + algoName + "V3" ) ) ; } sinput . init_meta ( ) ; soutput = sinput ; } else { sinput = Schema . newInstance ( Handler . getHandlerMethodInputSchema ( route . _handler_method ) ) ; soutput = Schema . newInstance ( Handler . getHandlerMethodOutputSchema ( route . _handler_method ) ) ; } docs . routes [ 0 ] . input_schema = sinput . getClass ( ) . getSimpleName ( ) ; docs . routes [ 0 ] . output_schema = soutput . getClass ( ) . getSimpleName ( ) ; docs . routes [ 0 ] . markdown = route . markdown ( sinput , soutput ) . toString ( ) ; return docs ; }
Also called through reflection by RequestServer