org.apache.zookeeper.KeeperException.NoNodeException Java Examples

The following examples show how to use org.apache.zookeeper.KeeperException.NoNodeException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZkController.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void checkOverseerDesignate() {
  try {
    byte[] data = zkClient.getData(ZkStateReader.ROLES, null, new Stat(), true);
    if (data == null) return;
    @SuppressWarnings({"rawtypes"})
    Map roles = (Map) Utils.fromJSON(data);
    if (roles == null) return;
    @SuppressWarnings({"rawtypes"})
    List nodeList = (List) roles.get("overseer");
    if (nodeList == null) return;
    if (nodeList.contains(getNodeName())) {
      ZkNodeProps props = new ZkNodeProps(Overseer.QUEUE_OPERATION, CollectionParams.CollectionAction.ADDROLE.toString().toLowerCase(Locale.ROOT),
          "node", getNodeName(),
          "role", "overseer");
      log.info("Going to add role {} ", props);
      getOverseerCollectionQueue().offer(Utils.toJSON(props));
    }
  } catch (NoNodeException nne) {
    return;
  } catch (Exception e) {
    log.warn("could not read the overseer designate ", e);
  }
}
 
Example #2
Source File: ZKUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the specified node and all parent nodes required for it to exist.  The creation of
 * parent znodes is not atomic with the leafe znode creation but the data is written atomically
 * when the leaf node is created.
 *
 * No watches are set and no errors are thrown if the node already exists.
 *
 * The nodes created are persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node
 * @throws KeeperException if unexpected zookeeper exception
 */
public static void createWithParents(ZKWatcher zkw, String znode, byte[] data)
  throws KeeperException {
  try {
    if(znode == null) {
      return;
    }
    zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
        CreateMode.PERSISTENT);
  } catch(KeeperException.NodeExistsException nee) {
    return;
  } catch(KeeperException.NoNodeException nne) {
    createWithParents(zkw, getParent(znode));
    createWithParents(zkw, znode, data);
  } catch(InterruptedException ie) {
    zkw.interruptedException(ie);
  }
}
 
Example #3
Source File: ZkStateReader.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private DocCollection fetchCollectionState(String coll, Watcher watcher) throws KeeperException, InterruptedException {
  String collectionPath = getCollectionPath(coll);
  while (true) {
    try {
      Stat stat = new Stat();
      byte[] data = zkClient.getData(collectionPath, watcher, stat, true);
      ClusterState state = ClusterState.createFromJson(stat.getVersion(), data, Collections.emptySet());
      ClusterState.CollectionRef collectionRef = state.getCollectionStates().get(coll);
      return collectionRef == null ? null : collectionRef.get();
    } catch (KeeperException.NoNodeException e) {
      if (watcher != null) {
        // Leave an exists watch in place in case a state.json is created later.
        Stat exists = zkClient.exists(collectionPath, watcher, true);
        if (exists != null) {
          // Rare race condition, we tried to fetch the data and couldn't find it, then we found it exists.
          // Loop and try again.
          continue;
        }
      }
      return null;
    }
  }
}
 
Example #4
Source File: LeaderElectionTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private String getLeaderUrl(final String collection, final String slice)
    throws KeeperException, InterruptedException {
  int iterCount = 60;
  while (iterCount-- > 0) {
    try {
      byte[] data = zkClient.getData(
          ZkStateReader.getShardLeadersPath(collection, slice), null, null,
          true);
      ZkCoreNodeProps leaderProps = new ZkCoreNodeProps(
          ZkNodeProps.load(data));
      return leaderProps.getCoreUrl();
    } catch (NoNodeException | SessionExpiredException e) {
      Thread.sleep(500);
    }
  }
  zkClient.printLayoutToStream(System.out);
  throw new RuntimeException("Could not get leader props for " + collection + " " + slice);
}
 
