3030import org .apache .logging .log4j .Logger ;
3131
3232import java .util .Collections ;
33- import java .util .LinkedHashSet ;
33+ import java .util .HashMap ;
34+ import java .util .HashSet ;
35+ import java .util .Map ;
3436import java .util .Set ;
3537
3638/**
3739 * Preload CDN configuration
3840 */
39- public class SwiftDistributionConfigurationLoader extends OneTimeSchedulerFeature <Set <Distribution >> {
41+ public class SwiftDistributionConfigurationLoader extends OneTimeSchedulerFeature <Map < Path , Set <Distribution > >> {
4042 private static final Logger log = LogManager .getLogger (SwiftDistributionConfigurationLoader .class );
4143
4244 private final SwiftSession session ;
@@ -46,19 +48,19 @@ public SwiftDistributionConfigurationLoader(final SwiftSession session) {
4648 }
4749
4850 @ Override
49- protected Set <Distribution > operate (final PasswordCallback callback ) throws BackgroundException {
51+ protected Map < Path , Set <Distribution > > operate (final PasswordCallback callback ) throws BackgroundException {
5052 final DistributionConfiguration feature = session .getFeature (DistributionConfiguration .class );
5153 if (null == feature ) {
52- return Collections .emptySet ();
54+ return Collections .emptyMap ();
5355 }
5456 final AttributedList <Path > containers = new SwiftContainerListService (session ,
5557 new SwiftLocationFeature .SwiftRegion (session .getHost ().getRegion ())).list (Home .ROOT , new DisabledListProgressListener ());
56- final Set <Distribution > distributions = new LinkedHashSet <>();
58+ final Map < Path , Set <Distribution >> distributions = new HashMap <>();
5759 for (Path container : containers ) {
5860 for (Distribution .Method method : feature .getMethods (container )) {
5961 final Distribution distribution = feature .read (container , method , new DisabledLoginCallback ());
6062 log .info ("Cache distribution {}" , distribution );
61- distributions .add (distribution );
63+ distributions .getOrDefault ( container , new HashSet <>()). add (distribution );
6264 }
6365 }
6466 return distributions ;
0 commit comments