UniformRandomRouterPolicy extends AbstractRouterPolicy { @Override public SubClusterId getHomeSubcluster( ApplicationSubmissionContext appSubmissionContext, List<SubClusterId> blackListSubClusters) throws YarnException { validate(appSubmissionContext); Map<SubClusterId, SubClusterInfo> activeSubclusters = getActiveSubclusters(); List<SubClusterId> list = new ArrayList<>(activeSubclusters.keySet()); FederationPolicyUtils.validateSubClusterAvailability(list, blackListSubClusters); if (blackListSubClusters != null) { for (SubClusterId scId : blackListSubClusters) { list.remove(scId); } } return list.get(rand.nextInt(list.size())); } UniformRandomRouterPolicy(); @Override void reinitialize(FederationPolicyInitializationContext policyContext); @Override SubClusterId getHomeSubcluster(
      ApplicationSubmissionContext appSubmissionContext,
      List<SubClusterId> blackListSubClusters);  }
@Test public void testOneSubclusterIsChosen() throws YarnException { SubClusterId chosen = ((FederationRouterPolicy) getPolicy()) .getHomeSubcluster(getApplicationSubmissionContext(), null); Assert.assertTrue(getActiveSubclusters().keySet().contains(chosen)); }