Skip to content

Commit

Permalink
Refactors name id and num id to membership vector and identifier (par…
Browse files Browse the repository at this point in the history
…t-2) (#31)

* renames nameid and numberical id

* refactors identifier and membership vector in skip graph identity

* removes logger off skip graph identity

* refactors line length

* wip refactoring skip node

* wip refactors middlelayer

* refactors skipnode

* wip refactors middlelayer

* wip refactors lookup table

* wip refactors localskipgraph

* wip refactors tests

* refactors skipnode tests

* wip refactors tests and local skip graph

* fixes all underlay tests except udp

* fixes udp tests

* wip fixing tests

* wip why identifier map does not work?

* refactors concurrent lookup table

* adds identifier map test

* fixes bug with equal method

* refactors local skip graph

* fixes port issue with concurrent insertion and tests

* adds hub and fixes underlay tests

* wip

* fixes test insertion

* fixes concurrent insertion

* implements concurrent search

* adds search by membership vetctor

* fixes lint

* switches the constructor for local skip graph

* fixes bug with local skip graph tests

* adds logger as a module

* fixes pom issues

* adds logger and backoff to middlelayer

* fixes sequential insertion test

* fixes all tests

* fixes lints

* partially fixes name ids and numerical ids

* renames name id and num id to new equivalents.

* renames name ids to membership vector

* obsoletes the name ids and numerical ids

* lint fix
  • Loading branch information
thep2p authored Sep 7, 2023
1 parent fa606e7 commit a682560
Show file tree
Hide file tree
Showing 74 changed files with 1,643 additions and 1,201 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ parameters are:
* The Underlay Protocol to be used.
* Port
* Introducer Address
* Name ID Assignment Protocol
* Name ID value if Assignment Protocol is self-assgined
* Numerical ID Assignment Protocol
* Numerical ID value if Assignment Protocol is self-assigned
* Membership Vector Assignment Protocol
* Membership Vector value if Assignment Protocol is self-assgined
* Identifier Assignment Protocol
* Identifier value if Assignment Protocol is self-assigned
* Storage Path

After the configuration file is ready, the skip graph node can be run by running the executable
Expand All @@ -22,18 +22,18 @@ After setting up a Skip Graph process in the network and having it running, the
interact with the Skip Graph Node in an online manner. While the Node is running, options
for possible queries will appear to the user. These options are:

## Search by Numerical ID
## Search by Identifier

After the user picks this option, the interactor API prompts the user to provide the target
numerical ID to conduct the search. Then, the query is executed from the designated skip
identifier to conduct the search. Then, the query is executed from the designated skip
node as the source of the query, and finally, it prints to the user the information of
the node returned as the result of the query.

## Search by Name ID
## Search by Membership Vector (aka Search by Name ID)

After the user picks this option, the interactor API prompts the user to privde the target
name ID to conduct the search, which can be either a binary string, or a hexadecimal number
denoting the bytes of the name ID. Then, the query is executed from th desginated skip node
membership vector to conduct the search, which can be either a binary string, or a hexadecimal number
denoting the bytes of the membership vector. Then, the query is executed from th desginated skip node
as the source of the query, and finally, it prints to the user the information of the node
returned as the result of the query.

Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<property name="max" value="170"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

Expand Down
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,26 @@
<artifactId>java-multibase</artifactId>
<version>v1.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.0-alpha0</version>
<scope>runtime</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.findbugs/annotations -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</project>
4 changes: 3 additions & 1 deletion src/main/java/log/Appender.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package log;

/** Appender interface for adding multiple key-value pairs to JsonMessage. */
/**
* Appender interface for adding multiple key-value pairs to JsonMessage.
*/
public interface Appender {

Appender addInt(String key, int value);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/log/ContextLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
public class ContextLogger implements ContextLoggerInterface {

private Logger logger;
private JsonMessage msg = new JsonMessage();
private final Logger logger;
private final JsonMessage msg = new JsonMessage();

public ContextLogger(Logger logger) {
this.logger = logger;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/log/ContextLoggerInterface.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package log;

/** Logger interface extended with context info in mind. */
/**
* Logger interface extended with context info in mind.
*/
public interface ContextLoggerInterface extends LoggerInterface {

ContextLoggerInterface addInt(String key, int value);
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/log/Log4jAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;

/** Appender implementation for Log4jLogger. */
/**
* Appender implementation for Log4jLogger.
*/
public class Log4jAppender implements Appender {

private JsonMessage message;
private Logger logger;
private Level level;
private final JsonMessage message;
private final Logger logger;
private final Level level;
private Throwable exception = null;

/**
* Constructor forLog4jAppender.
*
* @param logger logger instance.
* @param level log level.
* @param level log level.
*/
public Log4jAppender(Logger logger, Level level) {
this.message = new JsonMessage();
Expand All @@ -26,9 +28,9 @@ public Log4jAppender(Logger logger, Level level) {
/**
* Constructor forLog4jAppender.
*
* @param msg Initial json message.
* @param msg Initial json message.
* @param logger logger instance.
* @param level log level.
* @param level log level.
*/
public Log4jAppender(JsonMessage msg, Logger logger, Level level) {
this.message = msg;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/log/Log4jLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class Log4jLogger implements LoggerInterface {

private Logger logger;
private final Logger logger;

public Log4jLogger(Logger logger) {
this.logger = logger;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/log/LoggerInterface.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package log;

/** Logger interface used for logging statements in key-value form. */
/**
* Logger interface used for logging statements in key-value form.
*/
public interface LoggerInterface {

Appender debug();
Expand Down
30 changes: 12 additions & 18 deletions src/main/java/lookup/ConcurrentLookupTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
* ConcurrentLookupTable is a lookup table that supports concurrent calls.
*/
public class ConcurrentLookupTable implements LookupTable {
private enum Direction {
LEFT,
RIGHT
}


// TODO: logger should be passed as a constructor parameter.
private static final Log4jLogger logger =
new Log4jLogger(LogManager.getLogger(ConcurrentLookupTable.class));
private static final Log4jLogger logger = new Log4jLogger(LogManager.getLogger(ConcurrentLookupTable.class));
private final SkipNodeIdentity owner;
private final int numLevels;
private final ReadWriteLock lock;
Expand Down Expand Up @@ -58,12 +54,9 @@ public SkipNodeIdentity updateLeft(SkipNodeIdentity node, int level) {

lock.writeLock().unlock();

logger
.debug()
.addInt("owner_num_id", owner.getNumId())
.addInt("neighbor_num_id", node.getNumId())
.addInt("level", level)
.addMsg("updated left neighbor in lookup table");

// logger.debug().addInt("owner_num_id", owner.getIdentifier()).addInt("neighbor_num_id", node.getIdentifier()).addInt("level", level).addMsg(
// "updated left neighbor in lookup table");
return prev;
}

Expand All @@ -80,12 +73,13 @@ public SkipNodeIdentity updateRight(SkipNodeIdentity node, int level) {

lock.writeLock().unlock();

logger
.debug()
.addInt("owner_num_id", owner.getNumId())
.addInt("neighbor_num_id", node.getNumId())
.addInt("level", level)
.addMsg("updated right in lookup table");
// logger.debug().addInt("owner_num_id", owner.getIdentifier()).addInt("neighbor_num_id", node.getIdentifier()).addInt("level", level).addMsg(
// logger
// .debug()
// .addInt("owner_num_id", owner.getIdentifier())
// .addInt("neighbor_num_id", node.getIdentifier())
// .addInt("level", level)
// .addMsg("updated right in lookup table");
return prev;
}

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/lookup/LookupTable.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package lookup;

import model.skipgraph.SkipGraph;
import skipnode.SkipNodeIdentity;

/**
* Lookup Table interface.
*/
public interface LookupTable {
/**
* Direction of the neighbor; Left or Right.
*/
enum Direction {
LEFT, RIGHT
}

SkipNodeIdentity EMPTY_NODE = new SkipNodeIdentity("EMPTY", -1, "EMPTY", -1);
SkipNodeIdentity INVALID_NODE = new SkipNodeIdentity("INVALID", -1, "INVALID", -1);
SkipNodeIdentity EMPTY_NODE = new SkipNodeIdentity(SkipGraph.getEmptyIdentifier(), SkipGraph.getEmptyMembershipVector(), "EMPTY", -1);
SkipNodeIdentity INVALID_NODE = new SkipNodeIdentity(SkipGraph.getInvalidIdentifier(), SkipGraph.getEmptyMembershipVector(), "INVALID", -1);

/**
* Updates the left neighbor on the given level to be the node.
Expand Down
Loading

0 comments on commit a682560

Please sign in to comment.