name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
pulsar_PulsarRecordCursor_haveAvailableCacheSize_rdh
/** * Check the queue has available cache size quota or not. * 1. If the CacheSizeAllocator is NullCacheSizeAllocator, return true. * 2. If the available cache size > 0, return true. * 3. If the available cache size is invalid and the queue size == 0, return true, ensure not block the query. */ private boolean hav...
3.26
pulsar_PulsarRecordCursor_getSchemaInfo_rdh
/** * Get the schemaInfo of the message. * * 1. If the schema type of pulsarSplit is NONE or BYTES, use the BYTES schema. * 2. If the schema type of pulsarSplit is BYTEBUFFER, use the BYTEBUFFER schema. * 3. If the schema version of the message is null, use the schema info of pulsarSplit. * 4. If the schema versi...
3.26
pulsar_PulsarStandalone_builder_rdh
/** * This method gets a builder to build an embedded pulsar instance * i.e. * <pre> * <code> * PulsarStandalone pulsarStandalone = PulsarStandalone.builder().build(); * pulsarStandalone.start(); * pulsarStandalone.stop(); * </code> * </pre> * * @return PulsarStandaloneBuilder instance */ public static Puls...
3.26
pulsar_ConcurrentOpenHashMap_keys_rdh
/** * * @return a new list of all keys (makes a copy) */ public List<K> keys() { List<K> keys = new ArrayList<>(((int) (size()))); forEach((key, value) -> keys.add(key)); return keys; }
3.26
pulsar_ConcurrentOpenHashMap_equals_rdh
/** * This object is used to delete empty value in this map. * EmptyValue.equals(null) = true. */private static final Object EmptyValue = new Object() { @SuppressFBWarnings @Override public boolean equals(Object obj) { return obj == null; }
3.26
pulsar_ConcurrentOpenHashMap_forEach_rdh
/** * Iterate over all the entries in the map and apply the processor function to each of them. * <p> * <b>Warning: Do Not Guarantee Thread-Safety.</b> * * @param processor * the function to apply to each entry */ public void forEach(BiConsumer<? super K, ? super V> processor) { for (int i = 0; i < sectio...
3.26
pulsar_PulsarMockBookKeeper_returnEmptyLedgerAfter_rdh
/** * After N times, make a ledger to appear to be empty. */ public synchronized void returnEmptyLedgerAfter(int steps) { emptyLedgerAfter = steps; }
3.26
pulsar_MultiMessageIdImpl_toByteArray_rdh
// TODO: Add support for Serialization and Deserialization // https://github.com/apache/pulsar/issues/4940 @Override public byte[] toByteArray() { throw new UnsupportedOperationException(); }
3.26
pulsar_MultiMessageIdImpl_compareTo_rdh
// If all messageId in map are same size, and all bigger/smaller than the other, return valid value. @Override public int compareTo(MessageId o) { if (!(o instanceof MultiMessageIdImpl)) { throw new IllegalArgumentException("expected MultiMessageIdImpl object. Got instance of " + o.getClass().getName()); ...
3.26
pulsar_FunctionCommon_getStateNamespace_rdh
/** * Convert pulsar tenant and namespace to state storage namespace. * * @param tenant * pulsar tenant * @param namespace * pulsar namespace * @return state storage namespace */ public static String getStateNamespace(String tenant, String namespace) { return String.format("%s_%s", tenant, namespace).repl...
3.26
pulsar_KeyValueSchemaImpl_getKeySchema_rdh
/** * Get the Schema of the Key. * * @return the Schema of the Key */ @Override public Schema<K> getKeySchema() { return keySchema; }
3.26
pulsar_KeyValueSchemaImpl_encode_rdh
// encode as bytes: [key.length][key.bytes][value.length][value.bytes] or [value.bytes] public byte[] encode(KeyValue<K, V> message) { if ((keyValueEncodingType != null) && (keyValueEncodingType == KeyValueEncodingType.INLINE)) { return KeyValue.encode(message.getKey(), keySchema, message.getValue(), valueSchema)...
3.26
pulsar_KeyValueSchemaImpl_fetchSchemaIfNeeded_rdh
/** * It may happen that the schema is not loaded but we need it, for instance in order to call getSchemaInfo() * We cannot call this method in getSchemaInfo. * * @see AutoConsumeSchema#fetchSchemaIfNeeded(SchemaVersion) */ public void fetchSchemaIfNeeded(String topicName, SchemaVersion schemaVersion) throws Schem...
3.26
pulsar_KeyValueSchemaImpl_of_rdh
/** * Key Value Schema using passed in schema type, support JSON and AVRO currently. */ public static <K, V> Schema<KeyValue<K, V>> of(Class<K> key, Class<V> value, SchemaType type) { checkArgument((SchemaType.JSON == type) || (SchemaType.AVRO == type)); if (SchemaType.JSON == type) { return new KeyVa...
3.26
pulsar_AuthenticationService_authenticateHttpRequest_rdh
/** * * @deprecated use {@link #authenticateHttpRequest(HttpServletRequest, HttpServletResponse)} */ @Deprecated(since = "3.0.0") public String authenticateHttpRequest(HttpServletRequest request, AuthenticationDataSource authData) throws AuthenticationException { String authMethodName = getAuthMethodName(request...
3.26
pulsar_OwnershipCache_updateBundleState_rdh
/** * Update bundle state in a local cache. * * @param bundle * @throws Exception */ public CompletableFuture<Void> updateBundleState(NamespaceBundle bundle, boolean isActive) { // Disable owned instance in local cache CompletableFuture<OwnedBundle> f = ownedBundlesCache.getIfPresent(bundle); if ((...
3.26
pulsar_OwnershipCache_isNamespaceBundleOwned_rdh
/** * Checked whether a particular bundle is currently owned by this broker. * * @param bundle * @return */ public boolean isNamespaceBundleOwned(NamespaceBundle bundle) { OwnedBundle ownedBundle = m0(bundle); return (ownedBundle != null) && ownedBundle.isActive(); }
3.26
pulsar_OwnershipCache_m0_rdh
/** * Return the {@link OwnedBundle} instance from the local cache. Does not block. * * @param bundle * @return */ public OwnedBundle m0(NamespaceBundle bundle) { CompletableFuture<OwnedBundle> future = ownedBundlesCache.getIfPresent(bundle); if (((future != null) && future.isDone()) && (!future.isComplet...
3.26
pulsar_OwnershipCache_checkOwnershipAsync_rdh
/** * Check whether this broker owns given namespace bundle. * * @param bundle * namespace bundle * @return future that will complete with check result */ public CompletableFuture<Boolean> checkOwnershipAsync(NamespaceBundle bundle) { Optional<CompletableFuture<OwnedBundle>> ownedBundleFuture = getOwnedBund...
3.26
pulsar_OwnershipCache_tryAcquiringOwnership_rdh
/** * Method to get the current owner of the <code>NamespaceBundle</code> * or set the local broker as the owner if absent. * * @param bundle * the <code>NamespaceBundle</code> * @return The ephemeral node data showing the current ownership info in <code>ZooKeeper</code> * @throws Exception */ public Completa...
3.26
pulsar_OwnershipCache_removeOwnership_rdh
/** * Method to remove the ownership of local broker on the <code>NamespaceBundle</code>, if owned. */ public CompletableFuture<Void> removeOwnership(NamespaceBundle bundle) { ResourceLock<NamespaceEphemeralData> lock = locallyAcquiredLocks.remove(bundle); if (lock == null) { // We don't own the...
3.26
pulsar_FunctionsApiV2Resource_getConnectorsList_rdh
/** * Deprecated in favor of moving endpoint to {@link org.apache.pulsar.broker.admin.v2.Worker} */ @GET @ApiOperation(value = "Fetches a list of supported Pulsar IO connectors currently running in cluster mode", response = List.class) @ApiResponses({ @ApiResponse(code = 403, message = "The requester doesn't have adm...
3.26
pulsar_GenericSchemaImpl_of_rdh
/** * warning : * we suggest migrate GenericSchemaImpl.of() to <GenericSchema Implementor>.of() method * (e.g. GenericJsonSchema 、GenericAvroSchema ) * * @param schemaInfo * {@link SchemaInfo} * @param useProvidedSchemaAsReaderSchema * {@link Boolean} * @return generic schema implementation */ public sta...
3.26
pulsar_PulsarClientException_getPreviousExceptions_rdh
/** * Get the collection of previous exceptions which have caused retries * for this operation. * * @return a collection of exception, ordered as they occurred */ public Collection<Throwable> getPreviousExceptions() { return this.previous; }
3.26
pulsar_PulsarClientException_wrap_rdh
// wrap an exception to enriching more info messages. public static Throwable wrap(Throwable t, String msg) { msg += "\n" + t.getMessage(); // wrap an exception with new message info if (t instanceof TimeoutException) { return new TimeoutException(msg...
3.26
pulsar_PulsarClientException_setPreviousExceptions_rdh
/** * Add a list of previous exception which occurred for the same operation * and have been retried. * * @param previous * A collection of throwables that triggered retries */public void setPreviousExceptions(Collection<Throwable> previous) { this.previous = previous;}
3.26
pulsar_MessageParser_parseMessage_rdh
/** * Parse a raw Pulsar entry payload and extract all the individual message that may be included in the batch. The * provided {@link MessageProcessor} will be invoked for each individual message. */ public static void parseMessage(TopicName topicName, long ledgerId, long entryId, ByteBuf headersAndPayload, Message...
3.26
pulsar_SchemaDataValidator_validateSchemaData_rdh
/** * Validate if the schema data is well formed. * * @param schemaData * schema data to validate * @throws InvalidSchemaDataException * if the schema data is not in a valid form. */ static void validateSchemaData(SchemaData schemaData) throws InvalidSchemaDataException ...
3.26
pulsar_ReplicatedSubscriptionsController_completed_rdh
/** * From Topic.PublishContext. */@Override public void completed(Exception e, long ledgerId, long entryId) { // Nothing to do in case of publish errors since the retry logic is applied upstream after a snapshot is not // closed if (log.isDebugEnabled()) { log.debug("[{}] Published marker at {}:{...
3.26
pulsar_TenantsImpl_m0_rdh
// Compat method names @Override public void m0(String tenant, TenantInfo config) throws PulsarAdminException { createTenant(tenant, config); }
3.26
pulsar_AbstractDispatcherMultipleConsumers_getConsumerFromHigherPriority_rdh
/** * Finds index of first available consumer which has higher priority then given targetPriority. * * @param targetPriority * @return -1 if couldn't find any available consumer */ private int getConsumerFromHigherPriority(int targetPriority) { for (int i = 0; i < currentConsumerRoundRobinIndex; i++) { ...
3.26
pulsar_AbstractDispatcherMultipleConsumers_getNextConsumerFromSameOrLowerLevel_rdh
/** * Finds index of round-robin available consumer that present on same level as consumer on * currentRoundRobinIndex if doesn't find consumer on same level then it finds first available consumer on lower * priority level else returns * index=-1 if couldn't find any available consumer in the list. * * @param cur...
3.26
pulsar_AbstractDispatcherMultipleConsumers_getRandomConsumer_rdh
/** * Get random consumer from consumerList. * * @return null if no consumer available, else return random consumer from consumerList */ public Consumer getRandomConsumer() { if (consumerList.isEmpty() || (IS_CLOSED_UPDATER.get(this) == TRUE)) { // abort read if no consumers are connected of if disconne...
3.26
pulsar_AbstractDispatcherMultipleConsumers_getNextConsumer_rdh
/** * <pre> * Broker gives more priority while dispatching messages. Here, broker follows descending priorities. (eg: * 0=max-priority, 1, 2,..) * <p> * Broker will first dispatch messages to max priority-level consumers if they * have permits, else broker will consider next priority level consumers. * Also on t...
3.26
pulsar_AbstractDispatcherMultipleConsumers_getFirstConsumerIndexOfPriority_rdh
/** * Finds index of first consumer in list which has same priority as given targetPriority. * * @param targetPriority * @return */ private int getFirstConsumerIndexOfPriority(int targetPriority) { for (int i = 0; i < consumerList.size(); i++) { if (consumerList.get(i).getPriorityLevel() == targetPriority)...
3.26
pulsar_ConsumerHandler_handleEndOfTopic_rdh
// Check and notify consumer if reached end of topic. private void handleEndOfTopic() { if (log.isDebugEnabled()) { log.debug("[{}/{}] Received check reach the end of topic request from {} ", consumer.getTopic(), subscription, getRemote().getInetSocketAddress().toString()); ...
3.26
pulsar_Reflections_classInJarImplementsIface_rdh
/** * check if a class implements an interface. * * @param fqcn * fully qualified class name to search for in jar * @param xface * interface to check if implement * @return true if class from jar implements interface xface and false if otherwise */ public static boolean classInJarImplementsIface(File jar, S...
3.26
pulsar_Reflections_classExistsInJar_rdh
/** * Check if a class is in a jar. * * @param jar * location of the jar * @param fqcn * fully qualified class name to search for in jar * @return true if class can be loaded from jar and false if otherwise */ public static boolean classExistsInJar(File jar, String fqcn) { URLClassLoader loader = null; try ...
3.26
pulsar_Reflections_loadClass_rdh
/** * Load class to resolve array types. * * @param className * class name * @param classLoader * class loader * @return loaded class * @throws ClassNotFoundException */ public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException { if (className.length() == 1...
3.26
pulsar_Reflections_createInstance_rdh
/** * Create an instance of <code>userClassName</code> using provided <code>classLoader</code>. * * @param userClassName * user class name * @param classLoader * class loader to load the class. * @return the instance */ public static Object createInstance(String userC...
3.26
pulsar_Reflections_classImplementsIface_rdh
/** * check if class implements interface. * * @param fqcn * fully qualified class name * @param xface * the interface the fqcn should implement * @return true if class implements interface xface and false if otherwise */ public static boolean classImplementsIface(String fqcn, Class xface) { boolean ret...
3.26
pulsar_Reflections_classExists_rdh
/** * Check if class exists. * * @param fqcn * fully qualified class name to search for * @return true if class can be loaded from jar and false if otherwise */ public static boolean classExists(String fqcn) { try { Class.forName(fqcn); return true; } catch (ClassNotFoundException e) ...
3.26
pulsar_AuthenticationDataHttp_hasSubscription_rdh
/* Subscription */ @Override public boolean hasSubscription() { return this.subscription != null; }
3.26
pulsar_AuthenticationDataHttp_hasDataFromHttp_rdh
/* HTTP */ @Override public boolean hasDataFromHttp() { return true; }
3.26
pulsar_NonPersistentTopicsImpl_validateTopic_rdh
/* returns topic name with encoded Local Name */ private TopicName validateTopic(String topic) { // Parsing will throw exception if name is not valid return TopicName.get(topic); }
3.26
pulsar_ClearTextSecretsProvider_provideSecret_rdh
/** * Fetches a secret. * * @return The actual secret */ @Override public String provideSecret(String secretName, Object pathToSecret) { if (pathToSecret != null) { return pathToSecret.toString(); } else { return null;} }
3.26
pulsar_NonPersistentReplicator_getProducerName_rdh
/** * * @return Producer name format : replicatorPrefix.localCluster-->remoteCluster */ @Override protected String getProducerName() { return (getReplicatorName(replicatorPrefix, localCluster) + REPL_PRODUCER_NAME_DELIMITER) + remoteCluster; }
3.26
pulsar_ConcurrentLongHashMap_forEach_rdh
/** * Iterate over all the entries in the map and apply the processor function to each of them. * <p> * <b>Warning: Do Not Guarantee Thread-Safety.</b> * * @param processor * the processor to apply to each entry */ public void forEach(EntryProcessor<V> processor) { for (int v19 = 0; v19 < sections.length; ...
3.26
pulsar_ConcurrentLongHashMap_keys_rdh
/** * * @return a new list of all keys (makes a copy) */ public List<Long> keys() { List<Long> v20 = Lists.newArrayListWithExpectedSize(((int) (size()))); forEach((key, value) -> v20.add(key)); return v20; }
3.26
pulsar_TokenClient_buildClientCredentialsBody_rdh
/** * Constructing http request parameters. * * @param req * object with relevant request parameters * @return Generate the final request body from a map. */ String buildClientCredentialsBody(ClientCredentialsExchangeRequest req) { Map<String, String> bodyMap = new TreeMap<>(); bodyMap.put("grant_type", "clien...
3.26
pulsar_TokenClient_exchangeClientCredentials_rdh
/** * Performs a token exchange using client credentials. * * @param req * the client credentials request details. * @return a token result * @throws TokenExchangeException */ public TokenResult exchangeClientCredentials(ClientCredentialsExchangeRequest req) throws TokenExchangeException, IOException { String...
3.26
pulsar_TimeAverageMessageData_getUpdatedValue_rdh
// Update the average of a sample using the number of samples, the previous // average, and a new sample. private double getUpdatedValue(final double oldAverage, final double newSample) { // Note that for numSamples == 1, this returns newSample. // This ensures that default stats get overwritten after the first...
3.26
pulsar_TimeAverageMessageData_totalMsgThroughput_rdh
/** * Get the total message throughput. * * @return Message throughput in + message throughput out. */ public double totalMsgThroughput() {return msgThroughputIn + msgThroughputOut; }
3.26
pulsar_TimeAverageMessageData_update_rdh
/** * Update using new samples for the message data. * * @param newMsgThroughputIn * Most recently observed throughput in. * @param newMsgThroughputOut * Most recently observed throughput out. * @param newMsgRateIn * Most recently observed message rate in. * @param newMsgRateOut * Most recently observ...
3.26
pulsar_PersistentSubscription_delete_rdh
/** * Delete the subscription by closing and deleting its managed cursor. Handle unsubscribe call from admin layer. * * @param closeIfConsumersConnected * Flag indicate whether explicitly close connected consumers before trying to * delete subscription. If * any consumer is connected to it and if this flag ...
3.26
pulsar_PersistentSubscription_doUnsubscribe_rdh
/** * Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with * unsubscribe. * * @param consumer * consumer object that is initiating the unsubscribe operation * @return CompletableFuture indicating the completion of unsubscribe operation */ @Override public C...
3.26
pulsar_PersistentSubscription_mergeCursorProperties_rdh
/** * Return a merged map that contains the cursor properties specified by used * (eg. when using compaction subscription) and the subscription properties. */ protected Map<String, Long> mergeCursorProperties(Map<String, Long> userProperties) { Map<String, Long> baseProperties = getBaseCursorProperties(isReplicated(...
3.26
pulsar_PersistentSubscription_resumeAfterFence_rdh
/** * Resume subscription after topic deletion or close failure. */ public synchronized void resumeAfterFence() { // If "fenceFuture" is null, it means that "disconnect" has never been called. if (fenceFuture != null) { fenceFuture.whenComplete((ignore, ignoreEx) -> { synchronized(this) { try { if (IS_FENCED_UPDATER....
3.26
pulsar_PersistentSubscription_deleteForcefully_rdh
/** * Forcefully close all consumers and deletes the subscription. * * @return */ @Overridepublic CompletableFuture<Void> deleteForcefully() { return delete(true); }
3.26
pulsar_PersistentSubscription_close_rdh
/** * Close the cursor ledger for this subscription. Requires that there are no active consumers on the dispatcher * * @return CompletableFuture indicating the completion of delete operation */ @Override public CompletableFuture<Void> close() { synchronized(this) { if ((dispatcher != null) && dispatcher.isConsu...
3.26
pulsar_ManagedLedgerPayloadProcessor_inputProcessor_rdh
/** * Used by ManagedLedger for pre-processing payload before storing in bookkeeper ledger. * * @return Handle to Processor instance */ default Processor inputProcessor() { return null; }
3.26
pulsar_ManagedLedgerPayloadProcessor_outputProcessor_rdh
/** * Used by ManagedLedger for processing payload after reading from bookkeeper ledger. * * @return Handle to Processor instance */ default Processor outputProcessor() { return null; }
3.26
pulsar_ZipFiles_isZip_rdh
/** * Returns true if the given file is a gzip file. */ public static boolean isZip(File f) { try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)))) { int test = in.readInt(); return test == 0x504b0304; } catch (final Exception e) { return f...
3.26
pulsar_ZipFiles_lines_rdh
/** * Get a lazily loaded stream of lines from a gzipped file, similar to * {@link Files#lines(java.nio.file.Path)}. * * @param path * The path to the zipped file. * @return stream with lines. */ public static Stream<String> lines(Path path) { ZipInputStream zipStream = null; try { zipStream =...
3.26
pulsar_DataBlockHeaderImpl_fromStream_rdh
// Construct DataBlockHeader from InputStream, which contains `HEADER_MAX_SIZE` bytes readable. public static DataBlockHeader fromStream(InputStream stream) throws IOException { CountingInputStream countingStream = new CountingInputStream(stream); DataInputStream dis = new DataInputStream(countingStream); int m...
3.26
pulsar_DataBlockHeaderImpl_toStream_rdh
/** * Get the content of the data block header as InputStream. * Read out in format: * [ magic_word -- int ][ block_len -- int ][ first_entry_id -- long] [padding zeros] */ @Override public InputStream toStream() { ByteBuf out = PulsarByteBufAl...
3.26
pulsar_AuthenticationDataHttps_hasDataFromTls_rdh
/* TLS */ @Override public boolean hasDataFromTls() { return certificates != null; }
3.26
pulsar_NarClassLoader_getServiceDefinition_rdh
/** * Read a service definition as a String. */public String getServiceDefinition(String serviceName) throws IOException { String serviceDefPath = (narWorkingDirectory + "/META-INF/services/") + serviceName; return new String(Files.readAllBytes(Paths.get(serviceDefPath)), StandardCharsets.UTF_8); }
3.26
pulsar_NarClassLoader_updateClasspath_rdh
/** * Adds URLs for the resources unpacked from this NAR: * <ul> * <li>the root: for classes, <tt>META-INF</tt>, etc.</li> * <li><tt>META-INF/dependencies</tt>: for config files, <tt>.so</tt>s, etc.</li> * <li><tt>META-INF/dependencies/*.jar</tt>: for dependent libraries</li> * </ul> ...
3.26
pulsar_WatermarkCountTriggerPolicy_handleWaterMarkEvent_rdh
/** * Triggers all the pending windows up to the waterMarkEvent timestamp * based on the sliding interval count. * * @param waterMarkEvent * the watermark event */ private void handleWaterMarkEvent(Event<T> waterMarkEvent) { long watermarkTs = waterMarkEvent.getTimestamp(); List<Long> eventTs = windowMa...
3.26
pulsar_ElasticSearchSink_m0_rdh
/** * Extract ES _id and _source using the Schema if available. * * @param record * @return A pair for _id and _source */ public Pair<String, String> m0(Record<GenericObject> ...
3.26
pulsar_ElasticSearchSink_stringifyKey_rdh
/** * Convert a JsonNode to an Elasticsearch id. */ public String stringifyKey(JsonNode jsonNode) throws JsonProcessingException { List<String> fields = new ArrayList<>(); jsonNode.fieldNames().forEachRemaining(fields::add); return stringifyKey(jsonNode, fields); }
3.26
pulsar_PrometheusMetricStreams_flushAllToStream_rdh
/** * Flush all the stored metrics to the supplied stream. * * @param stream * the stream to write to. */ void flushAllToStream(SimpleTextOutputStream stream) { metricStreamMap.values().forEach(s -> stream.write(s.getBuffer())); }
3.26
pulsar_PrometheusMetricStreams_writeSample_rdh
/** * Write the given metric and sample value to the stream. Will write #TYPE header if metric not seen before. * * @param metricName * name of the metric. * @param value * value of the sample * @param labelsAndValuesArray * varargs of label and label value */ void writeSample(String metricName, Number v...
3.26
pulsar_PrometheusMetricStreams_releaseAll_rdh
/** * Release all the streams to clean up resources. */void releaseAll() { metricStreamMap.values().forEach(s -> s.getBuffer().release()); metricStreamMap.clear(); }
3.26
pulsar_LoadReportDeserializer_deserialize_rdh
/** * Deserializer for a load report. */public class LoadReportDeserializer extends JsonDeserializer<LoadManagerReport> {@Override public LoadManagerReport deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectReader ...
3.26
pulsar_JdbcUtils_getTableId_rdh
/** * Get the {@link TableId} for the given tableName. */ public static TableId getTableId(Connection connection, String tableName) throws Exception { DatabaseMetaData metadata = connection.getMetaData(); try (ResultSet rs = metadata.getTables(null, null, tableName, new String[]{ "TABLE", "PARTITIONE...
3.26
pulsar_JdbcUtils_getTableDefinition_rdh
/** * Get the {@link TableDefinition} for the given table. */ public static TableDefinition getTableDefinition(Connection connection, TableId tableId, List<String> keyList, List<String> nonKeyList, boolean excludeNonDeclaredFields) throws Exception { TableDefinition table = TableDefinition.of(tableId, ...
3.26
pulsar_FunctionCacheManager_unregisterFunction_rdh
/** * Unregisters a job from the function cache manager. * * @param fid * function id */ default void unregisterFunction(String fid) { unregisterFunctionInstance(fid, null); }
3.26
pulsar_FunctionCacheManager_registerFunction_rdh
/** * Registers a function with its required jar files and classpaths. * * <p>The jar files are identified by their blob keys and downloaded for * use by a {@link ClassLoader}. * * @param fid * function id * @param requiredJarFiles * collection of blob keys identifying the required jar files. * @param req...
3.26
pulsar_TopicPoliciesService_getTopicPoliciesAsyncWithRetry_rdh
/** * When getting TopicPolicies, if the initialization has not been completed, * we will go back off and try again until time out. * * @param topicName * topic name * @param backoff * back off policy * @param isGlobal * is global policies * @return CompletableFuture&lt;Optional&lt;TopicPolicies&gt;&gt;...
3.26
pulsar_ConcurrentLongLongPairHashMap_keys_rdh
/** * * @return a new list of all keys (makes a copy). */ public List<LongPair> keys() { List<LongPair> keys = Lists.newArrayListWithExpectedSize(((int) (size()))); forEach((key1, key2, value1, value2) -> keys.add(new LongPair(key1, key2))); return keys; }
3.26
pulsar_ConcurrentLongLongPairHashMap_forEach_rdh
/** * Iterate over all the entries in the map and apply the processor function to each of them. * <p> * <b>Warning: Do Not Guarantee Thread-Safety.</b> * * @param processor * the processor to process the elements. */ public void forEach(BiConsumerLongPair processor) { for (Section s : sections) { s...
3.26
pulsar_ConcurrentLongLongPairHashMap_remove_rdh
/** * Remove an existing entry if found. * * @param key1 * @param key2 * @return the value associated with the key or -1 if key was not present. */public boolean remove(long key1, long key2) { checkBiggerEqualZero(key1); long v14 = hash(key1, key2); return getSection(v14).remove(key1, key2, ValueNo...
3.26
pulsar_ConcurrentLongLongPairHashMap_get_rdh
/** * * @param key1 * @param key2 * @return the value or -1 if the key was not present. */ public LongPair get(long key1, long key2) { checkBiggerEqualZero(key1); long h = hash(key1, key2); return getSection(h).get(key1, key2, ((int) (h))); }
3.26
pulsar_TopicPoliciesImpl_m7_rdh
/* returns topic name with encoded Local Name */ private TopicName m7(String topic) { // Parsing will throw exception if name is not valid return TopicName.get(topic); }
3.26
pulsar_ReplicatedSubscriptionSnapshotCache_advancedMarkDeletePosition_rdh
/** * Signal that the mark-delete position on the subscription has been advanced. If there is a snapshot that * correspond to this position, it will returned, other it will return null. */ public synchronized ReplicatedSubscriptionsSnapshot advancedMarkDeletePosition(PositionImpl pos) {ReplicatedSubscriptionsSnapsho...
3.26
pulsar_ReaderHandler_handleEndOfTopic_rdh
// Check and notify reader if reached end of topic. private void handleEndOfTopic() { try { String msg = objectWriter().writeValueAsString(new EndOfTopicResponse(reader.hasReachedEndOfTopic())); getSession().getRemote().sendString(msg, new WriteCallback() { @Override public void writeFailed(Throwable th) { log.warn("[{...
3.26
pulsar_PulsarAuthorizationProvider_canLookupAsync_rdh
/** * Check whether the specified role can perform a lookup for the specified topic. * * 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, String ...
3.26
pulsar_PulsarAuthorizationProvider_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_PulsarAuthorizationProvider_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_GZipFiles_isGzip_rdh
/** * Returns true if the given file is a gzip file. */ public static boolean isGzip(File f) { try (InputStream input = new FileInputStream(f)) { PushbackInputStream pb = new PushbackInputStream(input, 2); byte[] signature = new byte[2]; int len = pb.read(signature);// read the signat...
3.26
pulsar_GZipFiles_lines_rdh
/** * Get a lazily loaded stream of lines from a gzipped file, similar to * {@link Files#lines(java.nio.file.Path)}. * * @param path * The path to the gzipped file. * @return stream with lines. */ public static Stream<String> lines(Path path) { GZIPInputStream gzipStream = null; try { gzipSt...
3.26
pulsar_SchemaStorage_put_rdh
/** * Put the schema to the schema storage. * * @param key * The schema ID * @param fn * The function to calculate the value and hash that need to put to the schema storage * The input of the function is all the existing schemas that used to do the schemas compatibility check * @return The schema version ...
3.26
pulsar_SimpleLoadManagerImpl_doNamespaceBundleSplit_rdh
/** * Detect and split hot namespace bundles. */@Override public void doNamespaceBundleSplit() throws Exception { int maxBundleCount = pulsar.getConfiguration().getLoadBalancerNamespaceMaximumBundles(); long maxBundleTopics = pulsar.getConfiguration().getLoadBalancerNamespaceBundleMaxTopics(); long maxBundleSessions...
3.26
pulsar_SimpleLoadManagerImpl_getTotalAllocatedQuota_rdh
/** * Get the sum of allocated resource for the list of namespace bundles. */ private ResourceQuota getTotalAllocatedQuota(Set<String> bundles) {ResourceQuota totalQuota = new ResourceQuota(); for (String bundle : bundles) { ResourceQuota quota = this.getResourceQuota(bundle); totalQuota.add(quota); } return ...
3.26
pulsar_SimpleLoadManagerImpl_m1_rdh
/* temp method, remove it in future, in-place to make this glue code to make load balancing work */ private PulsarResourceDescription m1(LoadReport report) { SystemResourceUsage sru = report.getSystemResourceUsage();PulsarResourceDescription resourceDescription = new PulsarResourceDescription(); if (sru == null) {retur...
3.26
pulsar_SimpleLoadManagerImpl_updateBrokerToNamespaceToBundle_rdh
// Update the brokerToNamespaceToBundleRange map with the current preallocated and assigned bundle data. private synchronized void updateBrokerToNamespaceToBundle() { resourceUnitRankings.forEach((resourceUnit, ranking) -> { final String broker = resourceUnit.getResourceId(); final Set<String> loadedBundles = ranking...
3.26
pulsar_SimpleLoadManagerImpl_findBrokerForPlacement_rdh
/** * Assign owner for specified ServiceUnit from the given candidates, following the the principles: 1) Optimum * distribution: fill up one broker till its load reaches optimum level (defined by underload threshold) before pull * another idle broker in; 2) Even distribution: once all brokers' load are above optimum...
3.26
pulsar_SimpleLoadManagerImpl_isBrokerAvailableForRebalancing_rdh
// todo: changeme: this can be optimized, we don't have to iterate through everytime private boolean isBrokerAvailableForRebalancing(String bundleName, long maxLoadLevel) { NamespaceName namespaceName = NamespaceName.get(LoadManagerShared.getNamespaceNameFromBundleName(bundleName)); Map<Long, Set<ResourceUnit>> availa...
3.26