99import com .google .common .collect .Sets ;
1010import com .google .protobuf .Message ;
1111import io .envoyproxy .controlplane .cache .Resources .ResourceType ;
12+
1213import java .util .Collection ;
1314import java .util .Collections ;
1415import java .util .HashMap ;
2526import java .util .stream .Collectors ;
2627import java .util .stream .Stream ;
2728import javax .annotation .concurrent .GuardedBy ;
29+
2830import org .slf4j .Logger ;
2931import org .slf4j .LoggerFactory ;
3032
@@ -238,7 +240,7 @@ public DeltaWatch createDeltaWatch(
238240 return watch ;
239241 }
240242 } else if (hasClusterChanged && requestResourceType .equals (ResourceType .ENDPOINT )) {
241- ResponseState responseState = respondDelta (request , group , snapshot , version , watch );
243+ ResponseState responseState = respondDelta (request , watch , snapshot , version , group );
242244 if (responseState .isFinished ()) {
243245 return watch ;
244246 }
@@ -250,7 +252,7 @@ public DeltaWatch createDeltaWatch(
250252 }
251253
252254 // Otherwise, version is different, the watch may be responded immediately
253- ResponseState responseState = respondDelta (request , group , snapshot , version , watch );
255+ ResponseState responseState = respondDelta (request , watch , snapshot , version , group );
254256 if (responseState .isFinished ()) {
255257 return watch ;
256258 }
@@ -357,8 +359,9 @@ public StatusInfo<T> statusInfo(T group) {
357359
358360 @ VisibleForTesting
359361 protected void respondWithSpecificOrder (T group ,
360- U previousSnapshot , U snapshot ,
361- Map <ResourceType , CacheStatusInfo <T >> statusMap , Map <ResourceType , DeltaCacheStatusInfo <T >> deltaStatusMap ) {
362+ U previousSnapshot , U snapshot ,
363+ Map <ResourceType , CacheStatusInfo <T >> statusMap ,
364+ Map <ResourceType , DeltaCacheStatusInfo <T >> deltaStatusMap ) {
362365 for (ResourceType resourceType : RESOURCE_TYPES_IN_ORDER ) {
363366 CacheStatusInfo <T > status = statusMap .get (resourceType );
364367 if (status != null ) {
@@ -425,6 +428,7 @@ protected void respondWithSpecificOrder(T group,
425428
426429 Map <String , VersionedResource <?>> changedResources = findChangedResources (watch , snapshotChangedResources );
427430
431+
428432 ResponseState responseState = respondDelta (watch ,
429433 changedResources ,
430434 removedResources ,
@@ -443,16 +447,16 @@ protected void respondWithSpecificOrder(T group,
443447 }
444448
445449 private Response createResponse (XdsRequest request , Map <String , VersionedResource <?>> resources ,
446- String version ) {
450+ String version ) {
447451 Collection <? extends Message > filtered = request .getResourceNamesList ().isEmpty ()
448452 ? resources .values ().stream ()
449453 .map (VersionedResource ::resource )
450454 .collect (Collectors .toList ())
451455 : request .getResourceNamesList ().stream ()
452- .map (resources ::get )
453- .filter (Objects ::nonNull )
454- .map (VersionedResource ::resource )
455- .collect (Collectors .toList ());
456+ .map (resources ::get )
457+ .filter (Objects ::nonNull )
458+ .map (VersionedResource ::resource )
459+ .collect (Collectors .toList ());
456460
457461 return Response .create (request , filtered , version );
458462 }
@@ -517,7 +521,7 @@ private List<String> findRemovedResources(DeltaWatch watch, Map<String, Versione
517521 }
518522
519523 private Map <String , VersionedResource <?>> findChangedResources (DeltaWatch watch ,
520- Map <String , VersionedResource <?>> snapshotResources ) {
524+ Map <String , VersionedResource <?>> snapshotResources ) {
521525 return snapshotResources .entrySet ()
522526 .stream ()
523527 .filter (entry -> {
@@ -534,24 +538,24 @@ private Map<String, VersionedResource<?>> findChangedResources(DeltaWatch watch,
534538 .collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue ));
535539 }
536540
537- private ResponseState respondDelta (DeltaXdsRequest request , T group , U snapshot , String version , DeltaWatch watch ) {
541+
542+ private ResponseState respondDelta (DeltaXdsRequest request , DeltaWatch watch , U snapshot , String version , T group ) {
538543 Map <String , VersionedResource <?>> snapshotResources = snapshot .versionedResources (request .getResourceType ());
539544 List <String > removedResources = findRemovedResources (watch ,
540545 snapshotResources );
541546 Map <String , VersionedResource <?>> changedResources = findChangedResources (watch , snapshotResources );
542- return respondDelta (
543- watch ,
547+ return respondDelta (watch ,
544548 changedResources ,
545549 removedResources ,
546550 version ,
547551 group );
548552 }
549553
550554 private ResponseState respondDelta (DeltaWatch watch ,
551- Map <String , VersionedResource <?>> resources ,
552- List <String > removedResources ,
553- String version ,
554- T group ) {
555+ Map <String , VersionedResource <?>> resources ,
556+ List <String > removedResources ,
557+ String version ,
558+ T group ) {
555559 if (resources .isEmpty () && removedResources .isEmpty ()) {
556560 return ResponseState .UNRESPONDED ;
557561 }
0 commit comments