Example #5
Source File: TestConfigSetsAPIZkFailure.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public byte[] getData(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException {
  // we know we are doing a copy when we are getting data from the base config set and
  // the new config set (partially) exists
  String zkAddress = zkTestServer.getZkAddress();
  String chroot = zkAddress.substring(zkAddress.lastIndexOf("/"));
  if (path.startsWith(chroot + CONFIGS_ZKNODE + "/" + BASE_CONFIGSET_NAME)
      && !path.contains(ConfigSetProperties.DEFAULT_FILENAME)) {
    List<String> children = null;
    try {
      children = getChildren(chroot + CONFIGS_ZKNODE + "/" + CONFIGSET_NAME, null, null);
    } catch (KeeperException.NoNodeException e) {}
    if (children != null && children.size() > 0) {
      throw new RuntimeException("sample zookeeper error");
    }
  }
  return super.getData(path, stat, watcher);
}
 
Example #6
Source File: ZooKeeperCache.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public <T> CompletableFuture<Optional<T>> getDataAsync(final String path, final Deserializer<T> deserializer) {
    CompletableFuture<Optional<T>> future = new CompletableFuture<>();
    getDataAsync(path, this, deserializer).thenAccept(data -> {
        future.complete(data.map(e -> e.getKey()));
    }).exceptionally(ex -> {
        asyncInvalidate(path);
        if (ex.getCause() instanceof NoNodeException) {
            future.complete(Optional.empty());
        } else {
            future.completeExceptionally(ex.getCause());
        }

        return null;
    });
    return future;
}
 
Example #7
Source File: ZkStateReader.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Get current {@link AutoScalingConfig}.
 *
 * @param watcher optional {@link Watcher} to set on a znode to watch for config changes.
 * @return current configuration from <code>autoscaling.json</code>. NOTE:
 * this data is retrieved from ZK on each call.
 */
@SuppressWarnings({"unchecked"})
public AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws KeeperException, InterruptedException {
  Stat stat = new Stat();

  Map<String, Object> map = new HashMap<>();
  try {
    byte[] bytes = zkClient.getData(SOLR_AUTOSCALING_CONF_PATH, watcher, stat, true);
    if (bytes != null && bytes.length > 0) {
      map = (Map<String, Object>) fromJSON(bytes);
    }
  } catch (KeeperException.NoNodeException e) {
    // ignore
  }
  map.put(AutoScalingParams.ZK_VERSION, stat.getVersion());
  return new AutoScalingConfig(map);
}
 
Example #8
Source File: ZooKeeperCache.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public <T> CompletableFuture<Optional<Entry<T, Stat>>> getEntryAsync(final String path, final Deserializer<T> deserializer) {
    CompletableFuture<Optional<Entry<T, Stat>>> future = new CompletableFuture<>();
    getDataAsync(path, this, deserializer)
        .thenAccept(future::complete)
        .exceptionally(ex -> {
            asyncInvalidate(path);
            if (ex.getCause() instanceof NoNodeException) {
                future.complete(Optional.empty());
            } else {
                future.completeExceptionally(ex.getCause());
            }

            return null;
        });
    return future;
}
 
Example #9
Source File: ZkController.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void removeEphemeralLiveNode() throws KeeperException, InterruptedException {
  if (zkRunOnly) {
    return;
  }
  String nodeName = getNodeName();
  String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName;
  String nodeAddedPath = ZkStateReader.SOLR_AUTOSCALING_NODE_ADDED_PATH + "/" + nodeName;
  log.info("Remove node as live in ZooKeeper:{}", nodePath);
  List<Op> ops = new ArrayList<>(2);
  ops.add(Op.delete(nodePath, -1));
  ops.add(Op.delete(nodeAddedPath, -1));

  try {
    zkClient.multi(ops, true);
  } catch (NoNodeException e) {

  }
}
 
Example #10
Source File: TestAvatarSyncLastTxid.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrimaryCrash() throws Exception {
  createEdits(20);
  fs.close();
  InjectionHandler.set(new TestAvatarSyncLastTxidInjectionHandler());
  cluster.getPrimaryAvatar(0).avatar.shutdownAvatar();
  InjectionHandler.clear();
  ZookeeperTxId lastTxId = null;
  try {
    lastTxId = getLastTxid();
  } catch (NoNodeException e) {
    LOG.info("Expected exception", e);
    assertNull(lastTxId);
    return;
  }
  fail("Did not throw : " + NoNodeException.class);
}
 
Example #11
Source File: TestTSOClientConnectionToTSO.java    From phoenix-omid with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void beforeMethod() throws Exception {

    tsoPortForTest = TestUtils.getFreeLocalPort();

    int zkPortForTest = TestUtils.getFreeLocalPort();
    zkClusterForTest = TSO_HOST + ":" + zkPortForTest;
    LOG.info("Starting ZK Server in port {}", zkPortForTest);
    zkServer = TestUtils.provideTestingZKServer(zkPortForTest);
    LOG.info("ZK Server Started @ {}", zkServer.getConnectString());

    zkClient = TestUtils.provideConnectedZKClient(zkClusterForTest);

    Stat stat;
    try {
        zkClient.delete().forPath(CURRENT_TSO_PATH);
        stat = zkClient.checkExists().forPath(CURRENT_TSO_PATH);
        assertNull(stat, CURRENT_TSO_PATH + " should not exist");
    } catch (NoNodeException e) {
        LOG.info("{} ZNode did not exist", CURRENT_TSO_PATH);
    }

}
 
Example #12
Source File: OffsetGetter.java    From kmanager with Apache License 2.0 6 votes vote down vote up
public List<OffsetInfo> processTopic(String group, String topic) throws Exception {
	List<String> partitionIds = null;
	try {
		partitionIds = JavaConversions.seqAsJavaList(ZKUtils.getZKUtilsFromKafka()
				.getChildren(ZkUtils.BrokerTopicsPath() + "/" + topic + "/partitions"));
	} catch (Exception e) {
		if (e instanceof NoNodeException) {
			LOG.warn("Is topic >" + topic + "< exists!", e);
			return null;
		}
	}
	List<OffsetInfo> offsetInfos = new ArrayList<OffsetInfo>();
	OffsetInfo offsetInfo = null;
	if (partitionIds == null) {
		// TODO that topic exists in consumer node but not in topics node?!
		return null;
	}

	for (String partitionId : partitionIds) {
		offsetInfo = processPartition(group, topic, partitionId);
		if (offsetInfo != null) {
			offsetInfos.add(offsetInfo);
		}
	}
	return offsetInfos;
}
 
Example #13
Source File: TestAvatarSyncLastTxid.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoubleFailoverWithPrimaryCrash() throws Exception {
  // First failover
  createEdits(20);
  cluster.failOver();
  cluster.restartStandby();
  createEdits(20);
  fs.close();

  // Second failover.
  InjectionHandler.set(new TestAvatarSyncLastTxidInjectionHandler());
  cluster.killPrimary(0, true);
  InjectionHandler.clear();
  
  try {
    cluster.failOver();
  } catch (Exception e) {
    LOG.info("Expected exception : ", e);
    return;
  }
  fail("Did not throw : " + NoNodeException.class);
}
 
Example #14
Source File: ZooKeeperStateProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean replace(final StateMap oldValue, final Map<String, String> newValue, final String componentId) throws IOException {
    verifyEnabled();

    try {
        setState(newValue, (int) oldValue.getVersion(), componentId, false);
        return true;
    } catch (final NoNodeException nne) {
        return false;
    } catch (final IOException ioe) {
        final Throwable cause = ioe.getCause();
        if (cause != null && cause instanceof KeeperException) {
            final KeeperException ke = (KeeperException) cause;
            if (Code.BADVERSION == ke.code()) {
                return false;
            }
        }

        throw ioe;
    }
}
 
Example #15
Source File: OracleServer.java    From fluo with Apache License 2.0 6 votes vote down vote up
private void updateGcTimestamp() throws Exception {
  List<String> children;
  try {
    children = curator.getChildren().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS);
  } catch (NoNodeException nne) {
    children = Collections.emptyList();
  }

  long oldestTs = Long.MAX_VALUE;
  boolean nodeFound = false;

  for (String child : children) {
    Long ts = LongUtil.fromByteArray(
        curator.getData().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS + "/" + child));
    nodeFound = true;
    if (ts < oldestTs) {
      oldestTs = ts;
    }
  }

  if (nodeFound) {
    updateAdvertisedGcTimestamp(oldestTs);
  } else {
    updateAdvertisedGcTimestamp(currentTs);
  }
}
 
