@Test public void testInitializeAtHaRMCluster() throws AmbariException { 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<String, ServiceComponentHost>(); 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); Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies(); assertTrue("Dependencies are loaded after initialization", deps.size() > 0); verify(cluster, yarnService); assertFalse(dependenciesContainBlockedRole(deps, Role.PEERSTATUS)); assertFalse(dependenciesContainBlockedRole(deps, Role.GLUSTERFS_SERVICE_CHECK)); assertFalse(dependenciesContainBlockedRole(deps, Role.GLUSTERFS_CLIENT)); assertFalse(dependenciesContainBlockerRole(deps, Role.PEERSTATUS)); assertFalse(dependenciesContainBlockerRole(deps, Role.GLUSTERFS_SERVICE_CHECK)); assertFalse(dependenciesContainBlockerRole(deps, Role.GLUSTERFS_CLIENT)); assertTrue(dependenciesContainBlockerRole(deps, Role.DATANODE)); RoleCommandPair rmPair = new RoleCommandPair(Role.RESOURCEMANAGER, RoleCommand.START); Set<RoleCommandPair> rmRoleCommandPairs = deps.get(rmPair); assertNotNull(rmRoleCommandPairs); boolean isZookeeperStartPresent = false; for (RoleCommandPair pair : rmRoleCommandPairs) { if (pair.getCmd() == RoleCommand.START && pair.getRole() == Role.ZOOKEEPER_SERVER) { isZookeeperStartPresent = true; } } assertTrue(isZookeeperStartPresent); }
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; }