File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
src/java/org/apache/hadoop/http Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ Trunk (unreleased changes)
5959
6060 HADOOP-6411. Remove deprecated file src/test/hadoop-site.xml. (cos)
6161
62+ HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress:
63+ IllegalArgumentException is thrown (cos)
64+
6265Release 0.21.0 - Unreleased
6366
6467 INCOMPATIBLE CHANGES
Original file line number Diff line number Diff line change 2727import java .util .HashMap ;
2828import java .util .List ;
2929import java .util .Map ;
30+ import java .util .Random ;
3031
3132import javax .servlet .Filter ;
3233import javax .servlet .FilterChain ;
@@ -469,6 +470,33 @@ public void start() throws IOException {
469470 } //Workaround end
470471 LOG .info ("Jetty bound to port " + port );
471472 webServer .start ();
473+ // Workaround for HADOOP-6386
474+ port = listener .getLocalPort ();
475+ if (port < 0 ) {
476+ LOG .warn ("Bounds port is " + port + " after webserver start" );
477+ Random r = new Random (1000 );
478+ for (int i = 0 ; i < MAX_RETRIES /2 ; i ++) {
479+ try {
480+ webServer .stop ();
481+ } catch (Exception e ) {
482+ LOG .warn ("Can't stop web-server" , e );
483+ }
484+ Thread .sleep (r .nextInt ());
485+
486+ listener .setPort (oriPort == 0 ? 0 : (oriPort += 1 ));
487+ listener .open ();
488+ Thread .sleep (100 );
489+ webServer .start ();
490+ LOG .info (i + "attempts to restart webserver" );
491+ port = listener .getLocalPort ();
492+ if (port > 0 )
493+ break ;
494+ }
495+ if (port < 0 )
496+ throw new Exception ("listener.getLocalPort() is returning " +
497+ "less than 0 even after " +MAX_RETRIES +" resets" );
498+ }
499+ // End of HADOOP-6386 workaround
472500 break ;
473501 } catch (IOException ex ) {
474502 // if this is a bind exception,
You can’t perform that action at this time.
0 commit comments