Exemplo n.º 1
0
  /** Test the various four letter words */
  @Test
  public void testFourLetterWords() throws Exception {
    verify("ruok", "imok");
    verify("envi", "java.version");
    verify("conf", "clientPort");
    verify("stat", "Outstanding");
    verify("srvr", "Outstanding");
    verify("cons", "queued");
    verify("dump", "Session");
    verify("wchs", "watches");
    verify("wchp", "");
    verify("wchc", "");

    verify("srst", "reset");
    verify("crst", "reset");

    verify("stat", "Outstanding");
    verify("srvr", "Outstanding");
    verify("cons", "queued");

    TestableZooKeeper zk = createClient();
    String sid = "0x" + Long.toHexString(zk.getSessionId());

    verify("stat", "queued");
    verify("srvr", "Outstanding");
    verify("cons", sid);
    verify("dump", sid);

    zk.getData("/", true, null);

    verify("stat", "queued");
    verify("srvr", "Outstanding");
    verify("cons", sid);
    verify("dump", sid);

    verify("wchs", "watching 1");
    verify("wchp", sid);
    verify("wchc", sid);
    zk.close();

    verify("ruok", "imok");
    verify("envi", "java.version");
    verify("conf", "clientPort");
    verify("stat", "Outstanding");
    verify("srvr", "Outstanding");
    verify("cons", "queued");
    verify("dump", "Session");
    verify("wchs", "watch");
    verify("wchp", "");
    verify("wchc", "");

    verify("srst", "reset");
    verify("crst", "reset");

    verify("stat", "Outstanding");
    verify("srvr", "Outstanding");
    verify("cons", "queued");
    verify("mntr", "zk_server_state\tstandalone");
  }
Exemplo n.º 2
0
  protected TestableZooKeeper createClient(CountdownWatcher watcher, String hp, int timeout)
      throws IOException, InterruptedException {
    watcher.reset();
    TestableZooKeeper zk = new TestableZooKeeper(hp, timeout, watcher);
    if (!watcher.clientConnected.await(timeout, TimeUnit.MILLISECONDS)) {
      Assert.fail("Unable to connect to server");
    }
    synchronized (this) {
      if (!allClientsSetup) {
        LOG.error("allClients never setup");
        Assert.fail("allClients never setup");
      }
      if (allClients != null) {
        allClients.add(zk);
        JMXEnv.ensureAll(getHexSessionId(zk.getSessionId()));
      } else {
        // test done - close the zk, not needed
        zk.close();
      }
    }

    return zk;
  }