public NamespaceBundles getBundles(NamespaceName nsname, BundlesData bundleData) { long[] partitions; if (bundleData == null) { partitions = new long[] { Long.decode(FIRST_BOUNDARY), Long.decode(LAST_BOUNDARY) }; } else { partitions = new long[bundleData.boundaries.size()]; for (int i = 0; i < bundleData.boundaries.size(); i++) { partitions[i] = Long.decode(bundleData.boundaries.get(i)); } } return new NamespaceBundles(nsname, partitions, this); }
public NamespaceBundles(NamespaceName nsname, SortedSet<Long> partitionsSet, NamespaceBundleFactory factory) throws Exception { this(nsname, convertPartitions(partitionsSet), factory); }
public CompletableFuture<NamespaceBundle> getBundleAsync(DestinationName topic) { return bundleFactory.getBundlesAsync(topic.getNamespaceObject()) .thenApply(bundles -> bundles.findBundle(topic)); }
/** * Method to remove ownership of all owned bundles * * @param bundles * <code>NamespaceBundles</code> to remove from ownership cache */ public CompletableFuture<Void> removeOwnership(NamespaceBundles bundles) { List<CompletableFuture<Void>> allFutures = Lists.newArrayList(); for (NamespaceBundle bundle : bundles.getBundles()) { if (getOwnedBundle(bundle) == null) { // continue continue; } allFutures.add(this.removeOwnership(bundle)); } return FutureUtil.waitForAll(allFutures); }
NamespaceBundles splittedNsBundles = new NamespaceBundles(nsname, partitions, this); List<NamespaceBundle> splittedBundles = splittedNsBundles.getBundles().subList(splitPartition, (splitPartition + numBundles)); return new ImmutablePair<NamespaceBundles, List<NamespaceBundle>>(splittedNsBundles, splittedBundles);
public int getBundleCount(NamespaceName namespace) throws Exception { return bundleFactory.getBundles(namespace).size(); }
public NamespaceBundle getFullBundle(NamespaceName fqnn) throws Exception { return bundlesCache.synchronous().get(fqnn).getFullBundle(); }
public NamespaceBundle findBundle(DestinationName dn) { checkArgument(this.nsname.equals(dn.getNamespaceObject())); long hashCode = factory.getLongHashCode(dn.toString()); return getBundle(hashCode); }
protected NamespaceBundle validateNamespaceBundleRange(NamespaceName fqnn, BundlesData bundles, String bundleRange) { try { checkArgument(bundleRange.contains("_"), "Invalid bundle range"); String[] boundaries = bundleRange.split("_"); Long lowerEndpoint = Long.decode(boundaries[0]); Long upperEndpoint = Long.decode(boundaries[1]); Range<Long> hashRange = Range.range(lowerEndpoint, BoundType.CLOSED, upperEndpoint, (upperEndpoint.equals(NamespaceBundles.FULL_UPPER_BOUND)) ? BoundType.CLOSED : BoundType.OPEN); NamespaceBundle nsBundle = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundle(fqnn, hashRange); NamespaceBundles nsBundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(fqnn, bundles); nsBundles.validateBundle(nsBundle); return nsBundle; } catch (Exception e) { log.error("[{}] Failed to validate namespace bundle {}/{}", clientAppId(), fqnn.toString(), bundleRange, e); throw new RestException(e); } }
NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(nsName); Exception exception = null; for (NamespaceBundle nsBundle : bundles.getBundles()) { try {
NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(nsName); Exception exception = null; for (NamespaceBundle nsBundle : bundles.getBundles()) { try {
public NamespaceBundle getBundle(DestinationName destination) throws Exception { return bundleFactory.getBundles(destination.getNamespaceObject()).findBundle(destination); }
NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(nsName); Exception exception = null; for (NamespaceBundle nsBundle : bundles.getBundles()) { try {
/** * Checks whether the broker is the owner of all the namespace bundles. Otherwise, if authoritative is false, it * will throw an exception to redirect to assigned owner or leader; if authoritative is true then it will try to * acquire all the namespace bundles. * * @param fqnn * @param authoritative * @param readOnly * @param bundleData */ protected void validateNamespaceOwnershipWithBundles(String property, String cluster, String namespace, boolean authoritative, boolean readOnly, BundlesData bundleData) { NamespaceName fqnn = new NamespaceName(property, cluster, namespace); try { NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(fqnn, bundleData); for (NamespaceBundle bundle : bundles.getBundles()) { validateBundleOwnership(bundle, authoritative, readOnly); } } catch (WebApplicationException wae) { // propagate already wrapped-up WebApplicationExceptions throw wae; } catch (Exception oe) { log.debug(String.format("Failed to find owner for namespace %s", fqnn), oe); throw new RestException(oe); } }
for (NamespaceBundle bundle : bundles.getBundles()) {