Example #16
Source File: CuratorManager.java    From Singularity with Apache License 2.0 6 votes vote down vote up
protected List<String> getChildren(String root) {
  LOG.trace("Preparing to call getChildren() on {}", root);
  final long start = System.currentTimeMillis();
  int numChildren = 0;

  try {
    final List<String> children = curator.getChildren().forPath(root);
    numChildren = children.size();

    return children;
  } catch (NoNodeException nne) {
    return Collections.emptyList();
  } catch (Throwable t) {
    throw new RuntimeException(t);
  } finally {
    log(
      OperationType.GET_CHILDREN,
      Optional.of(numChildren),
      Optional.empty(),
      start,
      root
    );
  }
}
 
Example #17
Source File: ServiceUnitZkUtils.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * cleanupNamespaceNodes is only called when the NamespaceService is initialized. So, no need for synchronization.
 *
 * @throws Exception
 */
private static final void cleanupNamespaceNodes(ZooKeeper zkc, String root, String selfBrokerUrl) throws Exception {
    // we don't need a watch here since we are only cleaning up the stale ephemeral nodes from previous session
    try {
        for (String node : zkc.getChildren(root, false)) {
            String currentPath = root + "/" + node;
            // retrieve the content and try to decode with ServiceLookupData
            List<String> children = zkc.getChildren(currentPath, false);
            if (children.size() == 0) {
                // clean up a single namespace node
                cleanupSingleNamespaceNode(zkc, currentPath, selfBrokerUrl);
            } else {
                // this is an intermediate node, which means this is v2 namespace path
                cleanupNamespaceNodes(zkc, currentPath, selfBrokerUrl);
            }
        }
    } catch (NoNodeException nne) {
        LOG.info("No children for [{}]", nne.getPath());
    }
}
 
