@ Override public final synchronized void onHttpRequest ( final ParsedHttpRequest parsedHttpRequest , final HttpServletResponse response ) throws IOException , ServletException { LOG . log ( Level . INFO , "HttpServeShellCmdHandler in webserver onHttpRequest is called: {0}" , parsedHttpRequest . getRequestUri ( ) ) ; final String queryStr = parsedHttpRequest . getQueryString ( ) ; if ( parsedHttpRequest . getTargetEntity ( ) . equalsIgnoreCase ( "Evaluators" ) ) { final byte [ ] b = HttpShellJobDriver . CODEC . encode ( queryStr ) ; LOG . log ( Level . INFO , "HttpServeShellCmdHandler call HelloDriver onCommand(): {0}" , queryStr ) ; messageHandler . get ( ) . onNext ( b ) ; notify ( ) ; final long endTime = System . currentTimeMillis ( ) + WAIT_TIMEOUT ; while ( cmdOutput == null ) { final long waitTime = endTime - System . currentTimeMillis ( ) ; if ( waitTime <= 0 ) { break ; } try { wait ( WAIT_TIME ) ; } catch ( final InterruptedException e ) { LOG . log ( Level . WARNING , "HttpServeShellCmdHandler onHttpRequest InterruptedException: {0}" , e ) ; } } if ( cmdOutput != null ) { response . getOutputStream ( ) . write ( cmdOutput . getBytes ( StandardCharsets . UTF_8 ) ) ; cmdOutput = null ; } } else if ( parsedHttpRequest . getTargetEntity ( ) . equalsIgnoreCase ( "Driver" ) ) { final String commandOutput = CommandUtils . runCommand ( queryStr ) ; response . getOutputStream ( ) . write ( commandOutput . getBytes ( StandardCharsets . UTF_8 ) ) ; } }
it is called when receiving a http request .