@Test public void testMissingRestartDependenciesAdded() throws Exception { ClusterImpl cluster = createMock(ClusterImpl.class); ServiceComponentHost sch1 = createMock(ServiceComponentHostImpl.class); ServiceComponentHost sch2 = createMock(ServiceComponentHostImpl.class); expect(cluster.getService("GLUSTERFS")).andReturn(null); expect(cluster.getClusterId()).andReturn(1L); Map<String, ServiceComponentHost> hostComponents = new HashMap<>(); hostComponents.put("1", sch1); hostComponents.put("2", sch2); Service yarnService = createMock(Service.class); ServiceComponent resourcemanagerSC = createMock(ServiceComponent.class); expect(cluster.getService("YARN")).andReturn(yarnService).atLeastOnce(); expect(cluster.getService("HDFS")).andReturn(null); expect(yarnService.getServiceComponent("RESOURCEMANAGER")).andReturn(resourcemanagerSC).anyTimes(); expect(resourcemanagerSC.getServiceComponentHosts()).andReturn(hostComponents).anyTimes(); expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6")); replay(cluster, yarnService, sch1, sch2, resourcemanagerSC); RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster); verify(cluster, yarnService); Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies(); assertNotNull(deps); Map<RoleCommandPair, Set<RoleCommandPair>> startRCOs = new HashMap<>(); Map<RoleCommandPair, Set<RoleCommandPair>> restartRCOs = new HashMap<>(); for (Map.Entry<RoleCommandPair, Set<RoleCommandPair>> dep : deps.entrySet()) { if (dep.getKey().getCmd().equals(RoleCommand.START)) { startRCOs.put(dep.getKey(), dep.getValue()); } if (dep.getKey().getCmd().equals(RoleCommand.RESTART)) { restartRCOs.put(dep.getKey(), dep.getValue()); } } assertFalse(startRCOs.isEmpty()); assertFalse(restartRCOs.isEmpty()); assertEquals(startRCOs.size(), restartRCOs.size()); Map.Entry<RoleCommandPair, Set<RoleCommandPair>> entry = restartRCOs.entrySet().iterator().next(); assertEquals(RoleCommand.RESTART, entry.getKey().getCmd()); for (RoleCommandPair pair : entry.getValue()) { assertEquals(RoleCommand.RESTART, pair.getCmd()); } for (Map.Entry<RoleCommandPair, Set<RoleCommandPair>> startEntry : startRCOs.entrySet()) { assertTrue(restartRCOs.containsKey( new RoleCommandPair(startEntry.getKey().getRole(), RoleCommand.RESTART))); } }
public Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies() { return dependencies; }
RoleCommandOrder implements Cloneable { public Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies() { return dependencies; } }
RoleCommandOrder implements Cloneable { public Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies() { return dependencies; }  }
RoleCommandOrder implements Cloneable { public Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies() { return dependencies; }  @SuppressWarnings("unchecked") void initialize(Cluster cluster, LinkedHashSet<String> sectionKeys); int order(RoleGraphNode rgn1, RoleGraphNode rgn2); Set<Service> getTransitiveServices(Service service, RoleCommand cmd); int compareDeps(RoleCommandOrder rco); LinkedHashSet<String> getSectionKeys(); Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies(); @Override Object clone(); }
RoleCommandOrder implements Cloneable { public Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies() { return dependencies; }  @SuppressWarnings("unchecked") void initialize(Cluster cluster, LinkedHashSet<String> sectionKeys); int order(RoleGraphNode rgn1, RoleGraphNode rgn2); Set<Service> getTransitiveServices(Service service, RoleCommand cmd); int compareDeps(RoleCommandOrder rco); LinkedHashSet<String> getSectionKeys(); Map<RoleCommandPair, Set<RoleCommandPair>> getDependencies(); @Override Object clone(); final static String GLUSTERFS_DEPS_KEY; final static String NO_GLUSTERFS_DEPS_KEY; final static String NAMENODE_HA_DEPS_KEY; final static String RESOURCEMANAGER_HA_DEPS_KEY; final static String COMMENT_STR; }