@Test public void testDuplicateSpawn() throws IOException, InterruptedException { // use the simple command manger, non-gossip ackmanager FlumeMaster master = new FlumeMaster( new CommandManager(), new ConfigManager(), new StatusManager(), new MasterAckManager(), cfg); MasterRPC rpc = new DirectMasterRPC(master); FlumeNode node = new FlumeNode(rpc, false, false); // should have nothing. assertEquals(0, node.getLogicalNodeManager().getNodes().size()); String local = NetUtils.localhost(); // these are spawn commands master.getSpecMan().addLogicalNode(local, node.getPhysicalNodeName()); master.getSpecMan().addLogicalNode(local, "bar"); master.getSpecMan().addLogicalNode(local, "baz"); // there should not be duplicates in the mapping table. master.getSpecMan().addLogicalNode(local, node.getPhysicalNodeName()); master.getSpecMan().addLogicalNode(local, "bar"); master.getSpecMan().addLogicalNode(local, "baz"); Multimap<String, String> mapping = master.getSpecMan().getLogicalNodeMap(); assertEquals(3, mapping.size()); LivenessManager liveMan = node.getLivenessManager(); liveMan.checkLogicalNodes(); assertEquals(3, node.getLogicalNodeManager().getNodes().size()); }
/** * Checks to make sure that nodes specified at the master get spawned at the node. * * @throws InterruptedException */ @Test public void testZKMasterDecomission() throws IOException, InterruptedException { // use the simple command manger, non-gossip ackmanager cfg.set(FlumeConfiguration.MASTER_STORE, "zookeeper"); master = new FlumeMaster( new CommandManager(), new ConfigManager(), new StatusManager(), new MasterAckManager(), cfg); master.serve(); MasterRPC rpc = new DirectMasterRPC(master); FlumeNode node = new FlumeNode(rpc, false, false); // should have nothing. assertEquals(0, node.getLogicalNodeManager().getNodes().size()); master.getSpecMan().addLogicalNode(NetUtils.localhost(), node.getPhysicalNodeName()); master.getSpecMan().addLogicalNode(NetUtils.localhost(), "bar"); master.getSpecMan().addLogicalNode(NetUtils.localhost(), "baz"); LivenessManager liveMan = node.getLivenessManager(); liveMan.checkLogicalNodes(); // the two added nodes, plus the always present physnode/logical assertEquals(3, node.getLogicalNodeManager().getNodes().size()); }
@Test public void testUnmapLogicalNode() throws IOException, InterruptedException { // use the simple command manger, non-gossip ackmanager FlumeMaster master = new FlumeMaster( new CommandManager(), new ConfigManager(), new StatusManager(), new MasterAckManager(), cfg); MasterRPC rpc = new DirectMasterRPC(master); FlumeNode node = new FlumeNode(rpc, false, false); // should have nothing. assertEquals(0, node.getLogicalNodeManager().getNodes().size()); String local = NetUtils.localhost(); master.getSpecMan().addLogicalNode(local, node.getPhysicalNodeName()); master.getSpecMan().addLogicalNode(local, "bar"); master.getSpecMan().addLogicalNode(local, "baz"); LivenessManager liveMan = node.getLivenessManager(); liveMan.checkLogicalNodes(); assertEquals(local, master.getSpecMan().getPhysicalNode("bar")); assertEquals(local, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNull(master.getSpecMan().getConfig(local)); master.getSpecMan().unmapLogicalNode(local, "bar"); liveMan.checkLogicalNodes(); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(local, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNull(master.getSpecMan().getConfig(local)); master.getSpecMan().unmapLogicalNode(local, "baz"); liveMan.checkLogicalNodes(); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(null, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNull(master.getSpecMan().getConfig(local)); master.getSpecMan().unmapLogicalNode(local, local); liveMan.checkLogicalNodes(); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNull(master.getSpecMan().getConfig(local)); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(null, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); }
/** * Checks to make sure that nodes specified at the master get spawned at the node. * * <p>Even though only two nodes are set, there should be three because we currently have an * invariant where each physical node must have at least on logical node, which is named the same * name as the physical node name. * * <p>This may go away when we "bulkify" the node-master comms into one rpc call. * * @throws InterruptedException */ @Test public void testMasterLogicalNodeCheckAutoLogicalNode() throws IOException, InterruptedException { FlumeMaster master = new FlumeMaster(cfg); master.getSpecMan().addLogicalNode(NetUtils.localhost(), "bar"); master.getSpecMan().addLogicalNode(NetUtils.localhost(), "baz"); MasterRPC rpc = new DirectMasterRPC(master); FlumeNode node = new FlumeNode(rpc, false, false); // should have nothing. assertEquals(0, node.getLogicalNodeManager().getNodes().size()); LivenessManager liveMan = node.getLivenessManager(); liveMan.checkLogicalNodes(); // the two added nodes, plus the always present physnode/logical assertEquals(3, node.getLogicalNodeManager().getNodes().size()); }
@Test public void testZKRemoveLogicalNode() throws IOException, FlumeSpecException, InterruptedException { // use the simple command manger, non-gossip ackmanager cfg.set(FlumeConfiguration.MASTER_STORE, "zookeeper"); master = new FlumeMaster( new CommandManager(), new ConfigManager(), new StatusManager(), new MasterAckManager(), cfg); master.serve(); MasterRPC rpc = new DirectMasterRPC(master); FlumeNode node = new FlumeNode(rpc, false, false); // should have nothing. assertEquals(0, node.getLogicalNodeManager().getNodes().size()); String local = NetUtils.localhost(); master.getSpecMan().addLogicalNode(local, node.getPhysicalNodeName()); master.getSpecMan().addLogicalNode(local, "bar"); master.getSpecMan().addLogicalNode(local, "baz"); master.getSpecMan().setConfig(local, "my-test-flow", "null", "null"); master.getSpecMan().setConfig("bar", "my-test-flow", "null", "null"); master.getSpecMan().setConfig("baz", "my-test-flow", "null", "null"); LivenessManager liveMan = node.getLivenessManager(); liveMan.heartbeatChecks(); // liveMan.checkLogicalNodes(); assertEquals(local, master.getSpecMan().getPhysicalNode("bar")); assertEquals(local, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNotNull(master.getSpecMan().getConfig("bar")); assertNotNull(master.getSpecMan().getConfig("baz")); assertNotNull(master.getSpecMan().getConfig(local)); master.getSpecMan().removeLogicalNode("bar"); liveMan.heartbeatChecks(); // liveMan.checkLogicalNodes(); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(local, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNull(master.getSpecMan().getConfig("bar")); assertNotNull(master.getSpecMan().getConfig("baz")); assertNotNull(master.getSpecMan().getConfig(local)); master.getSpecMan().removeLogicalNode("baz"); liveMan.heartbeatChecks(); // liveMan.checkLogicalNodes(); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(null, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNotNull(master.getSpecMan().getConfig(local)); master.getSpecMan().removeLogicalNode(local); liveMan.heartbeatChecks(); // liveMan.checkLogicalNodes(); assertNull(master.getSpecMan().getConfig("bar")); assertNull(master.getSpecMan().getConfig("baz")); assertNull(master.getSpecMan().getConfig(local)); assertEquals(null, master.getSpecMan().getPhysicalNode("bar")); assertEquals(null, master.getSpecMan().getPhysicalNode("baz")); assertEquals(local, master.getSpecMan().getPhysicalNode(local)); }