@@ -153,9 +153,11 @@ public void postContextInit(Extensions ctx) throws PolarisException {
153153 eventQueue = new LinkedBlockingQueue <>(config .getEventQueueSize ());
154154
155155 serviceAddressRepository = new ServiceAddressRepository (this .config .getAddress (),
156- ctx .getValueContext ().getClientId (), ctx , new ServiceKey (config .getNamespace (), config .getService ()));
156+ ctx .getValueContext ().getClientId (), ctx ,
157+ new ServiceKey (config .getNamespace (), config .getService ()));
157158
158- eventExecutors .scheduleWithFixedDelay (new PushGatewayEventTask (), 1000 , 1000 , TimeUnit .MILLISECONDS );
159+ eventExecutors .scheduleWithFixedDelay (new PushGatewayEventTask (), 1000 , 1000 ,
160+ TimeUnit .MILLISECONDS );
159161 LOG .info ("PushGateway event reporter starts reporting task." );
160162 } catch (Throwable e ) {
161163 LOG .error ("Init PushGateway event reporter fail." , e );
@@ -224,9 +226,11 @@ public void run() {
224226
225227 private void postPushGatewayEvent (PushGatewayEventRequest request ) {
226228 StringEntity postBody = null ;
227- RequestConfig config = RequestConfig .custom ().setConnectTimeout (2000 ).setConnectionRequestTimeout (10000 ).setSocketTimeout (10000 ).build ();
229+ RequestConfig config = RequestConfig .custom ().setConnectTimeout (2000 ).setConnectionRequestTimeout (10000 )
230+ .setSocketTimeout (10000 ).build ();
228231 try (CloseableHttpClient httpClient = HttpClientBuilder .create ().setDefaultRequestConfig (config ).build ()) {
229- HttpPost httpPost = new HttpPost (getEventUri ());
232+ URI uri = getEventUri ();
233+ HttpPost httpPost = new HttpPost (uri );
230234 postBody = new StringEntity (mapper .writeValueAsString (request ), StandardCharsets .UTF_8 );
231235 if (LOG .isDebugEnabled ()) {
232236 LOG .debug ("postPushGatewayEvent body:{}" , postBody );
@@ -239,11 +243,13 @@ private void postPushGatewayEvent(PushGatewayEventRequest request) {
239243
240244 if (200 != httpResponse .getStatusLine ().getStatusCode ()) {
241245 String resultString = EntityUtils .toString (httpResponse .getEntity (), "utf-8" );
242- throw new RuntimeException ("Report push gateway event failed. Response = [" + resultString + "]." );
246+ throw new RuntimeException ("Report push gateway event to " + uri .getHost () + ":" + uri .getPort ()
247+ + "failed. Response = [" + resultString + "]." );
243248 } else {
244249 if (LOG .isDebugEnabled ()) {
245250 String resultString = EntityUtils .toString (httpResponse .getEntity (), "utf-8" );
246- LOG .info ("Report push gateway event success. Response is : {}" , resultString );
251+ LOG .info ("Report push gateway event to {}:{} success. Response is : {}" , uri .getHost (),
252+ uri .getPort (), resultString );
247253 } else {
248254 LOG .info ("Report push gateway event success." );
249255 }
0 commit comments