@Override public void remove(final String key) { try { client.delete().deletingChildrenIfNeeded().forPath(key); //CHECKSTYLE:OFF } catch (final Exception ex) { //CHECKSTYLE:ON RegExceptionHandler.handleException(ex); } }
@Override public void persistEphemeral(final String key, final String value) { try { if (isExisted(key)) { client.delete().deletingChildrenIfNeeded().forPath(key); } client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Charsets.UTF_8)); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON CuratorZookeeperExceptionHandler.handleException(ex); } }
/** * 删除数据 * * @param key */ public void remove(final String key) { try { client.delete().deletingChildrenIfNeeded().forPath(key); } catch (Exception ex) { Logs.RSD.error("removeAndClose:{}", key, ex); throw new ZKException(ex); } }
public void deleteTableMetadata(SchemaTableName tableName) { try { curator.delete().deletingChildrenIfNeeded().forPath(getTablePath(tableName)); } catch (Exception e) { throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when deleting table metadata", e); } }
public void deleteViewMetadata(SchemaTableName tableName) { try { curator.delete().deletingChildrenIfNeeded().forPath(getTablePath(tableName)); } catch (Exception e) { throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when deleting view metadata", e); } }
@Override public void persistEphemeral(final String key, final String value) { try { if (isExisted(key)) { client.delete().deletingChildrenIfNeeded().forPath(key); } client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Charsets.UTF_8)); //CHECKSTYLE:OFF } catch (final Exception ex) { //CHECKSTYLE:ON RegExceptionHandler.handleException(ex); } }
@Override public void clear() { try { curator.delete().deletingChildrenIfNeeded().forPath(mapPath); curator.create().creatingParentsIfNeeded().forPath(mapPath); } catch (Exception e) { throw new ZKException(e); } }
/** * Delete a ZNode. * @param path Path of the ZNode. * @return If the znode was deleted. * @throws Exception If it cannot contact ZooKeeper. */ public boolean delete(final String path) throws Exception { if (exists(path)) { curator.delete().deletingChildrenIfNeeded().forPath(path); return true; } return false; }
/** * 注册临时数据 * * @param key * @param value */ public void registerEphemeral(final String key, final String value, boolean cacheNode) { try { if (isExisted(key)) { client.delete().deletingChildrenIfNeeded().forPath(key); } client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Constants.UTF_8)); if (cacheNode) ephemeralNodes.put(key, value); } catch (Exception ex) { Logs.RSD.error("persistEphemeral:{},{}", key, value, ex); throw new ZKException(ex); } }
@Override public V remove(Object key) { try { V result = get(key); if (result != null) curator.delete().deletingChildrenIfNeeded().forPath(keyPath(key)); return result; } catch (Exception e) { throw new ZKException(e); } }
@Test public void testAgent() throws Exception { startDefaultMaster("--zk-cluster-id=" + zkClusterId); startDefaultAgent(testHost(), "--zk-cluster-id=" + zkClusterId); awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS); // Create job and deploy it final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND); deployJob(jobId, testHost()); final TaskStatus runningStatus = awaitTaskState(jobId, testHost(), RUNNING); final String containerId = runningStatus.getContainerId(); // Delete the config node which contains the cluster ID and all the job definitions zk().curatorWithSuperAuth().delete().deletingChildrenIfNeeded().forPath("/config"); // Sleep for a second so agent has a chance to react to deletion Thread.sleep(1000); // Make sure the agent didn't stop the job try (final DockerClient docker = getNewDockerClient()) { final List<Container> containers = docker.listContainers(); final CustomTypeSafeMatcher<Container> containerIdMatcher = new CustomTypeSafeMatcher<Container>("Container with id " + containerId) { @Override protected boolean matchesSafely(Container container) { return container.id().equals(containerId); } }; assertContainersMatch(containers, containerIdMatcher); } }
@Override public void applyMigration() { try { try { curator.delete().deletingChildrenIfNeeded().forPath("/slaves"); } catch (NoNodeException nee) {} try { curator.delete().deletingChildrenIfNeeded().forPath("/racks"); } catch (NoNodeException nee) {} } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void applyMigration() { try { try { curator.delete().deletingChildrenIfNeeded().forPath("/slaves"); } catch (NoNodeException nee) {} try { curator.delete().deletingChildrenIfNeeded().forPath("/racks"); } catch (NoNodeException nee) {} } catch (Exception e) { throw Throwables.propagate(e); } }
protected SingularityDeleteResult delete(String path) { final long start = System.currentTimeMillis(); try { curator.delete().deletingChildrenIfNeeded().forPath(path); return SingularityDeleteResult.DELETED; } catch (NoNodeException nne) { LOG.trace("Tried to delete an item at path {} that didn't exist", path); return SingularityDeleteResult.DIDNT_EXIST; } catch (Throwable t) { throw Throwables.propagate(t); } finally { log(OperationType.DELETE, Optional.absent(), Optional.<Integer> absent(), start, path); } }
public void deleteWithoutGuaranteed(String path, boolean isDeleteChildren) { try { if (!exist(path)) { return; } DeleteBuilder builder = client.delete(); if (isDeleteChildren) { builder.deletingChildrenIfNeeded().forPath(path); } else { builder.forPath(path); } } catch (Throwable e) { throw checkException(String.format("Fail to delete node of path: %s", path), e); } }
@Override @After public void tearDown() throws Exception { this.metadataStore.stop(); this.client.delete().deletingChildrenIfNeeded().forPath(this.metadataStore.getRoot()); }
public void deleteData(String path) throws Exception { if (zookeeperClient.checkExists().forPath(path) != null) { zookeeperClient.delete().deletingChildrenIfNeeded().forPath(path); } }
public void deleteData(String path) throws Exception { if (zookeeperStarter.curator().checkExists().forPath(path) != null) { zookeeperStarter.curator().delete().deletingChildrenIfNeeded().forPath(path); } }
/** * Delete the node recursively * @param path the node path */ public void deleteRecursively(String path){ try { client.delete().deletingChildrenIfNeeded().forPath(path); } catch (Exception e){ handleConnectionLoss(e); throw new ZkException(e); } }
private void removeConsumerEntries(SubscriptionName subscriptionName, String consumerId) { try { curator.delete().deletingChildrenIfNeeded() .forPath(zookeeperPaths.consumersRatePath(cluster, subscriptionName, consumerId)); } catch (KeeperException.NoNodeException e) { // ignore } catch (Exception e) { throw new InternalProcessingException(e); } }