Skip to content

Commit

Permalink
renames name ids to membership vector
Browse files Browse the repository at this point in the history
  • Loading branch information
yhassanzadeh13 committed Sep 4, 2023
1 parent e07c642 commit 1923a0e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/main/java/skipnode/SkipNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ public boolean unlock(SkipNodeIdentity owner) {
public boolean isAvailable() {
return inserted && !insertionLock.isLocked();
}

/**
* Finds the `ladder`, i.e. the node that should be used to propagate a newly joined node to the
* upper layer. Only used by the insertion protocol, and not by the membership vector search protocol even
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/skipnode/SkipNodeIdentity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@ public SkipNodeIdentity(Identifier identifier, MembershipVector membershipVector
this.port = port;
}

/**
* Method that calculates common bits for 2 name ids.
*
* @param name1 String representing name id.
* @param name2 String representing name id.
* @return number of common bits.
*/
@Deprecated
public static int commonBits(String name1, String name2) {
if (name1 == null || name2 == null) {
return -1;
}
if (name1.length() != name2.length()) {
return -1;
}
int i = 0;
while (i < name1.length() && name1.charAt(i) == name2.charAt(i)) {
i++;
}
return i;
}

public MembershipVector getMemVec() {
return membershipVector;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/skipnode/SkipNodeInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public interface SkipNodeInterface {
SearchResult searchByMembershipVector(MembershipVector nameId);

/**
* Used by the `searchByNameID` method. Implements a recursive name ID search algorithm.
* Used by the `searchByMembershipVector` method. Implements a recursive search by membership vector algorithm.
*
* @param target the target name ID.
* @param target the target membership vector.
* @param level the current level.
* @return the identity of the node with the given name ID, or the node with the closest name ID.
* @return the identity of the node with the given membership vector, or the node with the closest membership vector.
*/
SearchResult searchByMembershipVector(MembershipVector target, int level);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import underlay.packets.RequestType;

/**
* Request for searching by name id recursively.
* Request for searching by membership vector recursively.
*/
public class SearchByMembershipVectorRecursiveRequest extends Request {

Expand All @@ -15,7 +15,7 @@ public class SearchByMembershipVectorRecursiveRequest extends Request {
/**
* Constructor for SearchByNameIdRecursiveRequest.
*
* @param target name id of the target node.
* @param target membership vector of the target node.
* @param level Integer representing the level.
*/
public SearchByMembershipVectorRecursiveRequest(MembershipVector target, int level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import underlay.packets.RequestType;

/**
* Request for searching by name id.
* Request for searching by membership vector.
*/
public class SearchByMembershipVectorRequest extends Request {

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/underlay/UnderlayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void sendMessage() {
String remoteAddress = remoteUnderlay.getAddress();
int remotePort = remoteUnderlay.getPort();

// Check search by name ID request.
// Check search by membership vector request.
Assertions.assertNotNull(
localUnderlay.sendMessage(remoteAddress, remotePort, new SearchByMembershipVectorRequest(MembershipVectorFixture.newMembershipVector())));
// Check search by numerical ID request.
Expand Down

0 comments on commit 1923a0e

Please sign in to comment.