Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Filter out leaderPaxos from list of namespaces #4760

Merged
merged 11 commits into from
May 12, 2020

Conversation

sudiksha27
Copy link
Contributor

@sudiksha27 sudiksha27 commented May 11, 2020

Goals (and why):
leaderPaxos is not a namespace itself. It should be filtered out when loading namespaces from disk.

Implementation Description (bullets):
Filter out "leaderPaxos" while loading namespaces

Testing (What was existing testing like? What have you done to improve it?):
None

Concerns (what feedback would you like?):
None

Where should we start reviewing?:
DiskNamespaceLoader.java

Priority (whenever / two weeks / yesterday):
Anytime

@changelog-app
Copy link

changelog-app bot commented May 11, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

leaderPaxos will not be returned as a namespace. Previously, leaderPaxos was incorrectly considered as a namespace.

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏲️ 0:01

Change is correct, we should add tests.

Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change makes sense. I think there are some things in the test we could improve.

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();

private DiskNamespaceLoader diskNamespaceLoader;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I believe the Rule can be made final, and with that you can make this final and set it here as opposed to inside setup() (the test as written works, this is just general cleanliness).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DiskNamespaceLoader requires path to the tempFolder which is only available after the folder has been created. The only other option TemporaryFolder api gives is to provide the path of parent file. There is not a way to determine the path of the temp folder before it is created (which happens in the before block).

Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some cosmetic suggestions, but otherwise looks good.

private static final String NAMESPACE_2 = "namespace_2";


public final @Rule TemporaryFolder tempFolder = new TemporaryFolder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public final @Rule TemporaryFolder tempFolder = new TemporaryFolder();
@Rule
public final TemporaryFolder tempFolder = new TemporaryFolder();

This is fine also, just for consistency with the other tests.

private static final String NAMESPACE_1 = "namespace_1";
private static final String NAMESPACE_2 = "namespace_2";


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2 lines?


@Test
public void doesNotLoadLeaderPaxosAsNamespace() {
Set<String> namespaces = diskNamespaceLoader.getAllPersistedNamespaces().stream().map(client -> client.value()).collect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's use a method reference here (Client::value as opposed to x -> x.value())

}

private void createDirectoryForLeaderForEachClientUseCase(String namespace) {
if (Paths.get(tempFolder.getRoot().toPath().toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it's probably nicer to do tempFolder.getRoot().toPath().resolve(LEADER_PAXOS_NAMESPACE).resolve(...) which should behave in the same way

@sudiksha27 sudiksha27 merged commit dbf4235 into develop May 12, 2020
@delete-merged-branch delete-merged-branch bot deleted the namespace_loader_bug_fix branch May 12, 2020 11:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants