Skip to content

Commit

Permalink
[cleanup][broker] Remove unused NamespaceBundleFactory parameter when…
Browse files Browse the repository at this point in the history
… creating OwnershipCache (#22482)
  • Loading branch information
BewareMyPower authored Apr 13, 2024
1 parent 97153dc commit 51ecd02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public NamespaceService(PulsarService pulsar) {
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<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
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;
Expand Down Expand Up @@ -115,8 +114,7 @@ public CompletableFuture<OwnedBundle> asyncLoad(NamespaceBundle namespaceBundle,
*
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@
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;
Expand Down Expand Up @@ -123,14 +120,14 @@ public void teardown() throws Exception {

@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),
Expand All @@ -148,7 +145,7 @@ public void testDisableOwnership() throws Exception {

@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);
Expand Down Expand Up @@ -194,7 +191,7 @@ public void testGetOrSetOwner() throws Exception {

@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);
Expand Down Expand Up @@ -241,7 +238,7 @@ public void testGetOwner() throws Exception {

@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),
Expand Down Expand Up @@ -301,7 +298,7 @@ public void testGetOwnedServiceUnit() throws Exception {

@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),
Expand Down Expand Up @@ -347,7 +344,7 @@ public void testGetOwnedServiceUnits() throws Exception {

@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),
Expand All @@ -373,7 +370,7 @@ public void testRemoveOwnership() throws Exception {

@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);
Expand Down

0 comments on commit 51ecd02

Please sign in to comment.