String[] args = co.getArgArray(); String cmd = co.getCommand(); if (args.length < 1) { usage(); return false; cl.parseCommand(history.get(i)); if (cl.getCommand().equals( "redo" )){ System.out.println("No redoing redos"); return false;
public ZooKeeperMain(String args[]) throws IOException, InterruptedException { cl.parseOptions(args); System.out.println("Connecting to " + cl.getOption("server")); connectToZK(cl.getOption("server")); //zk = new ZooKeeper(cl.getOption("server"), // Integer.parseInt(cl.getOption("timeout")), new MyWatcher()); }
String[] args = co.getArgArray(); String cmd = co.getCommand(); if (args.length < 1) { usage(); return false; cl.parseCommand(history.get(i)); if (cl.getCommand().equals( "redo" )){ System.out.println("No redoing redos"); return false;
@SuppressWarnings("unchecked") void run() throws KeeperException, IOException, InterruptedException { if (cl.getCommand() == null) { System.out.println("Welcome to ZooKeeper!");
public void executeLine(String line) throws InterruptedException, IOException, KeeperException { if (!line.equals("")) { cl.parseCommand(line); addToHistory(commandCount,line); processCmd(cl); commandCount++; } }
protected void connectToZK(String newHost) throws InterruptedException, IOException { if (zk != null && zk.getState().isAlive()) { zk.close(); } host = newHost; zk = new ZooKeeper(host, Integer.parseInt(cl.getOption("timeout")), new MyWatcher()); }
public ZooKeeperMain(String args[]) throws IOException, InterruptedException { cl.parseOptions(args); System.out.println("Connecting to " + cl.getOption("server")); connectToZK(cl.getOption("server")); //zk = new ZooKeeper(cl.getOption("server"), // Integer.parseInt(cl.getOption("timeout")), new MyWatcher()); }
@SuppressWarnings("unchecked") void run() throws KeeperException, IOException, InterruptedException { if (cl.getCommand() == null) { System.out.println("Welcome to ZooKeeper!");
zkMain.cl.parseCommand(cmdstring); Assert.assertTrue( "Removewatches cmd fails to remove child/data watches",
protected boolean processZKCmd(MyCommandOptions co) throws CliException, IOException, InterruptedException { String[] args = co.getArgArray(); String cmd = co.getCommand(); if (args.length < 1) { usage(); throw new MalformedCommandException("Command index out of range"); cl.parseCommand(history.get(i)); if (cl.getCommand().equals("redo")) { throw new MalformedCommandException("No redoing redos");
void run() throws CliException, IOException, InterruptedException { if (cl.getCommand() == null) { System.out.println("Welcome to ZooKeeper!");
zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Removewatches cmd fails to remove child watches", zkMain.processZKCmd(zkMain.cl));
zkMain.cl.parseCommand(cmdstring0); Assert.assertFalse(zkMain.processZKCmd(zkMain.cl)); Assert.assertEquals(null, zk.exists("/a/b/v", null)); zkMain.cl.parseCommand(cmdstring1); Assert.assertFalse(zkMain.processZKCmd(zkMain.cl)); Assert.assertNull(zk.exists("/a", null));
zkMain.cl.parseCommand(cmdstring1); Assert.assertTrue( "Removewatches cmd fails to remove pre-create watches", zkMain.cl.parseCommand(cmdstring2); Assert.assertTrue("Removewatches cmd fails to remove data watches", zkMain.processZKCmd(zkMain.cl));
zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Doesn't create node without data", zkMain .processZKCmd(zkMain.cl)); zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Doesn't create node without data", zkMain .processZKCmd(zkMain.cl)); zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Doesn't create node without data", zkMain .processZKCmd(zkMain.cl)); zkMain.cl.parseCommand(cmdstring); try { Assert.assertTrue("Created node with wrong option", zkMain
zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Removewatches cmd fails to remove child watches", zkMain.processZKCmd(zkMain.cl));
/** * Test verifies deletion of NodeDataChanged watches */ @Test(timeout = 30000) public void testRemoveNodeDataChangedWatches() throws Exception { LOG.info("Adding data watcher using getData()"); List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>(); expectedEvents.add(EventType.DataWatchRemoved); MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1); zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zk.getData("/testnode1", myWatcher, null); String cmdstring = "removewatches /testnode1 -d"; LOG.info("Remove watchers using shell command : {}", cmdstring); zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Removewatches cmd fails to remove data watches", zkMain.processZKCmd(zkMain.cl)); LOG.info("Waiting for the DataWatchRemoved event"); myWatcher.matches(); // verifying that other path data watches are removed Assert.assertEquals( "Data watches are not removed : " + zk.getDataWatches(), 0, zk .getDataWatches().size()); }
public void executeLine(String line) throws InterruptedException, IOException, KeeperException { if (!line.equals("")) { cl.parseCommand(line); addToHistory(commandCount,line); processCmd(cl); commandCount++; } }
/** * Test verifies deletion of NodeChildrenChanged watches */ @Test(timeout = 30000) public void testRemoveNodeChildrenChangedWatches() throws Exception { List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>(); expectedEvents.add(EventType.ChildWatchRemoved); MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1); zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); LOG.info("Adding child changed watcher"); zk.getChildren("/testnode1", myWatcher); String cmdstring = "removewatches /testnode1 -c"; LOG.info("Remove watchers using shell command : {}", cmdstring); zkMain.cl.parseCommand(cmdstring); Assert.assertTrue("Removewatches cmd fails to remove child watches", zkMain.processZKCmd(zkMain.cl)); myWatcher.matches(); Assert.assertEquals( "Failed to remove child watches : " + zk.getChildWatches(), 0, zk.getChildWatches().size()); }
protected void connectToZK(String newHost) throws InterruptedException, IOException { if (zk != null && zk.getState().isAlive()) { zk.close(); } host = newHost; boolean readOnly = cl.getOption("readonly") != null; zk = new ZooKeeper(host, Integer.parseInt(cl.getOption("timeout")), new MyWatcher(), readOnly); }