This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 51ecd0235ce [cleanup][broker] Remove unused NamespaceBundleFactory
parameter when creating OwnershipCache (#22482)
51ecd0235ce is described below
commit 51ecd0235ce5d5ad03c563a3338b29c6a117d216
Author: Yunze Xu <[email protected]>
AuthorDate: Sat Apr 13 08:58:53 2024 +0800
[cleanup][broker] Remove unused NamespaceBundleFactory parameter when
creating OwnershipCache (#22482)
---
.../pulsar/broker/namespace/NamespaceService.java | 2 +-
.../pulsar/broker/namespace/OwnershipCache.java | 4 +---
.../pulsar/broker/namespace/OwnershipCacheTest.java | 19 ++++++++-----------
3 files changed, 10 insertions(+), 15 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
index 4492f9c8094..7c62f264c78 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
@@ -192,7 +192,7 @@ public class NamespaceService implements AutoCloseable {
this.config = pulsar.getConfiguration();
this.loadManager = pulsar.getLoadManager();
this.bundleFactory = new NamespaceBundleFactory(pulsar,
Hashing.crc32());
- this.ownershipCache = new OwnershipCache(pulsar, bundleFactory, this);
+ this.ownershipCache = new OwnershipCache(pulsar, this);
this.namespaceClients =
ConcurrentOpenHashMap.<ClusterDataImpl,
PulsarClientImpl>newBuilder().build();
this.bundleOwnershipListeners = new CopyOnWriteArrayList<>();
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
index 0033abf36c7..9a4534f5387 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
@@ -36,7 +36,6 @@ import java.util.concurrent.TimeoutException;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.common.naming.NamespaceBundle;
-import org.apache.pulsar.common.naming.NamespaceBundleFactory;
import org.apache.pulsar.common.naming.NamespaceBundles;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.metadata.api.coordination.LockManager;
@@ -115,8 +114,7 @@ public class OwnershipCache {
*
* the local broker URL that will be set as owner for the
<code>ServiceUnit</code>
*/
- public OwnershipCache(PulsarService pulsar, NamespaceBundleFactory
bundleFactory,
- NamespaceService namespaceService) {
+ public OwnershipCache(PulsarService pulsar, NamespaceService
namespaceService) {
this.namespaceService = namespaceService;
this.pulsar = pulsar;
this.ownerBrokerUrl = pulsar.getBrokerServiceUrl();
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/OwnershipCacheTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/OwnershipCacheTest.java
index c92127457aa..2c3182659f0 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/OwnershipCacheTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/OwnershipCacheTest.java
@@ -55,15 +55,12 @@ import
org.apache.pulsar.metadata.api.extended.MetadataStoreExtended;
import org.apache.pulsar.metadata.coordination.impl.CoordinationServiceImpl;
import org.apache.pulsar.zookeeper.ZookeeperServerTest;
import org.awaitility.Awaitility;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups = "broker")
public class OwnershipCacheTest {
- private static final Logger log =
LoggerFactory.getLogger(OwnershipCacheTest.class);
private PulsarService pulsar;
private ServiceConfiguration config;
@@ -123,14 +120,14 @@ public class OwnershipCacheTest {
@Test
public void testConstructor() {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
assertNotNull(cache);
assertNotNull(cache.getOwnedBundles());
}
@Test
public void testDisableOwnership() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceBundle testBundle = new
NamespaceBundle(NamespaceName.get("pulsar/test/ns-1"),
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
@@ -148,7 +145,7 @@ public class OwnershipCacheTest {
@Test
public void testGetOrSetOwner() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceBundle testFullBundle = new
NamespaceBundle(NamespaceName.get("pulsar/test/ns-2"),
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
bundleFactory);
@@ -194,7 +191,7 @@ public class OwnershipCacheTest {
@Test
public void testGetOwner() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceBundle testBundle = new
NamespaceBundle(NamespaceName.get("pulsar/test/ns-3"),
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
bundleFactory);
@@ -241,7 +238,7 @@ public class OwnershipCacheTest {
@Test
public void testGetOwnedServiceUnit() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceName testNs = NamespaceName.get("pulsar/test/ns-5");
NamespaceBundle testBundle = new NamespaceBundle(testNs,
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
@@ -301,7 +298,7 @@ public class OwnershipCacheTest {
@Test
public void testGetOwnedServiceUnits() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceName testNs = NamespaceName.get("pulsar/test/ns-6");
NamespaceBundle testBundle = new NamespaceBundle(testNs,
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
@@ -347,7 +344,7 @@ public class OwnershipCacheTest {
@Test
public void testRemoveOwnership() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceName testNs = NamespaceName.get("pulsar/test/ns-7");
NamespaceBundle bundle = new NamespaceBundle(testNs,
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
@@ -373,7 +370,7 @@ public class OwnershipCacheTest {
@Test
public void testReestablishOwnership() throws Exception {
- OwnershipCache cache = new OwnershipCache(this.pulsar, bundleFactory,
nsService);
+ OwnershipCache cache = new OwnershipCache(this.pulsar, nsService);
NamespaceBundle testFullBundle = new
NamespaceBundle(NamespaceName.get("pulsar/test/ns-8"),
Range.closedOpen(0L, (long) Integer.MAX_VALUE),
bundleFactory);