public void verifyNotExists(String path) throws IOException { if (curatorService.zkPathExists(path)) { fail("Path should not exist: " + path); } } }
public void verifyNotExists(String path) throws IOException { if (curatorService.zkPathExists(path)) { fail("Path should not exist: " + path); } } }
/** * Create or update an entry. * * @param path path * @param data data * @param acl ACL for path -used when creating a new entry * @param overwrite enable overwrite * @return true if the entry was created, false if it was simply updated. * @throws IOException */ public boolean zkSet(String path, CreateMode mode, byte[] data, List<ACL> acl, boolean overwrite) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); if (!zkPathExists(path)) { zkCreate(path, mode, data, acl); return true; } else { if (overwrite) { zkUpdate(path, data); return false; } else { throw new FileAlreadyExistsException(path); } } }
/** * Create or update an entry * @param path path * @param data data * @param acl ACL for path -used when creating a new entry * @param overwrite enable overwrite * @throws IOException * @return true if the entry was created, false if it was simply updated. */ public boolean zkSet(String path, CreateMode mode, byte[] data, List<ACL> acl, boolean overwrite) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); if (!zkPathExists(path)) { zkCreate(path, mode, data, acl); return true; } else { if (overwrite) { zkUpdate(path, data); return false; } else { throw new FileAlreadyExistsException(path); } } }
@Test public void testExistsMissing() throws Throwable { assertFalse(curatorService.zkPathExists(MISSING)); }
@Test public void testExists() throws Throwable { assertTrue(curatorService.zkPathExists("/")); }
@Test public void testExists() throws Throwable { assertTrue(curatorService.zkPathExists("/")); }
@Test public void testExistsMissing() throws Throwable { assertFalse(curatorService.zkPathExists(MISSING)); }
.currentUser(), YarnServiceConstants.APP_TYPE, exampleApp.getName()); Assert.assertTrue("Registry ZK service path doesn't exist", getCuratorService().zkPathExists(serviceZKPath)); getCuratorService().zkPathExists(serviceZKPath));