/** * Gets the <em>applications</em> after filtering the applications for * instances with only UP states and shuffling them. * * <p> * The filtering depends on the option specified by the configuration * {@link EurekaClientConfig#shouldFilterOnlyUpInstances()}. Shuffling helps * in randomizing the applications list there by avoiding the same instances * receiving traffic during start ups. * </p> * * @param apps * The applications that needs to be filtered and shuffled. * @return The applications after the filter and the shuffle. */ private Applications filterAndShuffle(Applications apps) { if (apps != null) { if (isFetchingRemoteRegionRegistries()) { Map<String, Applications> remoteRegionVsApps = new ConcurrentHashMap<String, Applications>(); apps.shuffleAndIndexInstances(remoteRegionVsApps, clientConfig, instanceRegionChecker); for (Applications applications : remoteRegionVsApps.values()) { applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); } this.remoteRegionVsApps = remoteRegionVsApps; } else { apps.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); } } return apps; }
Map<String, Applications> remoteRegionsRegistry = new HashMap<>(); remoteRegionsRegistry.put("us-east-1", new Applications()); applications.shuffleAndIndexInstances(remoteRegionsRegistry, clientConfig, instanceRegionChecker); assertNotNull(remoteRegionsRegistry.get("us-east-1").getRegisteredApplications("TestApp").getByInstanceId("test.east.hostname")); assertNull(applications.getRegisteredApplications("TestApp").getByInstanceId("test.east.hostname"));
/** * Gets the <em>applications</em> after filtering the applications for * instances with only UP states and shuffling them. * * <p> * The filtering depends on the option specified by the configuration * {@link EurekaClientConfig#shouldFilterOnlyUpInstances()}. Shuffling helps * in randomizing the applications list there by avoiding the same instances * receiving traffic during start ups. * </p> * * @param apps * The applications that needs to be filtered and shuffled. * @return The applications after the filter and the shuffle. */ private Applications filterAndShuffle(Applications apps) { if (apps != null) { if (isFetchingRemoteRegionRegistries()) { Map<String, Applications> remoteRegionVsApps = new ConcurrentHashMap<String, Applications>(); apps.shuffleAndIndexInstances(remoteRegionVsApps, clientConfig, instanceRegionChecker); for (Applications applications : remoteRegionVsApps.values()) { applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); } this.remoteRegionVsApps = remoteRegionVsApps; } else { apps.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); } } return apps; }