@@ -82,6 +82,9 @@ private static class ServerArguments {
8282 @ Parameter (names = {"-p" , "--port" }, description = "Port to listen on for gPRC server" )
8383 private int port = 4181 ;
8484
85+ @ Parameter (names = {"-u" , "--useHostname" }, description = "Use hostname instead of IP for server ID" )
86+ private boolean useHostname = false ;
87+
8588 @ Parameter (names = {"-h" , "--help" }, description = "Show this help message" )
8689 private boolean help = false ;
8790
@@ -105,11 +108,14 @@ private static void loadConfFile(CompositeConfiguration conf, String confFile)
105108
106109 public static Endpoint createLocalEndpoint (int port , boolean useHostname ) throws UnknownHostException {
107110 String hostname ;
111+ log .warn ("Determining hostname for stream storage" );
108112 if (useHostname ) {
109113 hostname = InetAddress .getLocalHost ().getHostName ();
110114 } else {
111115 hostname = InetAddress .getLocalHost ().getHostAddress ();
112116 }
117+
118+ log .warn ("Decided to use hostname {}" , hostname );
113119 return Endpoint .newBuilder ()
114120 .setHostname (hostname )
115121 .setPort (port )
@@ -143,12 +149,14 @@ static int doMain(String[] args) {
143149 }
144150
145151 int grpcPort = arguments .port ;
152+ boolean grpcUseHostname = arguments .useHostname ;
146153
147154 LifecycleComponent storageServer ;
148155 try {
149156 storageServer = buildStorageServer (
150157 conf ,
151- grpcPort );
158+ grpcPort ,
159+ grpcUseHostname );
152160 } catch (ConfigurationException e ) {
153161 log .error ("Invalid storage configuration" , e );
154162 return ExitCode .INVALID_CONF .code ();
@@ -174,11 +182,18 @@ static int doMain(String[] args) {
174182 public static LifecycleComponent buildStorageServer (CompositeConfiguration conf ,
175183 int grpcPort )
176184 throws UnknownHostException , ConfigurationException {
177- return buildStorageServer (conf , grpcPort , true , NullStatsLogger .INSTANCE );
185+ return buildStorageServer (conf , grpcPort , false , true , NullStatsLogger .INSTANCE );
186+ }
187+
188+ public static LifecycleComponent buildStorageServer (CompositeConfiguration conf ,
189+ int grpcPort , boolean useHostname )
190+ throws UnknownHostException , ConfigurationException {
191+ return buildStorageServer (conf , grpcPort , false , useHostname , NullStatsLogger .INSTANCE );
178192 }
179193
180194 public static LifecycleComponent buildStorageServer (CompositeConfiguration conf ,
181195 int grpcPort ,
196+ boolean useHostname ,
182197 boolean startBookieAndStartProvider ,
183198 StatsLogger externalStatsLogger )
184199 throws ConfigurationException , UnknownHostException {
@@ -199,7 +214,7 @@ public static LifecycleComponent buildStorageServer(CompositeConfiguration conf,
199214 storageConf .validate ();
200215
201216 // Get my local endpoint
202- Endpoint myEndpoint = createLocalEndpoint (grpcPort , false );
217+ Endpoint myEndpoint = createLocalEndpoint (grpcPort , useHostname );
203218
204219 // Create shared resources
205220 StorageResources storageResources = StorageResources .create ();
0 commit comments