Beispiel #1
0
  /**
   * 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());
  }
Beispiel #2
0
  @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());
  }
Beispiel #3
0
  /** Checks to make sure that an unmapped node correctly transitions to DECOMMISSIONED */
  @Test
  public void testUnmappedLogicalNodeGetsDecommissioned() throws IOException, InterruptedException {
    FlumeMaster master = new FlumeMaster(cfg);
    MasterRPC rpc = new DirectMasterRPC(master);

    FlumeNode node = new FlumeNode(rpc, false, false);
    // should have nothing.
    assertEquals(0, node.getLogicalNodeManager().getNodes().size());

    master.getSpecMan().addLogicalNode(node.getPhysicalNodeName(), "foo");

    master
        .getStatMan()
        .updateHeartbeatStatus(
            NetUtils.localhost(), node.getPhysicalNodeName(), "foo", NodeState.ACTIVE, 10);

    master.getSpecMan().unmapLogicalNode(NetUtils.localhost(), "foo");

    master.getStatMan().checkup();

    assertEquals(NodeState.DECOMMISSIONED, master.getStatMan().getNodeStatuses().get("foo").state);

    master.getSpecMan().addLogicalNode(node.getPhysicalNodeName(), "foo");
    master
        .getStatMan()
        .updateHeartbeatStatus(
            NetUtils.localhost(), node.getPhysicalNodeName(), "foo", NodeState.ACTIVE, 10);

    master.getStatMan().checkup();

    assertEquals(NodeState.ACTIVE, master.getStatMan().getNodeStatuses().get("foo").state);
  }
Beispiel #4
0
  /**
   * 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());
  }
Beispiel #5
0
  @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));
  }
  public void doTestLogicalNodesConcurrentDFOMans(final int threads, final int events, int timeout)
      throws IOException, InterruptedException, FlumeSpecException {
    FlumeTestHarness.setupLocalWriteDir();
    FlumeMaster master = new FlumeMaster();
    FlumeNode node = new FlumeNode(new DirectMasterRPC(master), false, false);
    final Reportable[] dfos = new Reportable[threads];

    for (int i = 0; i < threads; i++) {
      String name = "test." + i;
      String report = "report." + i;
      int count = events + i;
      String src = "asciisynth(" + count + ",100)";
      String snk = "{ diskFailover => counter(\"" + report + "\") } ";
      node.getLogicalNodeManager().testingSpawn(name, src, snk);
      dfos[i] = node.getLogicalNodeManager().get(name);
    }

    // TODO (jon) using sleep is cheating to give all threads a chance to start.
    // Test seems flakey without this due to a race condition.
    Thread.sleep(500);

    // wait for all to be done.
    waitForEmptyDFOs(node, timeout);

    // check to make sure everyone got the right number of events
    boolean success = true;

    for (int i = 0; i < threads; i++) {
      LOG.info(dfos[i].getMetrics());
    }

    for (int i = 0; i < threads; i++) {

      CounterSink cnt = (CounterSink) ReportManager.get().getReportable("report." + i);
      LOG.info(i + " expected " + (events + i) + " and got " + cnt.getCount());
      success &= ((events + i) == cnt.getCount());
      assertEquals(events + i, cnt.getCount());
    }
    assertTrue("Counts did not line up", success);

    FlumeTestHarness.cleanupLocalWriteDir();
  }
 /** Wait until the flume node's dfos are empty. */
 private void waitForEmptyDFOs(FlumeNode node, int timeout) throws InterruptedException {
   boolean done = false;
   long start = System.currentTimeMillis();
   while (!done) {
     if (System.currentTimeMillis() - start > timeout) {
       fail("Test took too long");
     }
     Collection<LogicalNode> lns = node.getLogicalNodeManager().getNodes();
     done = areDFOsReconfigured(lns) && areDFOsEmpty(lns);
     if (!done) {
       Thread.sleep(250);
     }
   }
 }
Beispiel #8
0
  @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));
  }