Example #18
Source File: ZooKeeperStateProvider.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean replace(final StateMap oldValue, final Map<String, String> newValue, final String componentId) throws IOException {
    verifyEnabled();

    try {
        setState(newValue, (int) oldValue.getVersion(), componentId, false);
        return true;
    } catch (final NoNodeException nne) {
        return false;
    } catch (final IOException ioe) {
        final Throwable cause = ioe.getCause();
        if (cause != null && cause instanceof KeeperException) {
            final KeeperException ke = (KeeperException) cause;
            if (Code.BADVERSION == ke.code()) {
                return false;
            }
        }

        throw ioe;
    }
}
 
Example #19
Source File: StateManager.java    From Singularity with Apache License 2.0 6 votes vote down vote up
private List<SingularityHostState> getHostStates() {
  List<String> children = getChildren(ROOT_PATH);
  List<SingularityHostState> states = Lists.newArrayListWithCapacity(children.size());

  for (String child : children) {
    try {
      byte[] bytes = curator.getData().forPath(ZKPaths.makePath(ROOT_PATH, child));

      states.add(hostStateTranscoder.fromBytes(bytes));
    } catch (NoNodeException nne) {} catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  return states;
}
 
Example #20
Source File: CuratorManager.java    From Singularity with Apache License 2.0 5 votes vote down vote up
protected Optional<Stat> checkExists(String path) {
  try {
    Stat stat = curator.checkExists().forPath(path);
    return Optional.ofNullable(stat);
  } catch (NoNodeException nne) {
    return Optional.empty();
  } catch (InterruptedException ie) {
    Thread.currentThread().interrupt();
    return Optional.empty();
  } catch (Throwable t) {
    throw new RuntimeException(t);
  }
}
 
Example #21
Source File: ZooKeeperStateProvider.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void setState(final Map<String, String> stateValues, final int version, final String componentId) throws IOException {
    try {
        setState(stateValues, version, componentId, true);
    } catch (final NoNodeException nne) {
        // should never happen because we are passing 'true' for allowNodeCreation
        throw new IOException("Unable to create Node in ZooKeeper to set state for component with ID " + componentId, nne);
    }
}
 
Example #22
Source File: CuratorManager.java    From Singularity with Apache License 2.0 5 votes vote down vote up
protected int getNumChildren(String path) {
  try {
    Stat s = curator.checkExists().forPath(path);
    if (s != null) {
      return s.getNumChildren();
    }
  } catch (NoNodeException nne) {} catch (Throwable t) {
    throw new RuntimeException(t);
  }

  return 0;
}
 
Example #23
Source File: NoopLoadManager.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws PulsarServerException {
    lookupServiceAddress = pulsar.getAdvertisedAddress() + ":" + pulsar.getConfiguration().getWebServicePort().get();
    localResourceUnit = new SimpleResourceUnit(String.format("http://%s", lookupServiceAddress),
            new PulsarResourceDescription());
    zkClient = pulsar.getZkClient();

    localData = new LocalBrokerData(pulsar.getSafeWebServiceAddress(), pulsar.getWebServiceAddressTls(),
            pulsar.getSafeBrokerServiceUrl(), pulsar.getBrokerServiceUrlTls());
    localData.setProtocols(pulsar.getProtocolDataToAdvertise());
    String brokerZnodePath = LoadManager.LOADBALANCE_BROKERS_ROOT + "/" + lookupServiceAddress;

    try {
        // When running in standalone, this error can happen when killing the "standalone" process
        // ungracefully since the ZK session will not be closed and it will take some time for ZK server
        // to prune the expired sessions after startup.
        // Since there's a single broker instance running, it's safe, in this mode, to remove the old lock

        // Delete and recreate z-node
        try {
            if (zkClient.exists(brokerZnodePath, null) != null) {
                zkClient.delete(brokerZnodePath, -1);
            }
        } catch (NoNodeException nne) {
            // Ignore if z-node was just expired
        }

        ZkUtils.createFullPathOptimistic(zkClient, brokerZnodePath, localData.getJsonBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);

    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
Example #24
Source File: ZookeeperDiscoveryClientTests.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Test
public void getServicesShouldReturnEmptyWhenNoNodeException() throws Exception {
	// given:
	ServiceDiscovery<ZookeeperInstance> serviceDiscovery = mock(
			ServiceDiscovery.class);
	when(serviceDiscovery.queryForNames()).thenThrow(new NoNodeException());
	ZookeeperDiscoveryClient discoveryClient = new ZookeeperDiscoveryClient(
			serviceDiscovery, null, new ZookeeperDiscoveryProperties());
	// when:
	List<String> services = discoveryClient.getServices();
	// then:
	then(services).isEmpty();
}
 
Example #25
Source File: ZookeeperCacheLoader.java    From pulsar with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize ZooKeeper session and creates broker cache list
 *
 * @param zookeeperServers
 * @throws Exception
 */
public ZookeeperCacheLoader(ZooKeeperClientFactory factory, String zookeeperServers, int zookeeperSessionTimeoutMs) throws Exception {
    this.zkClient = factory.create(zookeeperServers, SessionType.AllowReadOnly, zookeeperSessionTimeoutMs).get();
    this.localZkCache = new LocalZooKeeperCache(zkClient,
            (int) TimeUnit.MILLISECONDS.toSeconds(zookeeperSessionTimeoutMs), this.orderedExecutor);

    this.brokerInfo = new ZooKeeperDataCache<LoadManagerReport>(localZkCache) {
        @Override
        public LoadManagerReport deserialize(String key, byte[] content) throws Exception {
            return ObjectMapperFactory.getThreadLocal().readValue(content, LoadManagerReport.class);
        }
    };

    this.availableBrokersCache = new ZooKeeperChildrenCache(getLocalZkCache(), LOADBALANCE_BROKERS_ROOT);
    this.availableBrokersCache.registerListener((path, brokerNodes, stat) -> {
        try {
            updateBrokerList(brokerNodes);
        } catch (Exception e) {
            log.warn("Error updating broker info after broker list changed.", e);
        }
    });

    // Do initial fetch of brokers list
    try {
        updateBrokerList(availableBrokersCache.get());
    } catch (NoNodeException nne) { // can happen if no broker started yet
        updateBrokerList(Collections.emptySet());
    }
}
 
Example #26
Source File: LocalZooKeeperConnectionService.java    From pulsar with Apache License 2.0 5 votes vote down vote up
public static void deleteIfExists(ZooKeeper zk, String path, int version)
        throws KeeperException, InterruptedException {
    try {
        zk.delete(path, version);
    } catch (NoNodeException e) {
        // OK
        LOG.debug("Delete skipped for non-existing znode: path={}", path);
    }
}
 
Example #27
Source File: OwnershipCacheTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testRemoveOwnership() throws Exception {
    OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory, null);
    NamespaceName testNs = NamespaceName.get("pulsar/test/ns-7");
    NamespaceBundle bundle = bundleFactory.getFullBundle(testNs);
    // case 1: no one owns the namespace
    assertFalse(cache.getOwnerAsync(bundle).get().isPresent());

    cache.removeOwnership(bundle).get();
    assertTrue(cache.getOwnedBundles().isEmpty());

    // case 2: this broker owns the namespace
    NamespaceEphemeralData data1 = cache.tryAcquiringOwnership(bundle).get();
    assertEquals(data1.getNativeUrl(), selfBrokerUrl);
    assertFalse(data1.isDisabled());
    assertEquals(cache.getOwnedBundles().size(), 1);
    cache.removeOwnership(bundle);
    Thread.sleep(500);
    assertTrue(cache.getOwnedBundles().isEmpty());

    Thread.sleep(500);

    try {
        zkCache.getZooKeeper().getData(ServiceUnitZkUtils.path(bundle), null, null);
        fail("Should have failed");
    } catch (NoNodeException nne) {
        // OK
    }
}
 
Example #28
Source File: ServiceUnitZkUtils.java    From pulsar with Apache License 2.0 5 votes vote down vote up
private static void createZnodeOptimistic(ZooKeeper zkc, String path, String data, CreateMode mode)
        throws KeeperException, InterruptedException {
    try {
        // create node optimistically
        checkNotNull(LocalZooKeeperConnectionService.createIfAbsent(zkc, path, data, mode));
    } catch (NoNodeException e) {
        // if path contains multiple levels after the root, create the intermediate nodes first
        String[] parts = path.split("/");
        if (parts.length > 3) {
            String int_path = path.substring(0, path.lastIndexOf("/"));
            if (zkc.exists(int_path, false) == null) {
                // create the intermediate nodes
                try {
                    ZkUtils.createFullPathOptimistic(zkc, int_path, new byte[0], Ids.OPEN_ACL_UNSAFE,
                            CreateMode.PERSISTENT);
                } catch (KeeperException.NodeExistsException nee) {
                    LOG.debug(
                            "Other broker preempted the full intermediate path [{}] already. Continue for acquiring the leaf ephemeral node.",
                            int_path);
                }
            }
            checkNotNull(LocalZooKeeperConnectionService.createIfAbsent(zkc, path, data, mode));
        } else {
            // If failed to create immediate child of root node, throw exception
            throw e;
        }
    }
}
 
Example #29
Source File: ObserverStoreV2.java    From fluo with Apache License 2.0 5 votes vote down vote up
@Override
public void clear(CuratorFramework curator) throws Exception {
  try {
    curator.delete().forPath(CONFIG_FLUO_OBSERVERS2);
  } catch (NoNodeException nne) {
    // nothing to delete
  }
}
 
Example #30
Source File: HostInfosServiceImpl.java    From vespa with Apache License 2.0 5 votes vote down vote up
private Optional<byte[]> readBytesFromZk(String path) throws Exception {
    try {
        return Optional.of(curator.framework().getData().forPath(path));
    } catch (NoNodeException e) {
        return Optional.empty();
    }
}