name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
pulsar_ManagedCursorImpl_filterReadEntries_rdh
/** * Given a list of entries, filter out the entries that have already been individually deleted. * * @param entries * a list of entries * @return a list of entries not containing deleted messages */List<Entry> filterReadEntrie...
3.26
pulsar_ManagedCursorImpl_persistPositionWhenClosing_rdh
/** * Persist given markDelete position to cursor-ledger or zk-metaStore based on max number of allowed unack-range * that can be persist in zk-metastore. If current unack-range is higher than configured threshold then broker * persists mark-delete into cursor-ledger else into zk-meta...
3.26
pulsar_ManagedCursorImpl_trySetStateToClosing_rdh
/** * Try set {@link #state} to {@link State#Closing}. * * @return false if the {@link #state} already is {@link State#Closing} or {@link State#Closed}. */ private boolean trySetStateToClosing() { final AtomicBoolean notClosing = new AtomicBoolean(false); STATE_UPDATER.updateAndGet(this, state -> { ...
3.26
pulsar_ManagedCursorImpl_recover_rdh
/** * Performs the initial recovery, reading the mark-deleted position from the ledger and then calling initialize to * have a new opened ledger. */ void recover(final VoidCallback callback) { // Read the meta-data ledgerId from the store log.info("[{}] Recovering from bookkeeper ledger cursor: {}", ledger....
3.26
pulsar_ManagedCursorImpl_startCreatingNewMetadataLedger_rdh
// ////////////////////////////////////////////////// void startCreatingNewMetadataLedger() { // Change the state so that new mark-delete ops will be queued and not immediately submitted State oldState = STATE_UPDATER.getAndSet(this, State.SwitchingLedger); if (oldState == State.SwitchingLedger) { /...
3.26
pulsar_ManagedCursorImpl_getPendingReadOpsCount_rdh
// / Expose internal values for debugging purpose public int getPendingReadOpsCount() { return PENDING_READ_OPS_UPDATER.get(this); }
3.26
pulsar_ManagedCursorImpl_notifyEntriesAvailable_rdh
/** * * @return Whether the cursor responded to the notification */ void notifyEntriesAvailable() { if (log.isDebugEnabled()) { log.debug("[{}] [{}] Received ml notification", ledger.getName(), name); } OpReadEntry opReadEntry = WAITING_READ_OP_UPDATER.getAndSet(this, null);if (opReadEntry != null) { if...
3.26
pulsar_ManagedCursorImpl_asyncReplayEntries_rdh
/** * Async replays given positions: a. before reading it filters out already-acked messages b. reads remaining entries * async and gives it to given ReadEntriesCallback c. returns all already-acked messages which are not replayed so, * those messages can be removed by...
3.26
pulsar_ManagedCursorImpl_m4_rdh
/** * Checks given position is part of deleted-range and returns next position of upper-end as all the messages are * deleted up to that point. * * @param position * @return next available position */ public PositionImpl m4(PositionImpl position) { Range<PositionImpl> range = individualDeletedMessages.rangeContai...
3.26
pulsar_ManagedCursorImpl_getBatchPositionAckSet_rdh
// this method will return a copy of the position's ack set public long[] getBatchPositionAckSet(Position position) { if (!(position instanceof PositionImpl)) { return null; } if (f1 != null) { BitSetRecyclable bitSetRecyclable = f1.get(position); if (bitSetRecyclable == null) { return null;} else { return bitSetRecyc...
3.26
pulsar_ManagedCursorImpl_getRollbackPosition_rdh
/** * If we fail to recover the cursor ledger, we want to still open the ML and rollback. * * @param info */ private PositionImpl getRollbackPosition(ManagedCursorInfo info) { PositionImpl firstPosition = ledger.getFirstPosition(); PositionImpl snapshottedPosition = new PositionImpl(info.getMarkDeleteLedgerId(), ...
3.26
pulsar_ManagedCursorImpl_setReadPosition_rdh
/** * Internal version of seek that doesn't do the validation check. * * @param newReadPositionInt */ void setReadPosition(Position newReadPositionInt) { checkArgument(newReadPositionInt instanceof PositionImpl); if ((this.markDeletePosition == null) || (((PositionImpl) (newReadPositionInt)).compareTo(this....
3.26
pulsar_ManagedCursorImpl_updateLastMarkDeleteEntryToLatest_rdh
// update lastMarkDeleteEntry field if newPosition is later than the current lastMarkDeleteEntry.newPosition private void updateLastMarkDeleteEntryToLatest(final PositionImpl newPosition, final Map<String, Long> properties) { LAST_MARK_DELETE_ENTRY_UPDATER.updateAndGet(this, last -> { if ((last != null...
3.26
pulsar_ManagedCursorImpl_isBkErrorNotRecoverable_rdh
/** * return BK error codes that are considered not likely to be recoverable. */ public static boolean isBkErrorNotRecoverable(int rc) { switch (rc) { case Code.NoSuchLedgerExistsException : case Code.NoSuchLedgerExistsOnMetadataServerException : case Code.ReadException : case Code.LedgerRecoveryException : case Cod...
3.26
pulsar_ManagedCursorImpl_setAcknowledgedPosition_rdh
/** * * @param newMarkDeletePosition * the new acknowledged position * @return the previous acknowledged position */ PositionImpl setAcknowledgedPosition(PositionImpl newMarkDeletePosition) { if (newMarkDeletePosition.compareTo(markDeletePosition) < 0) { throw new MarkDeletingMarkedPosition((("Mark d...
3.26
pulsar_GenericRecord_getSchemaType_rdh
/** * Return the schema tyoe. * * @return the schema type * @throws UnsupportedOperationException * if this feature is not implemented * @see SchemaType#AVRO * @see SchemaType#PROTOBUF_NATIVE * @see SchemaType#JSON */ @Override default SchemaType getSchemaType() { throw new UnsupportedOperationException(...
3.26
pulsar_GenericRecord_getField_rdh
/** * Retrieve the value of the provided <tt>field</tt>. * * @param field * the field to retrieve the value * @return the value object */ default Object getField(Field field) { return getField(field.getName()); }
3.26
pulsar_GenericRecord_getNativeObject_rdh
/** * Return the internal native representation of the Record, * like a AVRO GenericRecord. * * @return the internal representation of the record * @throws UnsupportedOperationException * if the operation is not supported */ @Override default Object getNativeObject() { throw new UnsupportedOperationExcepti...
3.26
pulsar_ShadedJCloudsUtils_addStandardModules_rdh
/** * Setup standard modules. * * @param builder * the build */ public static void addStandardModules(ContextBuilder builder) { List<AbstractModule> modules = new ArrayList<>(); modules.add(new SLF4JLoggingModule()); if (ENABLE_OKHTTP_MODULE) { modules.add(new OkHttpCommandExecutorServiceMod...
3.26
pulsar_SingleSnapshotAbortedTxnProcessorImpl_trimExpiredAbortedTxns_rdh
// In this implementation we clear the invalid aborted txn ID one by one. @Overridepublic void trimExpiredAbortedTxns() { while ((!aborts.isEmpty()) && (!((ManagedLedgerImpl) (topic.getManagedLedger())).ledgerExists(aborts.get(aborts.firstKey()).getLedgerId()))) { if (log.isDebugEnabled()) { lo...
3.26
pulsar_DLOutputStream_writeAsync_rdh
/** * Write all input stream data to the distribute log. * * @param inputStream * the data we need to write * @return */ CompletableFuture<DLOutputStream> writeAsync(InputStream inputStream) { return getRecords(inputStream).thenCompose(this::writeAsync); }
3.26
pulsar_DLOutputStream_m0_rdh
/** * Every package will be a stream. So we need mark the stream as EndOfStream when the stream * write done. * * @return */ CompletableFuture<Void> m0() {return writer.markEndOfStream().thenCompose(ignore -> writer.asyncClose()).thenCompose(ignore -> distributedLogManager.asyncClose()); }
3.26
pulsar_CompactedTopicImpl_getCompactedTopicContext_rdh
/** * Getter for CompactedTopicContext. * * @return CompactedTopicContext */ public Optional<CompactedTopicContext> getCompactedTopicContext() throws ExecutionException, InterruptedException { return compactedTopicContext == null ? Optional.empty() : Optional.of(compactedTopicContext.get()); }
3.26
pulsar_EtcdSessionWatcher_checkConnectionStatus_rdh
// task that runs every TICK_TIME to check Etcd connection private synchronized void checkConnectionStatus() { try { CompletableFuture<SessionEvent> future = new CompletableFuture<>(); client.getKVClient().get(ByteSequence.from("/".getBytes(StandardCharsets.UTF_8))).thenRun(() -> { future.comple...
3.26
pulsar_AbstractPushSource_notifyError_rdh
/** * Allows the source to notify errors asynchronously. * * @param ex */ public void notifyError(Exception ex) { consume(new ErrorNotifierRecord(ex)); }
3.26
pulsar_AbstractPushSource_consume_rdh
/** * Send this message to be written to Pulsar. * Pass null if you you are done with this task * * @param record * next message from source which should be sent to a Pulsar topic */ public void consume(Record<T> record) { try {if (record != null) { queue.put(record); } else { qu...
3.26
pulsar_AbstractPushSource_getQueueLength_rdh
/** * Get length of the queue that records are push onto. * Users can override this method to customize the queue length * * @return queue length */ public int getQueueLength() { return DEFAULT_QUEUE_LENGTH; }
3.26
pulsar_WorkerApiV2Resource_clientAppId_rdh
/** * * @deprecated use {@link #authParams()} instead */ @Deprecated public String clientAppId() { return httpRequest != null ? ((String) (httpRequest.getAttribute(AuthenticationFilter.AuthenticatedRoleAttributeName))) : null; }
3.26
pulsar_RawReader_create_rdh
/** * Topic reader which receives raw messages (i.e. as they are stored in the managed ledger). */public interface RawReader { /** * Create a raw reader for a topic. */ static CompletableFuture<RawReader> create(PulsarClient client, String topic, String subscription) { CompletableFuture<Cons...
3.26
pulsar_MetadataStoreFactoryImpl_removeIdentifierFromMetadataURL_rdh
/** * Removes the identifier from the full metadata url. * * zk:my-zk:3000 -> my-zk:3000 * etcd:my-etcd:3000 -> my-etcd:3000 * my-default-zk:3000 -> my-default-zk:3000 * * @param metadataURL * @return */ public static String removeIdentifierFromMetadataURL(String metadataURL) {MetadataStoreProvider provider = ...
3.26
pulsar_MathUtils_ceilDiv_rdh
/** * Ceil version of Math.floorDiv(). * * @param x * the dividend * @param y * the divisor * @return the smallest value that is larger than or equal to the algebraic quotient. */ public static int ceilDiv(int x, int y) { return -Math.floorDiv(-x, y); }
3.26
pulsar_MathUtils_m0_rdh
/** * Compute sign safe mod. * * @param dividend * @param divisor * @return */ public static int m0(long dividend, int divisor) { int mod = ((int) (dividend % divisor)); if (mod < 0) { mod += divisor; } return mod; }
3.26
pulsar_PulsarClientImpl_newTransaction_rdh
// // Transaction related API // // This method should be exposed in the PulsarClient interface. Only expose it when all the transaction features // are completed. // @Override public TransactionBuilder newTransaction() { return new TransactionBuilderImpl(this, tcClient); }
3.26
pulsar_PulsarClientImpl_newTableViewBuilder_rdh
/** * * @deprecated use {@link #newTableView(Schema)} instead. */ @Override @Deprecated public <T> TableViewBuilder<T> newTableViewBuilder(Schema<T> schema) { return new TableViewBuilderImpl<>(this, schema); }
3.26
pulsar_PulsarClientImpl_getConnection_rdh
/** * Only for test. */ @VisibleForTesting public CompletableFuture<ClientCnx> getConnection(final String topic) { TopicName topicName = TopicName.get(topic); return lookup.getBroker(topicName).thenCompose(pair -> getConnection(pair.getLeft(), pair.getRight(), cnxPool.genRandomKeyToSelectCon())); }
3.26
pulsar_PulsarClientImpl_newPartitionedProducerImpl_rdh
/** * Factory method for creating PartitionedProducerImpl instance. * * Allows overriding the PartitionedProducerImpl instance in tests. * * @param topic * topic name * @param conf * producer configuration * @param schema * topic schema * @param interceptors * producer interceptors * @param produce...
3.26
pulsar_PulsarClientImpl_newProducerImpl_rdh
/** * Factory method for creating ProducerImpl instance. * * Allows overriding the ProducerImpl instance in tests. * * @param topic * topic name * @param partitionIndex * partition index of a partitioned topic. the value -1 is used for non-partitioned topics. * @param conf * producer configuration * @p...
3.26
pulsar_PulsarClientImpl_getSchema_rdh
/** * Read the schema information for a given topic. * * If the topic does not exist or it has no schema associated, it will return an empty response */ public CompletableFuture<Optional<SchemaInfo>> getSchema(String topic) { TopicName topicName; try { topicName = TopicName.get(topic); } catch (Throwable t) { retur...
3.26
pulsar_PulsarClientImpl_timer_rdh
/** * visible for pulsar-functions. * */ public Timer timer() { return timer; }
3.26
pulsar_HandlerState_changeToReadyState_rdh
// moves the state to ready if it wasn't closed protected boolean changeToReadyState() { if (STATE_UPDATER.get(this) == State.Ready) {return true; } return (STATE_UPDATER.compareAndSet(this, State.Uninitialized, State.Ready) || STATE_UPDATER.compareAndSet(this, State.Connecting, State.Ready)) || STATE_UPDA...
3.26
pulsar_InetAddressUtils_isIPv6HexCompressedAddress_rdh
/** * Checks whether the parameter is a valid compressed IPv6 address. * * @param input * the address string to check for validity * @return true if the input parameter is a valid compressed IPv6 address */ public static boolean isIPv6HexCompressedAddress(final String input) { ...
3.26
pulsar_InetAddressUtils_isIPv6StdAddress_rdh
/** * Checks whether the parameter is a valid standard (non-compressed) IPv6 address. * * @param input * the address string to check for validity * @return true if the input parameter is a valid standard (non-compressed) IPv6 address */ public static boolean isIPv6StdAddress(final String input) { return I...
3.26
pulsar_InetAddressUtils_isIPv6Address_rdh
/** * Checks whether the parameter is a valid IPv6 address (including compressed). * * @param input * the address string to check for validity * @return true if the input parameter is a valid standard or compressed IPv6 address */ public static boolean isIPv6Address(final String input) { return isIPv6StdAdd...
3.26
pulsar_IOUtils_confirmPrompt_rdh
/** * Confirm prompt for the console operations. * * @param prompt * Prompt message to be displayed on console * @return Returns true if confirmed as 'Y', returns false if confirmed as 'N' * @throws IOException */ public static boolean confirmPrompt(String prompt) throws IOException { while (true) { System...
3.26
pulsar_MetaStoreImpl_m2_rdh
// // update timestamp if missing or 0 // 3 cases - timestamp does not exist for ledgers serialized before // - timestamp is 0 for a ledger in recovery // - ledger has timestamp which is the normal case now private static ManagedLedgerInfo m2(ManagedLedgerInfo info) { List<ManagedLedgerInfo.LedgerInfo> infoList = ...
3.26
pulsar_MetaStoreImpl_compressManagedInfo_rdh
/** * Compress Managed Info data such as LedgerInfo, CursorInfo. * * compression data structure * [MAGIC_NUMBER](2) + [METADATA_SIZE](4) + [METADATA_PAYLOAD] + [MANAGED_LEDGER_INFO_PAYLOAD] */ private byte[] compressManagedInfo(byte[] info, byte[] metadata, int metadataSerializedSize, MLDataFormats.CompressionType...
3.26
pulsar_FunctionMetaDataManager_initialize_rdh
/** * Public methods. Please use these methods if references FunctionMetaManager from an external class */ /** * Initializes the FunctionMetaDataManager. * We create a new reader */ public synchronized void initialize() { try (Reader reader = FunctionMetaDataTopicTailer.createReader(workerConfig, pulsarClient...
3.26
pulsar_FunctionMetaDataManager_giveupLeadership_rdh
/** * called by the leader service when we lose leadership. We close the exclusive producer * and start the tailer. */ public synchronized void giveupLeadership() { log.info("FunctionMetaDataManager giving up leadership by closing exclusive producer"); try { exclusiveL...
3.26
pulsar_FunctionMetaDataManager_getFunctionMetaData_rdh
/** * Get the function metadata for a function. * * @param tenant * the tenant the function belongs to * @param namespace * the namespace the function belongs to * @param functionName * the function name * @return FunctionMetaData that contains the function metadata */ public synchronized FunctionMetaDa...
3.26
pulsar_FunctionMetaDataManager_acquireExclusiveWrite_rdh
/** * Acquires a exclusive producer. This method cannot return null. It can only return a valid exclusive producer * or throw NotLeaderAnymore exception. * * @param isLeader * if the worker is still the leader * @return A valid exclusive producer * @throws WorkerUtils.NotLeaderAnymore * if the worker is n...
3.26
pulsar_FunctionMetaDataManager_start_rdh
// Starts the tailer if we are in non-leader mode public synchronized void start() { if (exclusiveLeaderProducer == null) { try { // This means that we are in non-leader mode. start function metadata tailer initializeTailer(); } catch (PulsarClientException e) {throw new Runt...
3.26
pulsar_FunctionMetaDataManager_getAllFunctionMetaData_rdh
/** * Get a list of all the meta for every function. * * @return list of function metadata */ public synchronized List<FunctionMetaData> getAllFunctionMetaData() { List<FunctionMetaData> ret = new LinkedList<>(); for (Map<String, Map<String, FunctionMetaData>> i : this.functionMetaDataMap.values()) { ...
3.26
pulsar_FunctionMetaDataManager_listFunctions_rdh
/** * List all the functions in a namespace. * * @param tenant * the tenant the namespace belongs to * @param namespace * the namespace * @return a list of function names */public synchronized Collection<FunctionMetaData> listFunctions(...
3.26
pulsar_FunctionMetaDataManager_processMetaDataTopicMessage_rdh
/** * This is called by the MetaData tailer. It updates the in-memory cache. * It eats up any exception thrown by processUpdate/processDeregister since * that's just part of the state machine * * @param message * The message read from metadata topic that needs to be processed */ public void processMetaDataTopi...
3.26
pulsar_FunctionMetaDataManager_containsFunctionMetaData_rdh
/** * Private methods for internal use. Should not be used outside of this class */ private boolean containsFunctionMetaData(FunctionMetaData functionMetaData) { return containsFunctionMetaData(functionMetaData.getFunctionDetails()); }
3.26
pulsar_FunctionMetaDataManager_containsFunction_rdh
/** * Check if the function exists. * * @param tenant * tenant that the function belongs to * @param namespace * namespace that the function belongs to * @param functionName * name of function * @return true if function exists and false if it does not */ public synchronized boolean containsFunction(Stri...
3.26
pulsar_FunctionMetaDataManager_updateFunctionOnLeader_rdh
/** * Called by the worker when we are in the leader mode. In this state, we update our in-memory * data structures and then write to the metadata topic. * * @param functionMetaData * The function metadata in question * @param delete * Is this a delete operation * @throws IllegalStateException * if we a...
3.26
pulsar_FunctionMetaDataManager_acquireLeadership_rdh
/** * Called by the leader service when this worker becomes the leader. * We first get exclusive producer on the metadata topic. Next we drain the tailer * to ensure that we have caught up to metadata topic. After which we close the tailer. * Note that this method cannot be syncrhonized because the tailer might sti...
3.26
pulsar_MessageDeduplication_checkStatus_rdh
/** * Check the status of deduplication. If the configuration has changed, it will enable/disable deduplication, * returning a future to track the completion of the task */ public CompletableFuture<Void> checkStatus() { boolean shouldBeEnabled = isDeduplicationEnabled(); synchronized(this) { if ((sta...
3.26
pulsar_MessageDeduplication_replayCursor_rdh
/** * Read all the entries published from the cursor position until the most recent and update the highest sequence id * from each producer. * * @param future * future to trigger when the replay is complete */ private void replayCursor(CompletableFuture<Void> future) { managedCursor.asyncReadEntries(100, ne...
3.26
pulsar_MessageDeduplication_isDuplicate_rdh
/** * Assess whether the message was already stored in the topic. * * @return true if the message should be published or false if it was recognized as a duplicate */ public MessageDupStatus isDuplicate(PublishContext publishContext, ByteBuf headersAndPayload) { if ((!isEnabled()) || publishContext.isMarkerMessa...
3.26
pulsar_MessageDeduplication_purgeInactiveProducers_rdh
/** * Remove from hash maps all the producers that were inactive for more than the configured amount of time. */ public synchronized void purgeInactiveProducers() { long minimumActiveTimestamp = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(pulsar.getConfiguration(...
3.26
pulsar_MessageDeduplication_producerRemoved_rdh
/** * Topic will call this method whenever a producer disconnects. */ public void producerRemoved(String producerName) { // Producer is no-longer active inactiveProducers.put(producerName, System.currentTimeMillis()); }
3.26
pulsar_MessageDeduplication_recordMessagePersisted_rdh
/** * Call this method whenever a message is persisted to get the chance to trigger a snapshot. */ public void recordMessagePersisted(PublishContext publishContext, PositionImpl position) { if ((!isEnabled()) || publishContext.isMarkerMessage()) { return; }String producerName = publishContext.getProdu...
3.26
pulsar_RangeEntryCacheImpl_readFromStorage_rdh
/** * Reads the entries from Storage. * * @param lh * the handle * @param firstEntry * the first entry * @param lastEntry * the last entry * @param shouldCacheEntry * if we should put the entry into the cache * @return a handle to the operation */ CompletableFuture<List<EntryImpl>> readFromStorage(R...
3.26
pulsar_SingletonCleanerListener_objectMapperFactoryClearCaches_rdh
// Call ObjectMapperFactory.clearCaches() using reflection to clear up classes held in // the singleton Jackson ObjectMapper instances private static void objectMapperFactoryClearCaches() { if (OBJECTMAPPERFACTORY_CLEARCACHES_METHOD != null) { try { OBJECTMAPPERFACTORY_CLEARCACHES_METHOD.invok...
3.26
pulsar_SingletonCleanerListener_jsonSchemaClearCaches_rdh
// Call JSONSchema.clearCaches() using reflection to clear up classes held in // the singleton Jackson ObjectMapper instance of JSONSchema class private static void jsonSchemaClearCaches() { if (JSONSCHEMA_CLEARCACHES_METHOD != null) { try { JSONSCHEMA_CLEARCACHES_METHOD.invoke(null)...
3.26
pulsar_BrokerInterceptors_load_rdh
/** * Load the broker event interceptor for the given <tt>interceptor</tt> list. * * @param conf * the pulsar broker service configuration * @return the collection of broker event interceptor */ public static BrokerInterceptor load(ServiceConfiguration conf) throws IOException { BrokerInterceptorDefinitions...
3.26
pulsar_NoStrictCacheSizeAllocator_release_rdh
/** * This method used to release used cache size and add available cache size. * in normal case, the available size shouldn't exceed max cache size. * * @param size * release size */ public void release(long size) {lock.lock(); try { availableCacheSize.add(size); if (availableCacheSize.long...
3.26
pulsar_NoStrictCacheSizeAllocator_allocate_rdh
/** * This operation will cost available cache size. * if the request size exceed the available size, it's should be allowed, * because maybe one entry size exceed the size and * the query must be finished, the available size will become invalid. * * @param size * allocate size */ public void allocate(long si...
3.26
pulsar_PulsarClusterMetadataSetup_createMetadataNode_rdh
/** * a wrapper for creating a persistent node with store.put but ignore exception of node exists. */ private static void createMetadataNode(MetadataStore store, String path, byte[] data) throws InterruptedException, ExecutionException { try {store.put(path, data, Optional.of(-1L)).get(); } catch (ExecutionEx...
3.26
pulsar_Subscription_isCumulativeAckMode_rdh
// Subscription utils static boolean isCumulativeAckMode(SubType subType) { return SubType.Exclusive.equals(subType) || SubType.Failover.equals(subType); }
3.26
pulsar_InstanceConfig_getInstanceName_rdh
/** * Get the string representation of {@link #getInstanceId()}. * * @return the string representation of {@link #getInstanceId()}. */ public String getInstanceName() { return "" + instanceId; }
3.26
pulsar_SchemasImpl_convertGetSchemaResponseToSchemaInfo_rdh
// the util function converts `GetSchemaResponse` to `SchemaInfo` static SchemaInfo convertGetSchemaResponseToSchemaInfo(TopicName tn, GetSchemaResponse response) { byte[] schema; if (response.getType() == SchemaType.KEY_VALUE) { try { schema = DefaultImplementation.getDefaultImplementation().convertKeyValueDataSt...
3.26
pulsar_SchemasImpl_convertSchemaDataToStringLegacy_rdh
// the util function exists for backward compatibility concern static String convertSchemaDataToStringLegacy(SchemaInfo schemaInfo) throws IOException { byte[] schemaData = schemaInfo.getSchema(); if (null == schemaInfo.getSchema()) { return ""; } if (schemaInfo.getType() == SchemaType.KEY_VALUE) { return DefaultImple...
3.26
pulsar_PulsarKafkaSinkTaskContext_currentOffset_rdh
// for tests private Long currentOffset(TopicPartition topicPartition) { Long offset = currentOffsets.computeIfAbsent(topicPartition, kv -> { List<ByteBuffer> req = Lists.newLinkedList(); ByteBuffer key = topicPartitionAsKey(topicPartition); req.add(key); ...
3.26
pulsar_AuthenticationFactoryOAuth2_clientCredentials_rdh
/** * Authenticate with client credentials. * * @param issuerUrl * the issuer URL * @param credentialsUrl * the credentials URL * @param audience * An optional field. The audience identifier used by some Identity Providers, like Auth0. * @param scope * An optional field. The value of the scope paramet...
3.26
pulsar_RawBatchMessageContainerImpl_setCryptoKeyReader_rdh
/** * Sets a CryptoKeyReader instance to encrypt batched messages during serialization, `toByteBuf()`. * * @param cryptoKeyReader * a CryptoKeyReader instance */ public void setCryptoKeyReader(CryptoKeyReader cryptoKeyReader) { this.cryptoKeyReader = cryptoKeyReader; }
3.26
pulsar_SubscriptionPolicies_checkEmpty_rdh
/** * Check if this SubscriptionPolicies is empty. Empty SubscriptionPolicies can be auto removed from TopicPolicies. * * @return true if this SubscriptionPolicies is empty. */ public boolean checkEmpty() { return dispatchRate == null; }
3.26
pulsar_FastThreadLocalStateCleaner_cleanupAllFastThreadLocals_rdh
// cleanup all fast thread local state on all active threads public void cleanupAllFastThreadLocals(BiConsumer<Thread, Object> cleanedValueListener) { for (Thread v11 : ThreadUtils.getAllThreads()) { cleanupAllFastThreadLocals(v11, cleanedValueListener); } }
3.26
pulsar_SaslAuthenticationState_authenticate_rdh
/** * Returns null if authentication has completed, and no auth data is required to send back to client. * Do auth and Returns the auth data back to client, if authentication has not completed. */ @Override public AuthData authenticate(AuthData ...
3.26
pulsar_RelativeTimeUtil_nsToSeconds_rdh
/** * Convert nanoseconds to seconds and keep three decimal places. * * @param ns * @return seconds */ public static double nsToSeconds(long ns) { double seconds = ((double) (ns)) / 1000000000; BigDecimal bd = new BigDecimal(seconds); return bd.setScale(3, RoundingMode.HALF_UP).doubleValue(); }
3.26
pulsar_ManagedCursor_asyncReadEntriesWithSkipOrWait_rdh
/** * Asynchronously read entries from the ManagedLedger, up to the specified number and size. * * <p/>If no entries are available, the callback will not be triggered. Instead it will be registered to wait until * a new message will be persisted into the managed ledger * * @see #readEntriesOrWait(int, long) * @p...
3.26
pulsar_ManagedCursor_skipNonRecoverableLedger_rdh
/** * If a ledger is lost, this ledger will be skipped after enabled "autoSkipNonRecoverableData", and the method is * used to delete information about this ledger in the ManagedCursor. */ default void skipNonRecoverableLedger(long ledgerId) {}
3.26
pulsar_ManagedCursor_seek_rdh
/** * Move the cursor to a different read position. * * <p/>If the new position happens to be before the already mark deleted position, it will be set to the mark * deleted position instead. * * @param newReadPosition * the position where to move the cursor */ default void seek(Position newReadPosition) {seek...
3.26
pulsar_ManagedCursor_m2_rdh
/** * Asynchronously read entries from the ManagedLedger, up to the specified number and size. * * <p/>If no entries are available, the callback will not be triggered. Instead it will be registered to wait until * a new message will be persisted into the managed ledger * * @see #readEntriesOrWait(int, long) * @p...
3.26
pulsar_ManagedCursor_scan_rdh
/** * Scan the cursor from the current position up to the end. * Please note that this is an expensive operation * * @param startingPosition * the position to start from, if not provided the scan will start from * the lastDeleteMarkPosition * @param condition * a condition to continue the scan, the condit...
3.26
pulsar_MessageId_fromByteArray_rdh
/** * De-serialize a message id from a byte array. * * @param data * byte array containing the serialized message id * @return the de-serialized messageId object * @throws IOException * if the de-serialization fails */ static MessageId fromByteArray(byte[] data) throws IOException {return DefaultImplementat...
3.26
pulsar_ModularLoadManagerImpl_m0_rdh
/** * As the leader broker, attempt to automatically detect and split hot namespace bundles. */ @Override public void m0() { if ((((!conf.isLoadBalancerAutoBundleSplitEnabled()) || (pulsar.getLeaderElectionService() == null)) || (!pulsar.getLeaderElectionService().isLeader())) || (knownBrokers.size() <= 1)) { return...
3.26
pulsar_ModularLoadManagerImpl_writeBrokerDataOnZooKeeper_rdh
/** * As any broker, write the local broker data to metadata store. */ @Override public void writeBrokerDataOnZooKeeper() { writeBrokerDataOnZooKeeper(false); }
3.26
pulsar_ModularLoadManagerImpl_selectBrokerForAssignment_rdh
/** * As the leader broker, find a suitable broker for the assignment of the given bundle. * * @param serviceUnit * ServiceUnitId for the bundle. * @return The name of the selected broker, as it appears on metadata store. */ @Overridepublic Optional<String> selectBrokerForAssignment(final ServiceUnitId serviceU...
3.26
pulsar_ModularLoadManagerImpl_updateBundleUnloadingMetrics_rdh
/** * As leader broker, update bundle unloading metrics. * * @param bundlesToUnload */ private void updateBundleUnloadingMetrics(Multimap<String, String> bundlesToUnload) { unloadBrokerCount += bundlesToUnload.keySet().size(); unloadBundleCount += bundlesToUnload.values().size();List<Metrics> metrics = new Arra...
3.26
pulsar_ModularLoadManagerImpl_disableBroker_rdh
/** * As any broker, disable the broker this manager is running on. * * @throws PulsarServerException * If there's a failure when disabling broker on metadata store. */ @Override public void disableBroker() throws PulsarServerException { if (StringUtils.isNotEmpty(brokerZnodePath)) { try { brokerDataLock.release...
3.26
pulsar_ModularLoadManagerImpl_getBundleDataOrDefault_rdh
// Attempt to local the data for the given bundle in metadata store // If it cannot be found, return the default bundle data. @Override public BundleData getBundleDataOrDefault(final String bundle) { BundleData bundleData = null; try { Optional<BundleData> optBundleData = pulsarResources.getLoadBalance...
3.26
pulsar_ModularLoadManagerImpl_updateBundleData_rdh
// As the leader broker, use the local broker data saved on metadata store to update the bundle stats so that better // load management decisions may be made. private void updateBundleData() { final Map<String, BundleData> bundleData = loadData.getBundleData(); final Set<String> activeBundles = new HashSet<>(); // Iter...
3.26
pulsar_ModularLoadManagerImpl_m1_rdh
/** * As any broker, retrieve the namespace bundle stats and system resource usage to update data local to this broker. * * @return */ @Override public LocalBrokerData m1() { lock.lock();try { final SystemResourceUsage systemResourceUsage = LoadManagerShared.getSystemResourceUsage(brokerHostUsage); localDat...
3.26
pulsar_ModularLoadManagerImpl_getBundleStats_rdh
// Use the Pulsar client to acquire the namespace bundle stats. private Map<String, NamespaceBundleStats> getBundleStats() { return pulsar.getBrokerService().getBundleStats(); }
3.26
pulsar_ModularLoadManagerImpl_updateAll_rdh
// Update both the broker data and the bundle data. public void updateAll() { if (log.isDebugEnabled()) { log.debug("Updating broker and bundle data for loadreport"); }cleanupDeadBrokersData(); updateAllBrokerData(); updateBundleData(); // broker has latest load-report: check if any bundle requires split m0(); }
3.26
pulsar_ModularLoadManagerImpl_updateLoadBalancingBundlesMetrics_rdh
/** * As any broker, update its bundle metrics. * * @param bundlesData */ private void updateLoadBalancingBundlesMetrics(Map<String, NamespaceBundleStats> bundlesData) { List<Metrics> metrics = new ArrayList<>(); for (Map.Entry<String, NamespaceBundleStats> entry : bundlesData.entrySet()) { final String bundle = e...
3.26
pulsar_ModularLoadManagerImpl_stop_rdh
/** * As any broker, stop the load manager. * * @throws PulsarServerException * If an unexpected error occurred when attempting to stop the load manager. */ @Override public void stop() throws PulsarServerException { executors.shutdownNow(); try { brokersData.close(); } catch (Exception e) { log.warn("Failed to...
3.26