name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
pulsar_NarUnpacker_makeFile_rdh
/** * Creates the specified file, whose contents will come from the <tt>InputStream</tt>. * * @param inputStream * the contents of the file to create. * @param file * the file to create. * @throws IOException * if the file could not be created. */ private static void makeFile(final InputStream inputStrea...
3.26
pulsar_HierarchicalLedgerUtils_ledgerListToSet_rdh
/** * Get all ledger ids in the given zk path. * * @param ledgerNodes * List of ledgers in the given path * example:- {L1652, L1653, L1650} * @param path * The zookeeper path of the ledger ids. The path should start with {@ledgerRootPath } * example (with ledgerRootPath = /ledgers):- /ledgers/00/0053 *...
3.26
pulsar_NamespaceBundleStatsComparator_compare_rdh
// sort in reverse order, maximum loaded should be on top public int compare(String a, String b) { int result = 0; if (this.f0 == ResourceType.CPU) { result = map.get(a).compareByMsgRate(map.get(b)); } else if (this.f0 == ResourceType.Memory) { result = map.get(a).compareByTopicConnections(map.get(b)); } els...
3.26
pulsar_BookKeeperTestClient_waitForBookieInSet_rdh
/** * Wait for bookie to appear in either the writable set of bookies, * or the read only set of bookies. Also ensure that it doesn't exist * in the other set before completing. */ private Future<?> waitForBookieInSet(BookieId b, boolean writable) throws Exception { log.info("Wait for {} to become {}", b, writable...
3.26
pulsar_BookKeeperTestClient_readBookiesBlocking_rdh
/** * Force a read to zookeeper to get list of bookies. * * @throws InterruptedException * @throws KeeperException */public void readBookiesBlocking() throws InterruptedException, BKException { bookieWatcher.initialBlockingBookieRead(); }
3.26
pulsar_SslContextAutoRefreshBuilder_get_rdh
/** * It updates SSLContext at every configured refresh time and returns updated SSLContext. * * @return */ public T get() { T ctx = getSslContext(); if (ctx == null) { try { update(); lastRefreshTime = System.currentTimeMillis(); return ...
3.26
pulsar_DeviationShedder_findBundlesForUnloading_rdh
/** * Recommend that all of the returned bundles be unloaded based on observing excessive standard deviations according * to some metric. * * @param loadData * The load data to used to make the unloading decision. * @param conf * The service configuration. * @return A map from all selected bundles to the br...
3.26
pulsar_PulsarShell_computeDefaultPulsarShellRootDirectory_rdh
/** * Compute the default Pulsar shell root directory. * If system property "user.home" returns invalid value, the default value will be the current directory. * * @return */ private static String computeDefaultPulsarShellRootDirectory() { final String userHome = System.getProperty("user.home");if ((!StringUt...
3.26
pulsar_SystemTopicClient_deleteAsync_rdh
/** * Async delete event in the system topic. * * @param key * the key of the event * @param t * pulsar event * @return message id future */ default CompletableFuture<MessageId> deleteAsync(String key, T t) { throw new UnsupportedOperationException("Unsupported operation"); }
3.26
pulsar_SystemTopicClient_delete_rdh
/** * Delete event in the system topic. * * @param key * the key of the event * @param t * pulsar event * @return message id * @throws PulsarClientException * exception while write event cause */ default MessageId delete(String key, T t) throws PulsarClientException { throw new UnsupportedOperatio...
3.26
pulsar_ManagedLedgerImpl_getNumberOfEntries_rdh
/** * Get the number of entries between a contiguous range of two positions. * * @param range * the position range * @return the count of entries */ long getNumberOfEntries(Range<PositionImpl> range) { PositionImpl fromPosition = range.lowerEndpoint(); boolean fromIncluded = range.lowerBoundType() == Bo...
3.26
pulsar_ManagedLedgerImpl_isFenced_rdh
// The state that is transitioned to when a BK write failure happens // After handling the BK write failure, managed ledger will get signalled to create a new ledger public boolean isFenced() { return false; }
3.26
pulsar_ManagedLedgerImpl_m2_rdh
// ////////////////////////////////////////////////////////////////////// // Private helpers synchronized void m2(final LedgerHandle lh) { final State state = STATE_UPDATER.get(this); LedgerHandle currentLedger = this.currentLedger; if ((currentLedger == lh) && ((state == State.ClosingLedger) || (state == S...
3.26
pulsar_ManagedLedgerImpl_advanceCursorsIfNecessary_rdh
/** * Non-durable cursors have to be moved forward when data is trimmed since they are not retain that data. * This is to make sure that the `consumedEntries` counter is correctly updated with the number of skipped * entries and the stats are reported c...
3.26
pulsar_ManagedLedgerImpl_delete_rdh
/** * Delete this ManagedLedger completely from the system. * * @throws Exception */ @Overridepublic void delete() throws InterruptedException, ManagedLedgerException { final CountDownLatch counter = new CountDownLatch(1); final AtomicReference<ManagedLedgerException> exception = new AtomicReference<>(); ...
3.26
pulsar_ManagedLedgerImpl_getPositionAfterN_rdh
/** * Get the entry position at a given distance from a given position. * * @param startPosition * starting position * @param n * number of entries to skip ahead * @param startRange * specifies whether to include the start position in calculating the distance * @return the new position that is n entries ...
3.26
pulsar_ManagedLedgerImpl_invalidateEntriesUpToSlowestReaderPosition_rdh
// slowest reader position is earliest mark delete position when cacheEvictionByMarkDeletedPosition=true // it is the earliest read position when cacheEvictionByMarkDeletedPosition=false private void invalidateEntriesUpToSlowestReaderPosition() { if (entryCache.getSize() <= 0) { return; } if (!activ...
3.26
pulsar_ManagedLedgerImpl_checkFenced_rdh
/** * Throws an exception if the managed ledger has been previously fenced. * * @throws ManagedLedgerException */ private void checkFenced() throws ManagedLedgerException { if (STATE_UPDATER.get(this).isFenced()) { log.error("[{}] Attempted to use a fenced managed ledger", f0); throw new Manage...
3.26
pulsar_ManagedLedgerImpl_isBkErrorNotRecoverable_rdh
/** * return BK error codes that are considered not likely to be recoverable. */ private static boolean isBkErrorNotRecoverable(int rc) { switch (rc) { case Code.NoSuchLedgerExistsException : case Code.NoSuchLedgerExistsOnMetadataServerException :case Code.NoSuchEntryException : return...
3.26
pulsar_ManagedLedgerImpl_getFirstPositionAndCounter_rdh
/** * Get the first position written in the managed ledger, alongside with the associated counter. */ Pair<PositionImpl, Long> getFirstPositionAndCounter() { PositionImpl pos; long count; Pair<PositionImpl, Long> lastPositionAndCounter;do { pos = getFirstPosition(); lastPositionAndCount...
3.26
pulsar_ManagedLedgerImpl_hasActiveCursors_rdh
/** * Tells whether the managed ledger has any active-cursor registered. * * @return true if at least a cursor exists */ public boolean hasActiveCursors() { // Use hasCursors instead of isEmpty because isEmpty does not take into account non-durable cursors return !activeCursors.isEmpty(); }
3.26
pulsar_ManagedLedgerImpl_releaseReadHandleIfNoLongerRead_rdh
/** * * @param ledgerId * the ledger handle which maybe will be released. * @return if the ledger handle was released. */ private boolean releaseReadHandleIfNoLongerRead(long ledgerId, long slowestNonDurationLedgerId) {if (ledgerId < slowestNonDurationLedgerId) { if (log.isDebugEnabled()) { ...
3.26
pulsar_ManagedLedgerImpl_createComplete_rdh
// ////////////////////////////////////////////////////////////////////// // Callbacks @Override public synchronized void createComplete(int rc, final LedgerHandle lh, Object ctx) { if (STATE_UPDATER.get(this) == State.Closed) { if (lh != null) { log.warn("[{}] ledger create completed a...
3.26
pulsar_ManagedLedgerImpl_checkAndCompleteLedgerOpTask_rdh
/** * check if ledger-op task is already completed by timeout-task. If completed then delete the created ledger * * @return */ protected boolean checkAndCompleteLedgerOpTask(int rc, LedgerHandle lh, Object ctx) { if (ctx instanceof CompletableFuture) { // ledger-creation is already timed out and callbac...
3.26
pulsar_ManagedLedgerImpl_calculateLastEntryInLedgerList_rdh
/** * * @return null if all ledgers is empty. */ private PositionImpl calculateLastEntryInLedgerList(List<LedgerInfo> ledgersToDelete) { for (int i = ledgersToDelete.size() - 1; i >= 0; i--) { LedgerInfo ledgerInfo = ledgersToDelete.get(i); if (((ledgerInfo != null) && ledgerInfo.hasEntries()...
3.26
pulsar_ManagedLedgerImpl_getLastPositionAndCounter_rdh
/** * Get the last position written in the managed ledger, alongside with the associated counter. */ Pair<PositionImpl, Long> getLastPositionAndCounter() { PositionImpl pos; long count; do {pos = lastConfirmedEntry;count = ENTRIES_ADDED_COUNTER_UPDATER.get(this);// Ensure no entry was written while readin...
3.26
pulsar_ManagedLedgerImpl_getPreviousPosition_rdh
/** * Get the entry position that come before the specified position in the message stream, using information from the * ledger list and each ledger entries count. * * @param position * the current position * @return the previous position */ public PositionImpl getPreviousPosition(PositionImpl position) {if (p...
3.26
pulsar_ManagedLedgerImpl_isValidPosition_rdh
/** * Validate whether a specified position is valid for the current managed ledger. * * @param position * the position to validate * @return true if the position is valid, false otherwise */ public boolean isValidPosition(PositionImpl position) { PositionImpl lac = lastConfirmedEntry; if (log.isDebugEn...
3.26
pulsar_ManagedLedgerImpl_getEstimatedBacklogSize_rdh
/** * Get estimated backlog size from a specific position. */ public long getEstimatedBacklogSize(PositionImpl pos) { if (pos == null) {return 0; } return estimateBacklogFromPosition(pos); }
3.26
pulsar_ManagedLedgerImpl_asyncCreateLedger_rdh
/** * Create ledger async and schedule a timeout task to check ledger-creation is complete else it fails the callback * with TimeoutException. * * @param bookKeeper * @param config * @param digestType * @param cb * @param metadata */ protected void asyncCreateLedger(BookKeeper bookKeeper, ManagedLedgerConfig...
3.26
pulsar_MultiTopicsConsumerImpl_getPartitionsOfTheTopicMap_rdh
// get all partitions that in the topics map int getPartitionsOfTheTopicMap() { return partitionedTopics.values().stream().mapToInt(Integer::intValue).sum(); }
3.26
pulsar_MultiTopicsConsumerImpl_getPartitionedTopics_rdh
// get topics name public List<String> getPartitionedTopics() { return partitionedTopics.keySet().stream().collect(Collectors.toList()); ...
3.26
pulsar_MultiTopicsConsumerImpl_messageReceived_rdh
// Must be called from the internalPinnedExecutor thread private void messageReceived(ConsumerImpl<T> consumer, Message<T> message) { checkArgument(message instanceof MessageImpl); TopicMessageImpl<T> topicMessage = new TopicMessageImpl<>(consumer.getTopic(), message, consumer); if (log.isDebugEnabled())...
3.26
pulsar_MultiTopicsConsumerImpl_removeConsumerAsync_rdh
// Remove a consumer for a topic public CompletableFuture<Void> removeConsumerAsync(String topicName) { checkArgument(TopicName.isValid(topicName), "Invalid topic name:" + topicName); if ((getState() == State.Closing) || (getState() == State.Closed)) { return FutureUtil.failedFuture(new PulsarClientExce...
3.26
pulsar_MultiTopicsConsumerImpl_unsubscribeAsync_rdh
// un-subscribe a given topic public CompletableFuture<Void> unsubscribeAsync(String topicName) { checkArgument(TopicName.isValid(topicName), "Invalid topic name:" + topicName); if ((getState() == State.Closing) || (getState() == State.Closed)) { return FutureUtil.failedFuture(new PulsarClientException.Alr...
3.26
pulsar_MultiTopicsConsumerImpl_topicNamesValid_rdh
// Check topics are valid. // - each topic is valid, // - topic names are unique. private static boolean topicNamesValid(Collection<String> topics) { checkState((topics != null) && (topics.size() >= 1), "topics should contain more than 1 topic"); Optional<String> result = topics.stream().filter(topic -> !Topic...
3.26
pulsar_MultiTopicsConsumerImpl_createPartitionedConsumer_rdh
// create consumer for a single topic with already known partitions. // first create a consumer with no topic, then do subscription for already know partitionedTopic. public static <T> MultiTopicsConsumerImpl<T> createPartitionedConsumer(PulsarClientImpl client, ConsumerConfigurationData<T> conf, ExecutorProvider execu...
3.26
pulsar_MultiTopicsConsumerImpl_m2_rdh
// get partitioned consumers public List<ConsumerImpl<T>> m2() { return consumers.values().stream().collect(Collectors.toList()); }
3.26
pulsar_MultiTopicsConsumerImpl_onTopicsExtended_rdh
// Check partitions changes of passed in topics, and subscribe new added partitions. @Override public CompletableFuture<Void> onTopicsExtended(Collection<String> topicsExtended) { CompletableFuture<Void> future = new CompletableFuture<>(); if (topicsExtended.isEmpty()) { future.complete(null); ...
3.26
pulsar_MultiTopicsConsumerImpl_subscribeAsync_rdh
// subscribe one more given topic, but already know the numberPartitions CompletableFuture<Void> subscribeAsync(String topicName, int numberPartitions) { TopicName topicNameInstance = getTopicName(topicName); if (topicNameInstance == null) { return FutureUtil.failedFuture(new PulsarClientException.Alrea...
3.26
pulsar_MultiTopicsConsumerImpl_handleSubscribeOneTopicError_rdh
// handling failure during subscribe new topic, unsubscribe success created partitions private void handleSubscribeOneTopicError(String topicName, Throwable error, CompletableFuture<Void> subscribeFuture) { log.warn("[{}] Failed to subscribe for topic [{}] in topics consumer {}", topic, topicName, error.getMessage(...
3.26
pulsar_MultiTopicsConsumerImpl_subscribeIncreasedTopicPartitions_rdh
// subscribe increased partitions for a given topic private CompletableFuture<Void> subscribeIncreasedTopicPartitions(String topicName) { int oldPartitionNumber ...
3.26
pulsar_GracefulExecutorServicesShutdown_terminationTimeout_rdh
/** * Sets the timeout for waiting for executors to complete in forceful termination. * * @param terminationTimeout * duration for the timeout * @return the current instance for controlling graceful shutdown */ public GracefulExecutorServicesShutdown terminationTimeout(Duration terminationTimeout) { this.te...
3.26
pulsar_GracefulExecutorServicesShutdown_handle_rdh
/** * Starts the handler for polling frequently for the completed termination of enlisted executors. * * If the termination times out or the future is cancelled, all active executors will be forcefully * terminated by calling {@link ExecutorService#shutdownNow()}. * * @return a future ...
3.26
pulsar_GracefulExecutorServicesShutdown_timeout_rdh
/** * Sets the timeout for graceful shutdown. * * @param timeout * duration for the timeout * @return the current instance for controlling graceful shutdown */ public GracefulExecutorServicesShutdown timeout(Duration timeout) { this.timeout = timeout; return this;}
3.26
pulsar_GracefulExecutorServicesShutdown_shutdown_rdh
/** * Calls {@link ExecutorService#shutdown()} and enlists the executor as part of the * shutdown handling. * * @param executorServices * one or many executors to shutdown * @return the current instance for controlling graceful shutdown */ public GracefulExecutorServicesShutdown shutdown(ExecutorService... exe...
3.26
pulsar_AbstractMetadataStore_isValidPath_rdh
/** * valid path in metadata store should be * 1. not blank * 2. starts with '/' * 3. not ends with '/', except root path "/" */ static boolean isValidPath(String path) { return StringUtils.equals(path, "/") || ((StringUtils.isNotBlank(path) && path.startsWith("/")) && (!path.endsWith("/"))); }
3.26
pulsar_AbstractMetadataStore_execute_rdh
/** * Run the task in the executor thread and fail the future if the executor is shutting down. */ @VisibleForTesting public void execute(Runnable task, Supplier<List<CompletableFuture<?>>> futures) { try { executor.execute(task); } catch (final Throwable t) { futures.get().forEach(f -> f.completeExceptionally(t)); }...
3.26
pulsar_ThreadRuntime_start_rdh
/** * The core logic that initialize the thread container and executes the function. */ @Override public void start() throws Exception { // extract class loader for function ClassLoader functionClassLoader = getFunctionClassLoader(instanceConfig, instanceConfig.getFunctionId(), jarFile, narExtractionDirectory...
3.26
pulsar_TopicsBase_lookUpBrokerForTopic_rdh
// Look up topic owner for non-partitioned topic or single topic partition. private CompletableFuture<Void> lookUpBrokerForTopic(TopicName partitionedTopicName, boolean authoritative, List<String> redirectAddresses) { CompletableFuture<Void> future = new CompletableFuture<>(); if (!pulsar().getBrokerService().getLookup...
3.26
pulsar_TopicsBase_findOwnerBrokerForTopic_rdh
// Look up topic owner for given topic. Return if asyncResponse has been completed // which indicating redirect or exception. private boolean findOwnerBrokerForTopic(boolean authoritative, AsyncResponse asyncResponse) { PartitionedTopicMetadata metadata = internalGetPartitionedMetadata(authoritative, false); List<Stri...
3.26
pulsar_TopicsBase_completeLookup_rdh
// Release lookup semaphore and add result to redirectAddresses if current broker doesn't own the topic. private synchronized void completeLookup(Pair<List<String>, Boolean> result, List<String> redirectAddresses, CompletableFuture<Void> future) {pulsar().getBrokerService().getLookupRequestSemaphore().release(); // Lef...
3.26
pulsar_TopicsBase_messageToByteBuf_rdh
// Convert message to ByteBuf public ByteBuf messageToByteBuf(Message message) { checkArgument(message instanceof MessageImpl, "Message must be type of MessageImpl."); MessageImpl msg = ((MessageImpl) (message)); MessageMetadata messageMetadata = msg.getMessageBuilder(); ByteBuf payload = msg.getDataBuffer(); message...
3.26
pulsar_TopicsBase_extractException_rdh
// Return error code depends on exception we got indicating if client should retry with same broker. private void extractException(Exception e, ProducerAck produceMessageResult) { if (!((e instanceof BrokerServiceException.TopicFencedException) && (e instanceof ManagedLedgerException))) { produceMessageResult.setError...
3.26
pulsar_TopicsBase_publishMessages_rdh
// Publish message to a topic, can be partitioned or non-partitioned protected void publishMessages(AsyncResponse asyncResponse, ProducerMessages request, boolean authoritative) { String topic = topicName.getPartitionedTopicName(); try { if (pulsar().getBrokerService().getOwningTop...
3.26
pulsar_TopicsBase_buildMessage_rdh
// Build pulsar message from REST request. private List<Message> buildMessage(ProducerMessages producerMessages, Schema schema, String producerName, TopicName topicName) { List<ProducerMessage> messages; List<Message> pulsarMessages = new ArrayList<>(); messages = producerMessages.getMessages(); for (ProducerMessage ...
3.26
pulsar_TopicsBase_getSchemaData_rdh
// Build schemaData from passed in schema string. private SchemaData getSchemaData(String keySchema, String valueSchema) { try { SchemaInfoImpl valueSchemaInfo = ((valueSchema == null) || valueSchema.isEmpty()) ? ((SchemaInfoImpl) (StringSchema.utf8().getSchemaInfo())) : SCHEMA_INFO_READER.readValue(valueSchema); if (n...
3.26
pulsar_TopicsBase_encodeWithSchema_rdh
// Encode message with corresponding schema, do necessary conversion before encoding private byte[] encodeWithSchema(String input, Schema schema) { try { switch (schema.getSchemaInfo().getType()) { case INT8 : return schema.encode(Byte.parseByte(input)); case INT16 : return schema.encode(Short.parseShort(input)...
3.26
pulsar_TopicsBase_publishMessagesToPartition_rdh
// Publish message to single partition of a partitioned topic. protected void publishMessagesToPartition(AsyncResponse asyncResponse, ProducerMessages request, boolean authoritative, int partition) { if (topicName.isPartitioned()) { asyncResponse.resume(new RestException(Status.BAD_REQUEST, "Topic name can...
3.26
pulsar_TopicsBase_processPublishMessageResults_rdh
// Process results for all message publishing attempts private void processPublishMessageResults(List<ProducerAck> produceMessageResults, List<CompletableFuture<PositionImpl>> publishResults) { // process publish message result for (int index = 0; index < publishResults.size(); index++) { try { PositionImpl position ...
3.26
pulsar_TopicsBase_addSchema_rdh
// Add a new schema to schema registry for a topic private CompletableFuture<SchemaVersion> addSchema(SchemaData schemaData) { // Only need to add to first partition the broker owns since the schema id in schema registry are // same for all partitions which is the partitionedTopicName List<Integer> partitions = pulsar(...
3.26
pulsar_LocalBrokerData_updateSystemResourceUsage_rdh
// Update resource usage given each individual usage. private void updateSystemResourceUsage(final ResourceUsage cpu, final ResourceUsage memory, final ResourceUsage directMemory, final ResourceUsage bandwidthIn, final ResourceUsage bandwidthOut) { this.cpu = cpu; this.memory = memory; this.dir...
3.26
pulsar_LocalBrokerData_equals_rdh
/** * Since the broker data is also used as a lock for the broker, we need to have a stable comparison * operator that is not affected by the actual load on the broker. */ @Override public boolean equals(Object o) { if (o instanceof LocalBrokerData) { LocalBrokerData other = ((LocalBrokerData) (o)); ...
3.26
pulsar_LocalBrokerData_updateBundleData_rdh
// Aggregate all message, throughput, topic count, bundle count, consumer // count, and producer count across the // given data. Also keep track of bundle gains and losses. private void updateBundleData(final Map<String, NamespaceBundleStats> bundleStats) { msgRateIn = 0; ...
3.26
pulsar_LocalBrokerData_update_rdh
/** * Using another LocalBrokerData, update this. * * @param other * LocalBrokerData to update from. */ public void update(final LocalBrokerData other) { updateSystemResourceUsage(other.cpu, other.memory, other.directMemory, other.bandwidthIn, other.bandwidthOut); updateBundleData(other.lastStats); l...
3.26
pulsar_FileSystemManagedLedgerOffloader_offload_rdh
/* ledgerMetadata stored in an index of -1 */ @Override public CompletableFuture<Void> offload(ReadHandle readHandle, UUID uuid, Map<String, String> extraMetadata) { CompletableFuture<Void> promise = new CompletableFuture<>(); scheduler.chooseThread(readHandle.getId()).execute(new LedgerReader(readHandle, uuid...
3.26
pulsar_TransactionMetadataStore_getLowWaterMark_rdh
/** * Get the low water mark of this tc, in order to delete unless transaction in transaction buffer and pending ack. * * @return long {@link long} the lowWaterMark */ default long getLowWaterMark() { return Long.MIN_VALUE; }
3.26
pulsar_StateChangeListeners_notifyOnCompletion_rdh
/** * Notify all currently added listeners on completion of the future. * * @return future of a new completion stage */ public <T> CompletableFuture<T> notifyOnCompletion(CompletableFuture<T> future, String serviceUnit, ServiceUnitStateData data) { return future.whenComplete((r, ex) -> notify(serviceUnit, data...
3.26
pulsar_MultiRolesTokenAuthorizationProvider_canConsumeAsync_rdh
/** * Check if the specified role has permission to receive messages from the specified fully qualified topic * name. * * @param topicName * the fully qualified topic name associated with the topic. * @param role * the app id used to receive messages from the topic. * @param subscription * the subscripti...
3.26
pulsar_MultiRolesTokenAuthorizationProvider_canLookupAsync_rdh
/** * Check whether the specified role can perform a lookup for the specified topic. * <p> * For that the caller needs to have producer or consumer permission. * * @param topicName * @param role * @return * @throws Exception */ @Override public CompletableFuture<Boolean> canLookupAsync(TopicName topicName, Str...
3.26
pulsar_MultiRolesTokenAuthorizationProvider_canProduceAsync_rdh
/** * Check if the specified role has permission to send messages to the specified fully qualified topic name. * * @param topicName * the fully qualified topic name associated with the topic. * @param role * the app id used to send messages to the topic. */ @Override public CompletableFuture<Boolean> canProd...
3.26
pulsar_PulsarAdmin_builder_rdh
/** * Get a new builder instance that can used to configure and build a {@link PulsarAdmin} instance. * * @return the {@link PulsarAdminBuilder} */ static PulsarAdminBuilder builder() { return DefaultImplementation.newAdminClientBuilder(); }
3.26
pulsar_LoadManagerShared_fillNamespaceToBundlesMap_rdh
/** * Using the given bundles, populate the namespace to bundle range map. * * @param bundles * Bundles with which to populate. * @param target * Map to fill. */ public static void fillNamespaceToBundlesMap(final Set<String> bundles, final ConcurrentOpenHashMap<String, ConcurrentOpenHashSet<String>> target) ...
3.26
pulsar_LoadManagerShared_shouldAntiAffinityNamespaceUnload_rdh
/** * It checks if given anti-affinity namespace should be unloaded by broker due to load-shedding. If all the brokers * are owning same number of anti-affinity namespaces then unloading this namespace again ends up at the same broker * from which it was unloaded. So, this util checks that given namespace should be ...
3.26
pulsar_LoadManagerShared_filterAntiAffinityGroupOwnedBrokers_rdh
/** * It tries to filter out brokers which own namespace with same anti-affinity-group as given namespace. If all the * domains own namespace with same anti-affinity group then it will try to keep brokers with domain that has least * number of namespace...
3.26
pulsar_LoadManagerShared_filterDomainsNotHavingLeastNumberAntiAffinityNamespaces_rdh
/** * It computes least number of namespace owned by any of the domain and then it filters out all the domains that own * namespaces more than this count. * * @param brokerToAntiAffinityNamespaceCount * @param candidates * @param brokerToDomainMap *...
3.26
pulsar_LoadManagerShared_applyNamespacePolicies_rdh
// Determines the brokers available for the given service unit according to the given policies. // The brokers are put into brokerCandidateCache. public static void applyNamespacePolicies(final ServiceUnitId serviceUnit, final SimpleResourceAllocationPolicies policies, final Set<String> brokerCandidateCache, final Set<...
3.26
pulsar_LoadManagerShared_getAntiAffinityNamespaceOwnedBrokers_rdh
/** * It returns map of broker and count of namespace that are belong to the same anti-affinity group as given. * * @param pulsar * @param namespaceName * @param brokerToNamespaceToBundleRange * @return */ public static CompletableFuture<Map<String, Integer>> getAntiAffinityNamespaceOwnedBrokers(final PulsarServ...
3.26
pulsar_LoadManagerShared_getNamespaceNameFromBundleName_rdh
// From a full bundle name, extract the namespace name. public static String getNamespaceNameFromBundleName(String bundleName) { // the bundle format is property/cluster/namespace/0x00000000_0xFFFFFFFF int pos = bundleName.lastIndexOf('/'); checkArgument(pos != (-1)); return bundleName.substring(0, pos...
3.26
pulsar_LoadManagerShared_getSystemResourceUsage_rdh
// Get the system resource usage for this broker. public static SystemResourceUsage getSystemResourceUsage(final BrokerHostUsage brokerHostUsage) { SystemResourceUsage systemResourceUsage = brokerHostUsage.getBrokerHostUsage(); // Override System memory usage and limit with JVM heap usage and limit double ...
3.26
pulsar_LoadManagerShared_getBundleRangeFromBundleName_rdh
// From a full bundle name, extract the bundle range. public static String getBundleRangeFromBundleName(String bundleName) {// the bundle format is property/cluster/namespace/0x00000000_0xFFFFFFFF int pos = bundleName.lastIndexOf("/"); checkArgument(pos != (-1)); return bundleName.substring(pos + 1); }
3.26
pulsar_LoadManagerShared_isLoadSheddingEnabled_rdh
/** * If load balancing is enabled, load shedding is enabled by default unless forced off by dynamic configuration. * * @return true by default */ public static boolean isLoadSheddingEnabled(final PulsarService pulsar) { return pulsar.getConfiguration().isLoadBalancerEnabled() && pulsar.getConfiguration().isLoa...
3.26
pulsar_LoadManagerShared_filterBrokersWithLargeTopicCount_rdh
/** * It filters out brokers which owns topic higher than configured threshold at * ServiceConfiguration.loadBalancerBrokerMaxTopics. <br/> * if all the brokers own topic higher than threshold then it resets the list with original broker candidates * * @param brokerCandidateCache * @param loadData * @param loadB...
3.26
pulsar_LoadManagerShared_removeMostServicingBrokersForNamespace_rdh
/** * Removes the brokers which have more bundles assigned to them in the same namespace as the incoming bundle than at * least one other available broker from consideration. * * @param assignedBundleName * Name of bundle to be assigned. * @param candidates * BrokersBase available for placement. * @param br...
3.26
pulsar_AbstractSinkRecord_cumulativeAck_rdh
/** * Some sink sometimes wants to control the ack type. */ public void cumulativeAck() { if (sourceRecord instanceof PulsarRecord) { PulsarRecord pulsarRecord = ((PulsarRecord) (sourceRecord)); pulsarRecord.cumulativeAck(); } else { throw new Ru...
3.26
pulsar_AbstractSinkRecord_individualAck_rdh
/** * Some sink sometimes wants to control the ack type. */ public void individualAck() { if (sourceRecord instanceof PulsarRecord) { PulsarRecord v1 = ((PulsarRecord) (sourceRecord)); v1.individualAck(); } else { throw new RuntimeException("SourceRecord class type must be PulsarRecord"); } }
3.26
pulsar_RestMessagePublishContext_get_rdh
// recycler public static RestMessagePublishContext get(CompletableFuture<PositionImpl> positionFuture, Topic topic, long startTimeNs) { RestMessagePublishContext callback = RECYCLER.get(); callback.positionFuture = positionFuture; callback.topic = topic; callback.startTimeNs = startTimeNs; return callback; }
3.26
pulsar_RestMessagePublishContext_completed_rdh
/** * Executed from managed ledger thread when the message is persisted. */ @Override public void completed(Exception exception, long ledgerId, long entryId) { if (exception != null) { positionFuture.completeExceptionally(exception); if (log.isInfoEnabled()) { ...
3.26
pulsar_NamespaceName_getTopicName_rdh
/** * Compose the topic name from namespace + topic. * * @param domain * @param topic * @return */ String getTopicName(TopicDomain domain, String topic) { if (domain == null) { throw new IllegalArgumentException("invalid null domain"); } NamedEntity.checkName(topic); return String.format("%s://%s/%s", domain.toSt...
3.26
pulsar_NamespaceName_isV2_rdh
/** * Returns true if this is a V2 namespace prop/namespace-name. * * @return true if v2 */ public boolean isV2() { return cluster == null; }
3.26
pulsar_PulsarConfigurationLoader_create_rdh
/** * Creates PulsarConfiguration and loads it with populated attribute values from provided Properties object. * * @param properties * The properties to populate the attributed from * @throws IOException * @throws IllegalArgumentException */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T exte...
3.26
pulsar_PulsarConfigurationLoader_isComplete_rdh
/** * Validates {@link FieldContext} annotation on each field of the class element. If element is annotated required * and value of the element is null or number value is not in a provided (min,max) range then consider as incomplete * object and throws exception with incomplete parameters * * @param obj * @return...
3.26
pulsar_PulsarConfigurationLoader_convertFrom_rdh
/** * Converts a PulsarConfiguration object to a ServiceConfiguration object. * * @param conf * @param ignoreNonExistMember * @return * @throws IllegalArgumentException * if conf has the field whose name is not contained in ServiceConfiguration and ignoreNonExistMember * is false. * @throws RuntimeExceptio...
3.26
pulsar_StickyKeyConsumerSelector_select_rdh
/** * Select a consumer by sticky key. * * @param stickyKey * sticky key * @return consumer */ default Consumer select(byte[] stickyKey) { return select(makeStickyKeyHash(stickyKey)); }
3.26
pulsar_ManagedLedgerStorage_create_rdh
/** * Initialize the {@link ManagedLedgerStorage} from the provided resources. * * @param conf * service config * @param bkProvider * bookkeeper client provider * @return the initialized managed ledger storage. */ static ManagedLedgerStorage create(ServiceConfiguration conf, MetadataStoreExtended metadataSt...
3.26
pulsar_PrometheusTextFormat_write004_rdh
/** * Provide Prometheus text format for a collection of metrics, without the HELP string. */public class PrometheusTextFormat {/** * Write out the text version 0.0.4 of the given MetricFamilySamples. */ public static void write004(Writer writer, Enumeration<Collector.MetricFamilySamples> mfs) throws I...
3.26
pulsar_OffloadIndexBlock_getStreamSize_rdh
/** * * @return the number of bytes in the stream. */public long getStreamSize() { return streamSize; }
3.26
pulsar_ConcurrentOpenLongPairRangeSet_addOpenClosed_rdh
/** * Adds the specified range to this {@code RangeSet} (optional operation). That is, for equal range sets a and b, * the result of {@code a.add(range)} is that {@code a} will be the minimal range set for which both * {@code a.enclosesAll(b)} and {@code a.encloses(range)}. * * <p>Note that {@code range} will merg...
3.26
pulsar_ConcurrentOpenLongPairRangeSet_add_rdh
/** * Adds the specified range to this {@code RangeSet} (optional operation). That is, for equal range sets a and b, * the result of {@code a.add(range)} is that {@code a} will be the minimal range set for which both * {@code a.enclosesAll(b)} and {@code a.encloses(range)}. * * <p>Note that {@code range} will merg...
3.26
pulsar_FunctionRuntimeManager_getFunctionStats_rdh
/** * Get stats of all function instances. * * @param tenant * the tenant the function belongs to * @param namespace * the namespace the function belongs to * @param functionName * the function name * @return a list of function statuses * @throws PulsarAdminException */ public FunctionStatsImpl getFun...
3.26