name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
pulsar_FunctionRuntimeManager_findAssignment_rdh
/** * Private methods for internal use. Should not be used outside of this class */ private Assignment findAssignment(String tenant, String namespace, String functionName, int instanceId) { String v95 = FunctionCommon.getFullyQualifiedInstanceId(tenant, namespace, functionName, instanceId); for (Map.Entry<St...
3.26
pulsar_FunctionRuntimeManager_restartFunctionUsingPulsarAdmin_rdh
/** * Restart the entire function or restart a single instance of the function. */ @VisibleForTesting void restartFunctionUsingPulsarAdmin(Assignment assignment, String tenant, String namespace, String functionName, boolean restartEntireFunction) throws Puls...
3.26
pulsar_FunctionRuntimeManager_processAssignment_rdh
/** * Process an assignment update from the assignment topic. * * @param newAssignment * the assignment */ public synchronized void processAssignment(Assignment newAssignment) { boolean exists = false; for (Map<String, Assignment> entry : this.workerIdToAssignments.values()) { if (entry.containsK...
3.26
pulsar_FunctionRuntimeManager_findFunctionAssignments_rdh
/** * Find all instance assignments of function. * * @param tenant * @param namespace * @param functionName * @return */ public synchronized Collection<Assignment> findFunctionAssignments(String tenant, String namespace, String functionName) { return findFunctionAssignments(tenant, namespace, functionName, this...
3.26
pulsar_FunctionRuntimeManager_removeAssignments_rdh
/** * Removes a collection of assignments. * * @param assignments * assignments to remove */ public synchronized void removeAssignments(Collection<Assignment> assignments) { for (Assignment assignment : assignments) { this.deleteAssignment(assignment); } }
3.26
pulsar_FunctionRuntimeManager_findFunctionAssignment_rdh
/** * Find a assignment of a function. * * @param tenant * the tenant the function belongs to * @param namespace * the namespace the function belongs to * @param functionName * the function name * @return the assignment of the function */ public synchronized Assignment findFunctionAssignment(String tena...
3.26
pulsar_FunctionRuntimeManager_getMyInstances_rdh
/** * Methods for metrics. * */ public int getMyInstances() { Map<String, Assignment> myAssignments = workerIdToAssignments.get(workerConfig.getWorkerId()); return myAssignments == null ? 0 : myAssignments.size(); }
3.26
pulsar_FunctionRuntimeManager_stopAllOwnedFunctions_rdh
/** * It stops all functions instances owned by current worker. * * @throws Exception */ public void stopAllOwnedFunctions() { if (runtimeFactory.externallyManaged()) { log.warn("Will not stop any functions since they are externally managed"); return; } final String worke...
3.26
pulsar_FunctionRuntimeManager_getFunctionInstanceStats_rdh
/** * Get stats of a function instance. If this worker is not running the function instance. * * @param tenant * the tenant the function belongs to * @param namespace * the namespace the function belongs to * @param functionName * the function name * @param instanceId * the function instance id * @r...
3.26
pulsar_FunctionRuntimeManager_initialize_rdh
/** * Initializes the FunctionRuntimeManager. Does the following: * 1. Consume all existing assignments to establish existing/latest set of assignments * 2. After current assignments are read, assignments belonging to this worker will be processed * * @return the message id of the message processed during init ph...
3.26
pulsar_RuntimeUtils_splitRuntimeArgs_rdh
/** * Regex for splitting a string using space when not surrounded by single or double quotes. */ public static String[] splitRuntimeArgs(String input) { return input.split("\\s(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); }
3.26
pulsar_RuntimeUtils_getGoInstanceCmd_rdh
/** * Different from python and java function, Go function uploads a complete executable file(including: * instance file + user code file). Its parameter list is provided to the broker in the form of a yaml file, * the advantage of this approach is that backward compatibility is guara...
3.26
pulsar_ResourceGroup_accumulateBMCount_rdh
// Visibility for unit testing protected static BytesAndMessagesCount accumulateBMCount(BytesAndMessagesCount... bmCounts) { BytesAndMessagesCount retBMCount = new BytesAndMessagesCount(); for (int ix = 0; ix < bmCounts.length; ix++) { retBMCount.f1 += bmCounts[ix].f1; retBMCount.f0 += bmCounts...
3.26
pulsar_ResourceGroup_getUsageFromMonitoredEntity_rdh
// Update fields in a particular monitoring class from a given broker in the // transport-manager callback for listening to usage reports. private void getUsageFromMonitoredEntity(ResourceGroupMonitoringClass monClass, NetworkUsage p, String broker) { final int idx = monClass.ordinal(); PerMonitoringClassFields...
3.26
pulsar_ResourceGroup_rgFillResourceUsage_rdh
// Transport manager mandated op. public void rgFillResourceUsage(ResourceUsage resourceUsage) { NetworkUsage p; resourceUsage.setOwner(this.getID()); p = resourceUsage.setPublish(); this.setUsageInMonitoredEntity(ResourceGroupMonitoringClass.Publish, p); p = resourceUsage.setDispatch(); this.setUsageInMonitoredEntity...
3.26
pulsar_ResourceGroup_rgResourceUsageListener_rdh
// Transport manager mandated op. public void rgResourceUsageListener(String broker, ResourceUsage resourceUsage) { NetworkUsage p; p = resourceUsage.getPublish(); this.getUsageFromMonitoredEntity(ResourceGroupMonitoringClass.Publish, p, broker); p = resourceUsage.getDispatch(); this.getUsageFromMonitoredEntity(Resour...
3.26
pulsar_ResourceGroup_getRgRemoteUsageMessageCount_rdh
// Visibility for unit testing protected static double getRgRemoteUsageMessageCount(String rgName, String monClassName, String brokerName) { return rgRemoteUsageReportsMessages.labels(rgName, monClassName, brokerName).get(); }
3.26
pulsar_ResourceGroup_getRgUsageReportedCount_rdh
// Visibility for unit testing protected static double getRgUsageReportedCount(String rgName, String monClassName) { return rgLocalUsageReportCount.labels(rgName, monClassName).get(); }
3.26
pulsar_ResourceGroup_getRgRemoteUsageByteCount_rdh
// Visibility for unit testing protected static double getRgRemoteUsageByteCount(String rgName, String monClassName, String brokerName) { return rgRemoteUsageReportsBytes.labels(rgName, monClassName, brokerName).get(); }
3.26
pulsar_ResourceGroup_setUsageInMonitoredEntity_rdh
// Fill usage about a particular monitoring class in the transport-manager callback // for reporting local stats to other brokers. // Returns true if something was filled. // Visibility for unit testing. protected boolean setUsageInMonitoredEntity(ResourceGroupMonitoringClass monClass, NetworkUsage p) { long bytesU...
3.26
pulsar_NonPersistentSubscriptionStatsImpl_add_rdh
// if the stats are added for the 1st time, we will need to make a copy of these stats and add it to the current // stats public NonPersistentSubscriptionStatsImpl add(NonPersistentSubscriptionStatsImpl stats) {Objects.requireNonNull(stats); super.add(stats); this.msgDropRate += stats.msgDropRate; return t...
3.26
pulsar_ImmutableBucket_recoverDelayedIndexBitMapAndNumber_rdh
/** * Recover delayed index bit map and message numbers. * * @throws InvalidRoaringFormat * invalid bitmap serialization format */ private void recoverDelayedIndexBitMapAndNumber(int startSnapshotIndex, List<SnapshotSegmentMetadata> segmentMetaList) { delayedIndexBitMap.clear();// cleanup dirty bm final var nu...
3.26
pulsar_ReaderListener_reachedEndOfTopic_rdh
/** * Get the notification when a topic is terminated. * * @param reader * the Reader object associated with the terminated topic */ default void reachedEndOfTopic(Reader reader) { // By default ignore the notification }
3.26
pulsar_ConsumerConfigurationData_getMaxPendingChuckedMessage_rdh
/** * * @deprecated use {@link #getMaxPendingChunkedMessage()} */ @Deprecated public int getMaxPendingChuckedMessage() { return maxPendingChunkedMessage; }
3.26
pulsar_ConsumerConfigurationData_setMaxPendingChuckedMessage_rdh
/** * * @deprecated use {@link #setMaxPendingChunkedMessage(int)} */ @Deprecated public void setMaxPendingChuckedMessage(int maxPendingChuckedMessage) { this.maxPendingChunkedMessage = maxPendingChuckedMessage; }
3.26
pulsar_WaterMarkEventGenerator_track_rdh
/** * Tracks the timestamp of the event from a topic, returns * true if the event can be considered for processing or * false if its a late event. */ public boolean track(String inputTopic, long ts) { Long currentVal = f0.get(inputTopic); if ((currentVal == null) || (ts > currentVal)) { f0.put(inpu...
3.26
pulsar_WaterMarkEventGenerator_computeWaterMarkTs_rdh
/** * Computes the min ts across all input topics. */ private long computeWaterMarkTs() { long ts = 0; // only if some data has arrived on each input topic if (f0.size() >= inputTopics.size()) { ts = Long.MAX_VALUE; for (Map.Entry<String, Long> entry : f0.entrySet()) { ts =...
3.26
pulsar_ManagedLedgerOfflineBacklog_getNumberOfEntries_rdh
// need a better way than to duplicate the functionality below from ML private long getNumberOfEntries(Range<PositionImpl> range, NavigableMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgers) { PositionImpl fromPosition = range.lowerEndpoint(); boolean fromIncluded = range.lowerBoundType() == BoundTy...
3.26
pulsar_OffloadPoliciesImpl_oldPoliciesCompatible_rdh
/** * This method is used to make a compatible with old policies. * * <p>The filed {@link Policies#offload_threshold} is primitive, so it can't be known whether it had been set. * In the old logic, if the field value is -1, it could be thought that the field had not been set. * * @param nsLevelPolicies * names...
3.26
pulsar_OffloadPoliciesImpl_mergeConfiguration_rdh
/** * Merge different level offload policies. * * <p>policies level priority: topic > namespace > broker * * @param topicLevelPolicies * topic level offload policies * @param nsLevelPolicies * namespace level offload policies * @param brokerProperties * broker level offload configuration * @return offl...
3.26
pulsar_OffloadPoliciesImpl_getCompatibleValue_rdh
/** * Make configurations of the OffloadPolicies compatible with the config file. * * <p>The names of the fields {@link OffloadPoliciesImpl#managedLedgerOffloadDeletionLagInMillis} * and {@link OffloadPoliciesImpl#managedLedgerOffloadThresholdInBytes} are not matched with * config file (broker.conf or standalone.c...
3.26
pulsar_ConsumerImpl_createEncryptionContext_rdh
/** * Create EncryptionContext if message payload is encrypted. * * @param msgMetadata * @return {@link Optional}<{@link EncryptionContext}> */ private Optional<EncryptionContext> createEncryptionContext(MessageMetadata msgMetadata) { EncryptionContext encryptionCtx = null; if (msgMetadata.getEncryptionKeysCount()...
3.26
pulsar_ConsumerImpl_notifyPendingReceivedCallback_rdh
/** * Notify waiting asyncReceive request with the received message. * * @param message */void notifyPendingReceivedCallback(final Message<T> message, Exception exception) { if (pendingReceives.isEmpty()) { return; } // fetch receivedCallback from queue final CompletableFuture<Message<T>> receivedFuture = nextPendi...
3.26
pulsar_ConsumerImpl_m1_rdh
/** * Record the event that one message has been processed by the application. * * Periodically, it sends a Flow command to notify the broker that it can push more messages */ @Override protected synchronized void m1(Message<?> msg) { ClientCnx currentCnx = cnx(); ClientCnx msgCnx = ((MessageImpl<?>) (msg)).getCnx(...
3.26
pulsar_ConsumerImpl_releasePooledMessagesAndStopAcceptNew_rdh
/** * If enabled pooled messages, we should release the messages after closing consumer and stop accept the new * messages. */ private void releasePooledMessagesAndStopAcceptNew() { incomingMessages.terminate(message -> message.release()); clearIncomingMessages(); }
3.26
pulsar_ConsumerImpl_m0_rdh
/** * Clear the internal receiver queue and returns the message id of what was the 1st message in the queue that was * not seen by the application. */ private MessageIdAdv m0() { List<Message<?>> currentMessageQueue = new ArrayList<>(incomingMessages.size()); incomingMessages.drainTo(currentMessageQueue);resetIncomi...
3.26
pulsar_ConsumerImpl_cnx_rdh
// wrapper for connection methods ClientCnx cnx() { return this.connectionHandler.cnx(); }
3.26
pulsar_SecurityUtility_getBCProviderFromClassPath_rdh
/** * Get Bouncy Castle provider from classpath, and call Security.addProvider. * Throw Exception if failed. */ public static Provider getBCProviderFromClassPath() throws Exception { Class clazz; try { // prefer non FIPS, for backward compatibility concern. clazz = Class.forName(BC_NON_FI...
3.26
pulsar_SecurityUtility_processConscryptTrustManager_rdh
// workaround https://github.com/google/conscrypt/issues/1015 private static void processConscryptTrustManager(TrustManager trustManager) { if (trustManager.getClass().getName().equals("org.conscrypt.TrustManagerImpl")) { try { Class<?> conscryptClazz = Class.forName("org.conscrypt.Conscrypt"); ...
3.26
pulsar_SecurityUtility_getProvider_rdh
/** * Get Bouncy Castle provider, and call Security.addProvider(provider) if success. * 1. try get from classpath. * 2. try get from Nar. */ public static Provider getProvider() { boolean isProviderInstalled = (Security.getProvider(BC) != null) || (Security.getProvider(BC_FIPS) != null);if (isProviderIn...
3.26
pulsar_PerfClientUtils_printJVMInformation_rdh
/** * Print useful JVM information, you need this information in order to be able * to compare the results of executions in different environments. * * @param log */ public static void printJVMInformation(Logger log) { log.info("JVM args {}", ManagementFactory.getRuntimeMXBean().getInputArguments()); log.i...
3.26
pulsar_PackagesStorageProvider_newProvider_rdh
/** * Construct a provider from the provided class. * * @param providerClassName * the provider class name * @return an instance of package storage provider * @throws IOException */ static PackagesStorageProvider newProvider(String providerClassName) throws IOException { Class<?> providerClass; try { provi...
3.26
pulsar_ManagedLedgerMetrics_groupLedgersByDimension_rdh
/** * Build a map of dimensions key to list of topic stats (not thread-safe). * <p> * * @return */ private Map<Metrics, List<ManagedLedgerImpl>> groupLedgersByDimension() { ledgersByDimensionMap.clear(); // get the current topics statistics from StatsBrokerFilter // Map : topic-name->dest-stat for (Ent...
3.26
pulsar_ManagedLedgerMetrics_aggregate_rdh
/** * Aggregation by namespace (not thread-safe). * * @param ledgersByDimension * @return */ private List<Metrics> aggregate(Map<Metrics, List<ManagedLedgerImpl>> ledgersByDimension) { metricsCollection.clear(); for (Entry<Metrics, List<ManagedLedgerImpl>> e : ledgersByDimension.entrySet()) { Met...
3.26
pulsar_BlobStoreBackedReadHandleImpl_getState_rdh
// for testing State getState() { return this.state; }
3.26
pulsar_KubernetesServiceAccountTokenAuthProvider_cleanUpAuthData_rdh
/** * No need to clean up anything. Kubernetes cleans up the secret when the pod is deleted. */ @Override public void cleanUpAuthData(Function.FunctionDetails funcDetails, Optional<FunctionAuthData> functionAuthData) throws Exception { }
3.26
pulsar_KubernetesServiceAccountTokenAuthProvider_updateAuthData_rdh
/** * No need to update anything. Kubernetes updates the token used for authentication. */ @Override public Optional<FunctionAuthData> updateAuthData(Function.FunctionDetails funcDetails, Optional<FunctionAuthData> existingFunctionAuthData, AuthenticationDataSource authenticationDataSource) throws Exception { re...
3.26
pulsar_KubernetesServiceAccountTokenAuthProvider_cacheAuthData_rdh
/** * No need to cache anything. Kubernetes generates the token used for authentication. */ @Override public Optional<FunctionAuthData> cacheAuthData(Function.FunctionDetails funcDetails, AuthenticationDataSource authenticationDataSource) throws Exception { return Optional.empty(); }
3.26
pulsar_ConcurrentLongPairSet_remove_rdh
/** * Remove an existing entry if found. * * @param item1 * @return true if removed or false if item was not present */ public boolean remove(long item1, long item2) { checkBiggerEqualZero(item1); long h = hash(item1, item2); return getSection(h).remove(item1, item2, ((int) (h))); }
3.26
pulsar_ConcurrentLongPairSet_items_rdh
/** * * @return a new list of keys with max provided numberOfItems (makes a copy) */ public Set<LongPair> items(int numberOfItems) { return items(numberOfItems, (item1, item2) -> new LongPair(item1, item2)); }
3.26
pulsar_ConcurrentLongPairSet_forEach_rdh
/** * Iterate over all the elements in the set and apply the provided function. * <p> * <b>Warning: Do Not Guarantee Thread-Safety.</b> * * @param processor * the processor to process the elements */ public void forEach(LongPairConsumer processor) { for (int v16 = 0; v16 < s...
3.26
pulsar_PulsarZooKeeperClient_getSessionId_rdh
// inherits from ZooKeeper client for all operations @Override public long getSessionId() { ZooKeeper zkHandle = zk.get();if (null == zkHandle) { return super.getSessionId(); } return zkHandle.getSessionId(); }
3.26
pulsar_PulsarZooKeeperClient_isRecoverableException_rdh
/** * Check whether the given exception is recoverable by retry. * * @param exception * given exception * @return true if given exception is recoverable. */ public static boolean isRecoverableException(KeeperException exception) { return isRecoverableException(exception.code().intValue()); }
3.26
pulsar_PulsarZooKeeperClient_syncCallWithRetries_rdh
/** * Execute a sync zookeeper operation with a given retry policy. * * @param client * ZooKeeper client. * @param proc * Synchronous zookeeper operation wrapped in a {@link Callable}. * @param retryPolicy * Retry policy to execute the synchronous operation. * @param rateLimiter * Rate limiter for zoo...
3.26
pulsar_UniformLoadShedder_findBundlesForUnloading_rdh
/** * Attempt to shed some bundles off every broker which is overloaded. * * @param loadData * The load data to used to make the unloading decision. * @param conf * The service configuration. * @return A map from bundles to unload to the brokers on which they are loaded. ...
3.26
pulsar_ConnectionPool_getConnection_rdh
/** * Get a connection from the pool. * <p> * The connection can either be created or be coming from the pool itself. * <p> * When specifying multiple addresses, the logicalAddress is used as a tag for the broker, while the physicalAddress * is where the connection is actually happening. * <p> * These two addre...
3.26
pulsar_ConnectionPool_createConnection_rdh
/** * Resolve DNS asynchronously and attempt to connect to any IP address returned by DNS server. */ private CompletableFuture<Channel> createConnection(InetSocketAddress logicalAddress, InetSocketAddress unresolvedPhysicalAddress) { CompletableFuture<List<InetSocketAddress>> resolvedAddress; try { if...
3.26
pulsar_ConnectionPool_connectToAddress_rdh
/** * Attempt to establish a TCP connection to an already resolved single IP address. */ private CompletableFuture<Channel> connectToAddress(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress, InetSocketAddress unresolvedPhysicalAddress, InetSocketAddress sniHost) { if (clientConfig.isUseTls()) {...
3.26
pulsar_AbstractSchema_m0_rdh
/** * Decode a byteBuf into an object using a given version. * * @param byteBuf * the byte array to decode * @param schemaVersion * the schema version to decode the object. null indicates using latest version. * @return the deserialized object */ public T m0(ByteBuf byteBuf, byte[] schemaVersion) { // i...
3.26
pulsar_AbstractSchema_atSchemaVersion_rdh
/** * Return an instance of this schema at the given version. * * @param schemaVersion * the version * @return the schema at that specific version * @throws SchemaSerializationException * in case of unknown schema version * @throws NullPointerException * in case of...
3.26
pulsar_AbstractSchema_validate_rdh
/** * Check if the message read able length length is a valid object for this schema. * * <p>The implementation can choose what its most efficient approach to validate the schema. * If the implementation doesn't provide it, it will attempt to use {@link #decode(ByteBuf)} * to see if this schema can decode this mes...
3.26
pulsar_AuthenticationProviderOpenID_validateAllowedAudiences_rdh
/** * Validate the configured allow list of allowedAudiences. The allowedAudiences must be set because * JWT must have an audience claim. * See https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation. * * @param allowedAudiences * @return the validated audiences */ String[] validateAllowedAudien...
3.26
pulsar_AuthenticationProviderOpenID_verifyJWT_rdh
/** * Build and return a validator for the parameters. * * @param publicKey * - the public key to use when configuring the validator * @param publicKeyAlg * - the algorithm for the parameterized public key * @param jwt * - jwt to be v...
3.26
pulsar_AuthenticationProviderOpenID_getRole_rdh
/** * Get the role from a JWT at the configured role claim field. * NOTE: does not do any verification of the JWT * * @param jwt * - token to get the role from * @return the role, or null, if it is not set on the JWT */ String getRole(DecodedJWT jwt) { try { Claim roleClaim = jwt.getClaim(this.role...
3.26
pulsar_AuthenticationProviderOpenID_verifyIssuerAndGetJwk_rdh
/** * Verify the JWT's issuer (iss) claim is one of the allowed issuers and then retrieve the JWK from the issuer. If * not, see {@link FallbackDiscoveryMode} for the fallback behavior. * * @param jwt * - the token to use to discover the issuer's JWKS URI, which is then used to retrieve the issuer's * current...
3.26
pulsar_AuthenticationProviderOpenID_authenticateTokenAsync_rdh
/** * Authenticate the parameterized {@link AuthenticationDataSource} and return the decoded JWT. * * @param authData * - the authData containing the token. * @return a completed future with the decoded JWT, if the JWT is authenticated. Otherwise, a failed future. */ CompletableFuture<DecodedJWT> authenticateTo...
3.26
pulsar_AuthenticationProviderOpenID_decodeJWT_rdh
/** * Convert a JWT string into a {@link DecodedJWT} * The benefit of using this method is that it utilizes the already instantiated {@link JWT} parser. * WARNING: this method does not verify the authenticity of the token. It only decodes it. * ...
3.26
pulsar_AuthenticationProviderOpenID_authenticateAsync_rdh
/** * Authenticate the parameterized {@link AuthenticationDataSource} by verifying the issuer is an allowed issuer, * then retrieving the JWKS URI from the issuer, then retrieving the Public key from the JWKS URI, and finally * verifying the JWT signature and claims. * * @param authData * - the authData passed ...
3.26
pulsar_AuthenticationProviderOpenID_validateIssuers_rdh
/** * Validate the configured allow list of allowedIssuers. The allowedIssuers set must be nonempty in order for * the plugin to authenticate any token. Thus, it fails initialization if the configuration is * missing. Each issuer URL should use the HTTPS scheme. The plugin fails initialization if any * issuer url i...
3.26
pulsar_AuthenticationProviderOpenID_authenticateToken_rdh
/** * Authenticate the parameterized JWT. * * @param token * - a nonnull JWT to authenticate * @return a fully authenticated JWT, or AuthenticationException if the JWT is proven to be invalid in any way */ private CompletableFuture<DecodedJWT> authenticateToken(String token) { if (token == null) { i...
3.26
pulsar_ManagedLedgerInterceptor_processPayloadBeforeEntryCache_rdh
/** * Intercept after entry is read from ledger, before it gets cached. * * @param dataReadFromLedger * data from ledger * @return handle to the processor */ default PayloadProcessorHandle processPayloadBeforeEntryCache(ByteBuf dataReadFromLedger) { return null; }
3.26
pulsar_ManagedLedgerInterceptor_processPayloadBeforeLedgerWrite_rdh
/** * Intercept before payload gets written to ledger. * * @param ledgerWriteOp * OpAddEntry used to trigger ledger write. * @param dataToBeStoredInLedger * data to be stored in ledger * @return handle to the processor */ default PayloadProcessorHandle processPayloadBeforeLedgerWrite(OpAddEntry ledgerWriteO...
3.26
pulsar_ManagedLedgerInterceptor_afterFailedAddEntry_rdh
/** * Intercept When add entry failed. * * @param numberOfMessages */ default void afterFailedAddEntry(int numberOfMessages) { }
3.26
pulsar_SSLContextValidatorEngine_validate_rdh
/** * Validates TLS handshake up to TLSv1.2. * TLSv1.3 has a differences in TLS handshake as described in https://stackoverflow.com/a/62465859 */ public static void validate(SSLEngineProvider clientSslEngineSupplier, SSLEngineProvider serverSslEngineSupplier) throws SSLException { SSLContextValidatorEngine clientE...
3.26
pulsar_SSLContextValidatorEngine_ensureCapacity_rdh
/** * Check if the given ByteBuffer capacity. * * @param existingBuffer * ByteBuffer capacity to check * @param newLength * new length for the ByteBuffer. * returns ByteBuffer */ public static ByteBuffer ensureCapacity(ByteBuffer existingBuffer, int newLength) { if (newLength > existingBuffer.capacity...
3.26
pulsar_SinkSchemaInfoProvider_addSchemaIfNeeded_rdh
/** * Creates a new schema version with the info of the provided schema if the hash of the schema is a new one. * * @param schema * schema for which we create a version * @return the version of the schema */ public SchemaVersion addSchemaIfNeeded(Schema<?> schema) { SchemaHash schemaHash = SchemaHash.of(sc...
3.26
pulsar_NonPersistentTopicStatsImpl_add_rdh
// if the stats are added for the 1st time, we will need to make a copy of these stats and add it to the current // stats. This stat addition is not thread-safe. public NonPersistentTopicStatsImpl add(NonPersistentTopicStats ts) { NonPersistentTopicStatsImpl stats = ((NonPersistentTopicStatsImpl) (ts)); Objects...
3.26
pulsar_WebSocketWebResource_validateUserAccess_rdh
/** * Checks if user has super-user access or user is authorized to produce/consume on a given topic. * * @param topic * @throws RestException */ protected void validateUserAccess(TopicName topic) { boolean isAuthorized = false; try { validateSuperUserAccess();isAuthorized = true; } catch ...
3.26
pulsar_WebSocketWebResource_isAuthorized_rdh
/** * Checks if user is authorized to produce/consume on a given topic. * * @param topic * @return * @throws Exception */ protected boolean isAuthorized(TopicName topic) throws Exception { if (service().isAuthorizationEnabled()) { return service().getAuthorizationService().canLookup(topic, clientAppId...
3.26
pulsar_WebSocketWebResource_clientAppId_rdh
/** * Gets a caller id (IP + role). * * @return the web service caller identification */ public String clientAppId() { if (isBlank(clientId)) { try { String authMethodName = httpRequest.getHeader(AuthenticationFilter.PULSAR_AUTH_METHOD_NAME); if ((authMethodName != null) &...
3.26
pulsar_WebSocketWebResource_validateSuperUserAccess_rdh
/** * Checks whether the user has Pulsar Super-User access to the system. * * @throws RestException * if not authorized */ protected void validateSuperUserAccess() { if (service().getConfig().isAuthenticationEnabled()) { String appId = clientAppId(); if (log.isDebugEnabled()) { lo...
3.26
pulsar_BundleData_update_rdh
/** * Update the historical data for this bundle. * * @param newSample * The bundle stats to update this data with. */ public void update(final NamespaceBundleStats newSample) { shortTermData.update(newSample); longTermData.update(newSample); this.topics = ((int) (newSample.topics)); }
3.26
pulsar_ConfigUtils_getConfigValueAsBoolean_rdh
/** * Utility method to get a boolean from the {@link ServiceConfiguration}. If the key is present in the conf, * return the default value. If key is present the value is not a valid boolean, the result will be false. * * @param conf * - the map of configuration properties * @param configProp * - the propert...
3.26
pulsar_ConfigUtils_m0_rdh
/** * Get configured property as a string. If not configured, return null. * * @param conf * - the configuration map * @param configProp * - the property to get * @param defaultValue * - the value to use if the configuration value is not set * @return a string from the conf or the default value */ stati...
3.26
pulsar_ConfigUtils_getConfigValueAsSet_rdh
/** * Get configured property as a set. Split using a comma delimiter and remove any extra whitespace surrounding * the commas. If not configured, return the empty set. * * @param conf * - the map of configuration properties * @param configProp * - the property (key) to get * @return a set of strings from t...
3.26
pulsar_ConfigUtils_getConfigValueAsString_rdh
/** * Get configured property as a string. If not configured, return null. * * @param conf * - the configuration map * @param configProp * - the property to get * @return a string from the conf or null, if the configuration property was not set */ static String getConfigValueAsString(ServiceConfiguration co...
3.26
pulsar_ClassLoaderUtils_loadJar_rdh
/** * Helper methods wrt Classloading. */ @Slf4jpublic class ClassLoaderUtils { /** * Load a jar. * * @param jar * file of jar * @return classloader * @throws MalformedURLException */ public static ClassLoader loadJar(File jar) throws MalformedURLException { URL v0...
3.26
pulsar_ConfigValidationUtils_listFv_rdh
/** * Returns a new NestableFieldValidator for a List where each item is validated by validator. * * @param validator * used to validate each item in the list * @param notNull * whether or not a value of null is valid * @return a NestableFieldValidator for a list with each ite...
3.26
pulsar_ConfigValidationUtils_fv_rdh
/** * Returns a new NestableFieldValidator for a given class. * * @param cls * the Class the field should be a type of * @param notNull * whether or not a value of null is valid * @return a NestableFieldValidator for that class */ public static NestableFieldValidator fv(final Class cls, final boolean notNu...
3.26
pulsar_ConfigValidationUtils_mapFv_rdh
/** * Returns a new NestableFieldValidator for a Map. * * @param key * a validator for the keys in the map * @param val * a validator for the values in the map * @param notNull * whether or not a value of null is valid * @return a NestableFieldValidator for a Map */ public static NestableFieldValidator ...
3.26
pulsar_ObjectMapperFactory_clearCaches_rdh
/** * Clears the caches tied to the ObjectMapper instances and replaces the singleton ObjectMapper instance. * * This can be used in tests to ensure that classloaders and class references don't leak across tests. */public static void clearCaches() { clearTypeFactoryCache(getMapper().getObjectMapper()); clea...
3.26
pulsar_ObjectMapperFactory_m1_rdh
/** * This method is deprecated. Use {@link #getYamlMapper()} and {@link MapperReference#getObjectMapper()} */ @Deprecated public static ObjectMapper m1() { return getYamlMapper().getObjectMapper();}
3.26
pulsar_ObjectMapperFactory_getThreadLocal_rdh
/** * This method is deprecated. Use {@link #getMapper()} and {@link MapperReference#getObjectMapper()} */ @Deprecated public static ObjectMapper getThreadLocal() { return getMapper().getObjectMapper(); }
3.26
pulsar_PrecisePublishLimiter_tryReleaseConnectionThrottle_rdh
// If all rate limiters are not exceeded, re-enable auto read from socket. private void tryReleaseConnectionThrottle() { RateLimiter currentTopicPublishRateLimiterOnMessage = topicPublishRateLimiterOnMessage; RateLimiter currentTopicPublishRateLimiterOnByte = topicPublishRateLimiterOnByte; if (((currentTopicPublishRa...
3.26
pulsar_ResourceGroupService_updateStatsWithDiff_rdh
// Find the difference between the last time stats were updated for this topic, and the current // time. If the difference is positive, update the stats. private void updateStatsWithDiff(String topicName, String tenantString, String nsString, long accByteCount, long accMesgCount, ResourceGroupMonitoringClass monClass) ...
3.26
pulsar_ResourceGroupService_getNumResourceGroups_rdh
/** * Get the current number of RGs. For testing. */ protected long getNumResourceGroups() { return resourceGroupsMap.mappingCount(); }
3.26
pulsar_ResourceGroupService_getRgNamespaceRegistersCount_rdh
// Visibility for testing. protected static double getRgNamespaceRegistersCount(String rgName) { return rgNamespaceRegisters.labels(rgName).get(); }
3.26
pulsar_ResourceGroupService_getNamespaceResourceGroup_rdh
/** * Return the resource group associated with a namespace. * * @param namespaceName * @throws if * the RG does not exist, or if the NS already references the RG. */ public ResourceGroup getNamespaceResourceGroup(NamespaceName namespaceName) { return this.namespaceToRGsMap.get(namespaceName); }
3.26
pulsar_ResourceGroupService_getRgQuotaMessageCount_rdh
// Visibility for testing. protected static double getRgQuotaMessageCount(String rgName, String monClassName) { return rgCalculatedQuotaMessages.labels(rgName, monClassName).get(); }
3.26
pulsar_ResourceGroupService_registerNameSpace_rdh
/** * Registers a namespace as a user of a resource group. * * @param resourceGroupName * @param fqNamespaceName * (i.e., in "tenant/Namespace" format) * @throws if * the RG does not exist, or if the NS already references the RG. */public void registerNameSpace(String resourceGroupName, NamespaceName fqName...
3.26