20
20
package org .elasticsearch .discovery .zen ;
21
21
22
22
import org .apache .logging .log4j .message .ParameterizedMessage ;
23
- import org .elasticsearch .core .internal .io .IOUtils ;
24
23
import org .elasticsearch .ElasticsearchException ;
25
24
import org .elasticsearch .Version ;
26
25
import org .elasticsearch .action .ActionListener ;
41
40
import org .elasticsearch .common .io .stream .StreamOutput ;
42
41
import org .elasticsearch .common .settings .Settings ;
43
42
import org .elasticsearch .common .unit .TimeValue ;
43
+ import org .elasticsearch .core .internal .io .IOUtils ;
44
44
import org .elasticsearch .discovery .AckClusterStatePublishResponseHandler ;
45
45
import org .elasticsearch .discovery .BlockingClusterStatePublishResponseHandler ;
46
46
import org .elasticsearch .discovery .Discovery ;
@@ -207,6 +207,12 @@ private void innerPublish(final ClusterChangedEvent clusterChangedEvent, final S
207
207
clusterState .version (), publishTimeout , pendingNodes );
208
208
}
209
209
}
210
+ // The failure is logged under debug when a sending failed. we now log a summary.
211
+ Set <DiscoveryNode > failedNodes = publishResponseHandler .getFailedNodes ();
212
+ if (failedNodes .isEmpty () == false ) {
213
+ logger .warn ("publishing cluster state with version [{}] failed for the following nodes: [{}]" ,
214
+ clusterChangedEvent .state ().version (), failedNodes );
215
+ }
210
216
} catch (InterruptedException e ) {
211
217
// ignore & restore interrupt
212
218
Thread .currentThread ().interrupt ();
@@ -367,14 +373,14 @@ public static BytesReference serializeDiffClusterState(Diff diff, Version nodeVe
367
373
protected void handleIncomingClusterStateRequest (BytesTransportRequest request , TransportChannel channel ) throws IOException {
368
374
Compressor compressor = CompressorFactory .compressor (request .bytes ());
369
375
StreamInput in = request .bytes ().streamInput ();
370
- try {
371
- if ( compressor != null ) {
372
- in = compressor . streamInput ( in );
373
- }
374
- in = new NamedWriteableAwareStreamInput (in , namedWriteableRegistry );
375
- in . setVersion ( request . version ());
376
- synchronized ( lastSeenClusterStateMutex ) {
377
- final ClusterState incomingState ;
376
+ final ClusterState incomingState ;
377
+ synchronized ( lastSeenClusterStateMutex ) {
378
+ try {
379
+ if ( compressor != null ) {
380
+ in = compressor . streamInput (in );
381
+ }
382
+ in = new NamedWriteableAwareStreamInput ( in , namedWriteableRegistry );
383
+ in . setVersion ( request . version ()) ;
378
384
// If true we received full cluster state - otherwise diffs
379
385
if (in .readBoolean ()) {
380
386
incomingState = ClusterState .readFrom (in , transportService .getLocalNode ());
@@ -391,14 +397,17 @@ protected void handleIncomingClusterStateRequest(BytesTransportRequest request,
391
397
logger .debug ("received diff for but don't have any local cluster state - requesting full state" );
392
398
throw new IncompatibleClusterStateVersionException ("have no local cluster state" );
393
399
}
394
- incomingClusterStateListener .onIncomingClusterState (incomingState );
395
- lastSeenClusterState = incomingState ;
400
+ } catch (IncompatibleClusterStateVersionException e ) {
401
+ incompatibleClusterStateDiffReceivedCount .incrementAndGet ();
402
+ throw e ;
403
+ } catch (Exception e ) {
404
+ logger .warn ("unexpected error while deserializing an incoming cluster state" , e );
405
+ throw e ;
406
+ } finally {
407
+ IOUtils .close (in );
396
408
}
397
- } catch (IncompatibleClusterStateVersionException e ) {
398
- incompatibleClusterStateDiffReceivedCount .incrementAndGet ();
399
- throw e ;
400
- } finally {
401
- IOUtils .close (in );
409
+ incomingClusterStateListener .onIncomingClusterState (incomingState );
410
+ lastSeenClusterState = incomingState ;
402
411
}
403
412
channel .sendResponse (TransportResponse .Empty .INSTANCE );
404
413
}
0 commit comments