@PublicEvolving public final class TopicRangeUtils extends Object
Range
, used in Key Shared mode. It will be exposed
to the end users for simplifying the implementation of the RangeGenerator
.Modifier and Type | Field and Description |
---|---|
static String |
NONE_KEY
Pulsar would use this as default key if no key was provided.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isFullTopicRanges(List<TopicRange> ranges)
Check if the given topic ranges are full Pulsar range.
|
static int |
keyBytesHash(byte[] keyBytes)
This method is a bit of different compared to the
keyHash(byte[]) . |
static int |
keyHash(byte[] keyBytes)
Pulsar didn't expose the key hash range method.
|
static int |
keyHash(String key)
Pulsar didn't expose the key hash range method.
|
static void |
validateTopicRanges(List<TopicRange> ranges,
RangeGenerator.KeySharedMode sharedMode)
Make sure all the ranges should be valid in Pulsar Key Shared Policy.
|
public static final String NONE_KEY
public static void validateTopicRanges(List<TopicRange> ranges, RangeGenerator.KeySharedMode sharedMode)
public static boolean isFullTopicRanges(List<TopicRange> ranges)
public static int keyHash(String key)
key
- The key of Pulsar's Message
. Pulsar would try to use Message.getOrderingKey()
first. If it doesn't exist Pulsar will use Message.getKey()
instead. Remember that the Message.getOrderingKey()
could be
configured by PulsarMessageBuilder.orderingKey(byte[])
and the Message.getKey()
could be configured by PulsarMessageBuilder.key(String)
.public static int keyBytesHash(byte[] keyBytes)
keyHash(byte[])
. We only define
this method when you set the message key by using TypedMessageBuilder.keyBytes(byte[])
. Because the Pulsar would calculate the message key
hash in a different way.
It should be a bug on Pulsar, but we can't fix it for backward compatibility.
public static int keyHash(byte[] keyBytes)
keyBytes
- The key bytes of Pulsar's Message
. Pulsar would try to use Message.getOrderingKey()
first. If it doesn't exist Pulsar will use Message.getKey()
instead. Remember that the Message.getOrderingKey()
could be
configured by PulsarMessageBuilder.orderingKey(byte[])
and the Message.getKey()
could be configured by PulsarMessageBuilder.key(String)
.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.