Skip to content

Commit

Permalink
fixes sequential insertion test
Browse files Browse the repository at this point in the history
  • Loading branch information
thep2p committed Sep 2, 2023
1 parent 8bd2fd3 commit 82fe0ca
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/test/java/unittest/LocalSkipGraph.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package unittest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -35,8 +33,8 @@ public LocalSkipGraph(int size, String localAddress, int startingPort, boolean m
/**
* Constructor for LocalSkipGraph.
*
* @param size Integer representing the size.
* @param manualJoin Boolean representing if its manual join or not.
* @param size Integer representing the size.
* @param manualJoin Boolean representing if its manual join or not.
*/
public LocalSkipGraph(int size, boolean manualJoin) {
this.networkHub = new NetworkHub();
Expand All @@ -48,11 +46,11 @@ public LocalSkipGraph(int size, boolean manualJoin) {
Assertions.assertTrue(underlay.getPort() > 0);
underlays.add(underlay);
identities.add(
new SkipNodeIdentity(
IdentifierFixture.newIdentifier(),
MembershipVectorFixture.newMembershipVector(),
underlay.getAddress(),
underlay.getPort()));
new SkipNodeIdentity(
IdentifierFixture.newIdentifier(),
MembershipVectorFixture.newMembershipVector(),
underlay.getAddress(),
underlay.getPort()));
}
// Construct the lookup tables.
List<LookupTable> lookupTables = new ArrayList<>(size);
Expand All @@ -61,10 +59,6 @@ public LocalSkipGraph(int size, boolean manualJoin) {
lookupTables.add(lookupTable);
}

// Sort the identities by their identifier in ascending order.
identities.sort((id1, id2) -> id1.getIdentifier().comparedTo(id2.getIdentifier()));


// If manualJoin flag is set, then construct the lookup table manually,
// i.e. without using the join protocol.
if (manualJoin) {
Expand Down Expand Up @@ -142,8 +136,8 @@ public void insertAll() {
for (int i = 1; i < getNodes().size(); i++) {
SkipNode initiator = getNodes().get(i - 1);
getNodes()
.get(i)
.insert(initiator.getIdentity().getAddress(), initiator.getIdentity().getPort());
.get(i)
.insert(initiator.getIdentity().getAddress(), initiator.getIdentity().getPort());
}
}

Expand All @@ -165,7 +159,7 @@ public void insertAllRandomized() {
}

public Map<Identifier, LookupTable> identifierLookupTableMap() {
return skipNodes.stream().collect(Collectors.toMap(SkipNode::getIdentifier, SkipNode::getLookupTable));
return skipNodes.stream().collect(Collectors.toMap(SkipNode::getIdentifier, SkipNode::getLookupTable));
// return idMap.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().getIdentifier(), Map.Entry::getValue));
}

Expand Down

0 comments on commit 82fe0ca

Please sign in to comment.