@Override public void delete(String path) throws KeeperException { reporter.time(tag, "delete", () -> { client.delete(path); return null; }); }
@Override public void delete(String path, int version) throws KeeperException { reporter.time(tag, "delete", () -> { client.delete(path, version); return null; }); }
private void delete(final String node) throws KeeperException { final ZooKeeperClient client = client("delete"); final String nodePath = ZKPaths.makePath(path, node); if (client.stat(nodePath) != null) { log.debug("deleting node: {}", nodePath); client.delete(nodePath); } }
private void trimStatusEvents(List<String> events, JobId jobId) { // CleanupExecutor only has one thread so can assume no others are fiddling as we do this. // All this to sort numerically instead of lexically.... final List<Long> eventsAsLongs = Lists.newArrayList( Iterables.transform(events, new Function<String, Long>() { @Override public Long apply(String name) { return Long.valueOf(name); } })); Collections.sort(eventsAsLongs); for (int i = 0; i < (eventsAsLongs.size() - MAX_NUMBER_STATUS_EVENTS_TO_RETAIN); i++) { try { client.delete(Paths.historyJobHostEventsTimestamp(jobId, hostname, eventsAsLongs.get(i))); } catch (KeeperException e) { log.warn("failure deleting overflow of status items - we're hoping a later" + " execution will fix", e); } } } }
final String nodePath = ZKPaths.makePath(path, node); log.debug("sync: deleting node {}", nodePath); client.delete(nodePath); remote.remove(node);
@Test public void testZooKeeperClient() throws Exception { // Create the cluster ID node zk().curatorWithSuperAuth().newNamespaceAwareEnsurePath(Paths.configId(zkClusterId)) .ensure(zk().curatorWithSuperAuth().getZookeeperClient()); // We need to create a new curator because ZooKeeperClient will try to start it, // and zk().curator() has already been started. final ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = CuratorFrameworkFactory.builder() .retryPolicy(retryPolicy) .connectString(zk().connectString()) .build(); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zkClusterId); client.start(); // This should work since the cluster ID exists client.create("/test"); // Now let's remove the cluster ID client.delete(Paths.configId(zkClusterId)); // Sleep so the watcher thread in ZooKeeperClient has a chance to update state Thread.sleep(500); // Try the same operation again, and it should fail this time try { client.ensurePath(Paths.configJobs()); fail("ZooKeeper operation should have failed because cluster ID was removed"); } catch (IllegalStateException ignore) { // ignored } }
@Override public void delete(String path) throws KeeperException { try { client.delete(path); } catch (KeeperException e) { reporter.checkException(e, tag, "delete"); throw e; } }
@Override public void delete(String path, int version) throws KeeperException { try { client.delete(path, version); } catch (KeeperException e) { reporter.checkException(e, tag, "delete"); throw e; } }
private void delete(final String node) throws KeeperException { final ZooKeeperClient client = client("delete"); final String nodePath = ZKPaths.makePath(path, node); if (client.stat(nodePath) != null) { log.debug("deleting node: {}", nodePath); client.delete(nodePath); } }
private void trimStatusEvents(final List<String> events, final String eventsPath) { // All this to sort numerically instead of lexically.... final List<Long> eventsAsLongs = Lists.newArrayList(Iterables.transform(events, new Function<String, Long>() { @Override public Long apply(String name) { return Long.valueOf(name); } })); Collections.sort(eventsAsLongs); for (int i = 0; i < (eventsAsLongs.size() - getMaxEventsPerPath()); i++) { try { client.delete(getZkEventPath(eventsPath, eventsAsLongs.get(i))); } catch (KeeperException e) { log.warn("failure deleting overflow of status events - we're hoping a later" + " execution will fix", e); } } } }
final String nodePath = ZKPaths.makePath(path, node); log.debug("sync: deleting node {}", nodePath); client.delete(nodePath); remote.remove(node);
@Override public void removeDeploymentGroup(final String name) throws DeploymentGroupDoesNotExistException { log.info("removing deployment-group: name={}", name); final ZooKeeperClient client = provider.get("removeDeploymentGroup"); try { client.ensurePath(Paths.configDeploymentGroups()); client.delete(Paths.configDeploymentGroup(name)); if (client.exists(Paths.statusDeploymentGroupHosts(name)) != null) { client.delete(Paths.statusDeploymentGroupHosts(name)); } if (client.exists(Paths.statusDeploymentGroup(name)) != null) { client.delete(Paths.statusDeploymentGroup(name)); } } catch (final NoNodeException e) { throw new DeploymentGroupDoesNotExistException(name); } catch (final KeeperException e) { throw new HeliosRuntimeException("removing deployment-group " + name + " failed", e); } }