Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close the RegistrationManager in the finally block in AuditorPlacementPolicyCheckTest. #4080

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ public void testPlacementPolicyCheckWithBookiesFromDifferentRacks() throws Excep
int numOfBookies = 5;
List<BookieId> bookieAddresses = new ArrayList<>();
BookieSocketAddress bookieAddress;
try (RegistrationManager regManager = driver.createRegistrationManager()) {
// all the numOfBookies (5) are going to be in different racks
for (int i = 0; i < numOfBookies; i++) {
bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181);
StaticDNSResolver.addNodeToRack(bookieAddress.getHostName(), "/rack" + (i));
bookieAddresses.add(bookieAddress.toBookieId());
regManager.registerBookie(bookieAddress.toBookieId(), false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
// all the numOfBookies (5) are going to be in different racks
for (int i = 0; i < numOfBookies; i++) {
bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181);
StaticDNSResolver.addNodeToRack(bookieAddress.getHostName(), "/rack" + (i));
bookieAddresses.add(bookieAddress.toBookieId());
regManager.registerBookie(bookieAddress.toBookieId(), false, BookieServiceInfo.EMPTY);
}

LedgerManagerFactory mFactory = driver.getLedgerManagerFactory();
Expand Down Expand Up @@ -208,6 +207,7 @@ public void testPlacementPolicyCheckWithBookiesFromDifferentRacks() throws Excep
if (auditor != null) {
auditor.close();
}
regManager.close();
}
}

Expand All @@ -216,12 +216,11 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPlacementPolicy() th
int numOfBookies = 5;
int numOfLedgersNotAdheringToPlacementPolicy = 0;
List<BookieId> bookieAddresses = new ArrayList<>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}

// only three racks
Expand Down Expand Up @@ -291,6 +290,7 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPlacementPolicy() th
if (auditor != null) {
auditor.close();
}
regManager.close();
}
}

Expand All @@ -300,12 +300,11 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPlacementPolicyAndNo
int numOfBookies = 5;
int numOfLedgersNotAdheringToPlacementPolicy = 0;
List<BookieId> bookieAddresses = new ArrayList<>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}

// only three racks
Expand Down Expand Up @@ -372,12 +371,11 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPlacementPolicyAndMa
int numOfBookies = 5;
int numOfLedgersNotAdheringToPlacementPolicy = 0;
List<BookieId> bookieAddresses = new ArrayList<>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}

// only three racks
Expand Down Expand Up @@ -433,6 +431,7 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPlacementPolicyAndMa
if (auditor != null) {
auditor.close();
}
regManager.close();
}
LedgerUnderreplicationManager underreplicationManager = mFactory.newLedgerUnderreplicationManager();
long unnderReplicateLedgerId = underreplicationManager.pollLedgerToRereplicate();
Expand All @@ -458,12 +457,11 @@ public void testPlacementPolicyCheckWithURLedgers(boolean timeElapsed) throws Ex
int underreplicatedLedgerRecoveryGracePeriod = timeElapsed ? 1 : 1000;
int numOfURLedgersElapsedRecoveryGracePeriod = 0;
List<BookieId> bookieAddresses = new ArrayList<BookieId>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}

LedgerManagerFactory mFactory = driver.getLedgerManagerFactory();
Expand Down Expand Up @@ -569,6 +567,7 @@ public void testPlacementPolicyCheckWithURLedgers(boolean timeElapsed) throws Ex
if (auditor != null) {
auditor.close();
}
regManager.close();
}
}

Expand All @@ -577,12 +576,11 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPolicyWithMultipleSe
int numOfBookies = 7;
int numOfLedgersNotAdheringToPlacementPolicy = 0;
List<BookieId> bookieAddresses = new ArrayList<>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}
RegistrationManager regManager = driver.createRegistrationManager();
for (int i = 0; i < numOfBookies; i++) {
BookieId bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181).toBookieId();
bookieAddresses.add(bookieAddress);
regManager.registerBookie(bookieAddress, false, BookieServiceInfo.EMPTY);
}

// only three racks
Expand Down Expand Up @@ -673,6 +671,7 @@ public void testPlacementPolicyCheckWithLedgersNotAdheringToPolicyWithMultipleSe
if (auditor != null) {
auditor.close();
}
regManager.close();
}
}

Expand All @@ -682,19 +681,18 @@ public void testZoneawarePlacementPolicyCheck() throws Exception {
int numOfLedgersNotAdheringToPlacementPolicy = 0;
int numOfLedgersSoftlyAdheringToPlacementPolicy = 0;
List<BookieId> bookieAddresses = new ArrayList<BookieId>();
try (RegistrationManager regManager = driver.createRegistrationManager()) {
/*
* 6 bookies - 3 zones and 2 uds
*/
for (int i = 0; i < numOfBookies; i++) {
BookieSocketAddress bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181);
bookieAddresses.add(bookieAddress.toBookieId());
regManager.registerBookie(bookieAddress.toBookieId(), false, BookieServiceInfo.EMPTY);
String zone = "/zone" + (i % 3);
String upgradeDomain = "/ud" + (i % 2);
String networkLocation = zone + upgradeDomain;
StaticDNSResolver.addNodeToRack(bookieAddress.getHostName(), networkLocation);
}
RegistrationManager regManager = driver.createRegistrationManager();
/*
* 6 bookies - 3 zones and 2 uds
*/
for (int i = 0; i < numOfBookies; i++) {
BookieSocketAddress bookieAddress = new BookieSocketAddress("98.98.98." + i, 2181);
bookieAddresses.add(bookieAddress.toBookieId());
regManager.registerBookie(bookieAddress.toBookieId(), false, BookieServiceInfo.EMPTY);
String zone = "/zone" + (i % 3);
String upgradeDomain = "/ud" + (i % 2);
String networkLocation = zone + upgradeDomain;
StaticDNSResolver.addNodeToRack(bookieAddress.getHostName(), networkLocation);
}

LedgerManagerFactory mFactory = driver.getLedgerManagerFactory();
Expand Down Expand Up @@ -800,6 +798,7 @@ public void testZoneawarePlacementPolicyCheck() throws Exception {
if (auditor != null) {
auditor.close();
}
regManager.close();
}
}

Expand Down
Loading