Migrate project to Gradle, as library.

Fixed hex representation of NodeID.
This commit is contained in:
ChronosX88 2019-03-01 20:37:27 +04:00
parent cc62dff54c
commit d709113373
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
90 changed files with 623 additions and 1936 deletions

6
.gitignore vendored
View File

@ -1,2 +1,4 @@
/dist/ /out/
/build/ /build/
/.gradle/
/.idea/

17
build.gradle Normal file
View File

@ -0,0 +1,17 @@
plugins {
id 'java-library'
}
group 'io.github.chronosx88'
version '1.0'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
}

View File

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Kademlia" default="default" basedir=".">
<description>Builds, tests, and runs the project Kademlia.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Kademlia-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Fri Mar 01 19:17:47 MSK 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

172
gradlew vendored Executable file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
build.xml.data.CRC32=7e563d6e
build.xml.script.CRC32=c3cd04bd
build.xml.stylesheet.CRC32=8064a381@1.68.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7e563d6e
nbproject/build-impl.xml.script.CRC32=934ae712
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.74.1.48

View File

@ -1,77 +0,0 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Kademlia
application.vendor=Joshua
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Kademlia.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.gson-2.2.4.jar=C:\\Users\\Joshua\\Documents\\NetBeansProjects\\Libraries\\gson-2.2.4.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.gson-2.2.4.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=kademlia.KademliaBasic
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Kademlia</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

2
settings.gradle Normal file
View File

@ -0,0 +1,2 @@
rootProject.name = 'kademliadht'

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
import java.io.File; import java.io.File;

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -11,27 +11,26 @@ import java.net.InetAddress;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.dht.DHT; import io.github.chronosx88.kademliadht.dht.DHT;
import kademlia.dht.KadContent; import io.github.chronosx88.kademliadht.dht.KadContent;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.message.MessageFactory;
import kademlia.message.MessageFactory; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.KademliaId;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.operation.ConnectOperation;
import kademlia.operation.ConnectOperation; import io.github.chronosx88.kademliadht.operation.ContentLookupOperation;
import kademlia.operation.ContentLookupOperation; import io.github.chronosx88.kademliadht.operation.Operation;
import kademlia.operation.Operation; import io.github.chronosx88.kademliadht.operation.KadRefreshOperation;
import kademlia.operation.KadRefreshOperation; import io.github.chronosx88.kademliadht.operation.StoreOperation;
import kademlia.operation.StoreOperation; import io.github.chronosx88.kademliadht.routing.JKademliaRoutingTable;
import kademlia.routing.JKademliaRoutingTable; import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
import kademlia.routing.KademliaRoutingTable; import io.github.chronosx88.kademliadht.util.serializer.JsonDHTSerializer;
import kademlia.util.serializer.JsonDHTSerializer; import io.github.chronosx88.kademliadht.util.serializer.JsonRoutingTableSerializer;
import kademlia.util.serializer.JsonRoutingTableSerializer; import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
import kademlia.util.serializer.JsonSerializer;
/** /**
* The main Kademlia Node on the network, this node manages everything for this local system. * The main Kademlia Node on the network, this node manages everything for this local system.
@ -174,8 +173,8 @@ public class JKademliaNode implements KademliaNode
* *
* @return A Kademlia instance loaded from a stored state in a file * @return A Kademlia instance loaded from a stored state in a file
* *
* @throws java.io.FileNotFoundException * @throws FileNotFoundException
* @throws java.lang.ClassNotFoundException * @throws ClassNotFoundException
*/ */
public static JKademliaNode loadFromFile(String ownerId) throws FileNotFoundException, IOException, ClassNotFoundException public static JKademliaNode loadFromFile(String ownerId) throws FileNotFoundException, IOException, ClassNotFoundException
{ {
@ -190,8 +189,8 @@ public class JKademliaNode implements KademliaNode
* *
* @return A Kademlia instance loaded from a stored state in a file * @return A Kademlia instance loaded from a stored state in a file
* *
* @throws java.io.FileNotFoundException * @throws FileNotFoundException
* @throws java.lang.ClassNotFoundException * @throws ClassNotFoundException
*/ */
public static JKademliaNode loadFromFile(String ownerId, KadConfiguration iconfig) throws FileNotFoundException, IOException, ClassNotFoundException public static JKademliaNode loadFromFile(String ownerId, KadConfiguration iconfig) throws FileNotFoundException, IOException, ClassNotFoundException
{ {

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
/** /**
* Interface that defines a KadConfiguration object * Interface that defines a KadConfiguration object

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -13,12 +13,11 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import kademlia.exceptions.KadServerDownException; import io.github.chronosx88.kademliadht.exceptions.KadServerDownException;
import kademlia.message.KademliaMessageFactory; import io.github.chronosx88.kademliadht.message.KademliaMessageFactory;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.message.MessageFactory; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.message.Receiver;
import kademlia.message.Receiver;
/** /**
* The server that handles sending and receiving messages between nodes on the Kad Network * The server that handles sending and receiving messages between nodes on the Kad Network
@ -66,7 +65,7 @@ public class KadServer
* @param config * @param config
* @param statistician A statistician to manage the server statistics * @param statistician A statistician to manage the server statistics
* *
* @throws java.net.SocketException * @throws SocketException
*/ */
public KadServer(int udpPort, KademliaMessageFactory mFactory, Node localNode, KadConfiguration config, KadStatistician statistician) throws SocketException public KadServer(int udpPort, KademliaMessageFactory mFactory, Node localNode, KadConfiguration config, KadStatistician statistician) throws SocketException
{ {
@ -105,7 +104,7 @@ public class KadServer
* @return Integer The communication ID of this message * @return Integer The communication ID of this message
* *
* @throws IOException * @throws IOException
* @throws kademlia.exceptions.KadServerDownException * @throws KadServerDownException
*/ */
public synchronized int sendMessage(Node to, Message msg, Receiver recv) throws IOException, KadServerDownException public synchronized int sendMessage(Node to, Message msg, Receiver recv) throws IOException, KadServerDownException
{ {
@ -147,7 +146,7 @@ public class KadServer
* @param msg The reply message * @param msg The reply message
* @param comm The communication ID - the one received * @param comm The communication ID - the one received
* *
* @throws java.io.IOException * @throws IOException
*/ */
public synchronized void reply(Node to, Message msg, int comm) throws IOException public synchronized void reply(Node to, Message msg, int comm) throws IOException
{ {

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
/** /**
* Specification for class that keeps statistics for a Kademlia instance. * Specification for class that keeps statistics for a Kademlia instance.

View File

@ -1,16 +1,15 @@
package kademlia; package io.github.chronosx88.kademliadht;
import java.io.IOException; import java.io.IOException;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.KadContent; import io.github.chronosx88.kademliadht.dht.KadContent;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
import kademlia.routing.KademliaRoutingTable;
/** /**
* The main Kademlia Node on the network, this node manages everything for this local system. * The main Kademlia Node on the network, this node manages everything for this local system.
@ -71,7 +70,7 @@ public interface KademliaNode
* *
* @return Integer How many nodes the content was stored on * @return Integer How many nodes the content was stored on
* *
* @throws java.io.IOException * @throws IOException
* *
*/ */
public int put(KadContent content) throws IOException; public int put(KadContent content) throws IOException;
@ -84,7 +83,7 @@ public interface KademliaNode
* *
* @return Integer How many nodes the content was stored on * @return Integer How many nodes the content was stored on
* *
* @throws java.io.IOException * @throws IOException
* *
*/ */
public int put(JKademliaStorageEntry entry) throws IOException; public int put(JKademliaStorageEntry entry) throws IOException;
@ -94,7 +93,7 @@ public interface KademliaNode
* *
* @param content The content to put on the DHT * @param content The content to put on the DHT
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void putLocally(KadContent content) throws IOException; public void putLocally(KadContent content) throws IOException;
@ -105,15 +104,15 @@ public interface KademliaNode
* *
* @return DHTContent The content * @return DHTContent The content
* *
* @throws java.io.IOException * @throws IOException
* @throws kademlia.exceptions.ContentNotFoundException * @throws ContentNotFoundException
*/ */
public JKademliaStorageEntry get(GetParameter param) throws NoSuchElementException, IOException, ContentNotFoundException; public JKademliaStorageEntry get(GetParameter param) throws NoSuchElementException, IOException, ContentNotFoundException;
/** /**
* Allow the user of the System to call refresh even out of the normal Kad refresh timing * Allow the user of the System to call refresh even out of the normal Kad refresh timing
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void refresh() throws IOException; public void refresh() throws IOException;

View File

@ -1,4 +1,4 @@
package kademlia; package io.github.chronosx88.kademliadht;
import java.text.DecimalFormat; import java.text.DecimalFormat;

View File

@ -1,4 +1,4 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -9,12 +9,12 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.exceptions.ContentExistException; import io.github.chronosx88.kademliadht.exceptions.ContentExistException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
import kademlia.util.serializer.JsonSerializer; import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
import kademlia.util.serializer.KadSerializer; import io.github.chronosx88.kademliadht.util.serializer.KadSerializer;
/** /**
* The main Distributed Hash Table class that manages the entire DHT * The main Distributed Hash Table class that manages the entire DHT

View File

@ -1,6 +1,6 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* A GET request can get content based on Key, Owner, Type, etc * A GET request can get content based on Key, Owner, Type, etc

View File

@ -1,4 +1,4 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
/** /**
* A JKademliaStorageEntry class that is used to store a content on the DHT * A JKademliaStorageEntry class that is used to store a content on the DHT

View File

@ -1,6 +1,6 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Any piece of content that needs to be stored on the DHT * Any piece of content that needs to be stored on the DHT

View File

@ -1,13 +1,13 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
import kademlia.util.serializer.KadSerializer; import io.github.chronosx88.kademliadht.util.serializer.KadSerializer;
/** /**
* The main Distributed Hash Table interface that manages the entire DHT * The main Distributed Hash Table interface that manages the entire DHT
@ -44,7 +44,7 @@ public interface KademliaDHT
* *
* @return boolean true if we stored the content, false if the content already exists and is up to date * @return boolean true if we stored the content, false if the content already exists and is up to date
* *
* @throws java.io.IOException * @throws IOException
*/ */
public boolean store(JKademliaStorageEntry content) throws IOException; public boolean store(JKademliaStorageEntry content) throws IOException;
@ -58,8 +58,8 @@ public interface KademliaDHT
* *
* @return A KadContent object * @return A KadContent object
* *
* @throws java.io.FileNotFoundException * @throws FileNotFoundException
* @throws java.lang.ClassNotFoundException * @throws ClassNotFoundException
*/ */
public JKademliaStorageEntry retrieve(KademliaId key, int hashCode) throws FileNotFoundException, IOException, ClassNotFoundException; public JKademliaStorageEntry retrieve(KademliaId key, int hashCode) throws FileNotFoundException, IOException, ClassNotFoundException;
@ -79,7 +79,7 @@ public interface KademliaDHT
* *
* @return KadContent The content object * @return KadContent The content object
* *
* @throws java.io.IOException * @throws IOException
*/ */
public JKademliaStorageEntry get(KademliaStorageEntryMetadata entry) throws IOException, NoSuchElementException; public JKademliaStorageEntry get(KademliaStorageEntryMetadata entry) throws IOException, NoSuchElementException;
@ -90,7 +90,7 @@ public interface KademliaDHT
* *
* @return KadContent A KadContent found on the DHT satisfying the given criteria * @return KadContent A KadContent found on the DHT satisfying the given criteria
* *
* @throws java.io.IOException * @throws IOException
*/ */
public JKademliaStorageEntry get(GetParameter param) throws NoSuchElementException, IOException; public JKademliaStorageEntry get(GetParameter param) throws NoSuchElementException, IOException;
@ -100,7 +100,7 @@ public interface KademliaDHT
* @param content The Content to Remove * @param content The Content to Remove
* *
* *
* @throws kademlia.exceptions.ContentNotFoundException * @throws ContentNotFoundException
*/ */
public void remove(KadContent content) throws ContentNotFoundException; public void remove(KadContent content) throws ContentNotFoundException;

View File

@ -1,4 +1,4 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
/** /**
* A StorageEntry interface for the storage entry class used to store a content on the DHT * A StorageEntry interface for the storage entry class used to store a content on the DHT

View File

@ -1,6 +1,6 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Keeps track of data for a Content stored in the DHT * Keeps track of data for a Content stored in the DHT

View File

@ -1,7 +1,7 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import java.util.Objects; import java.util.Objects;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Keeps track of data for a Content stored in the DHT * Keeps track of data for a Content stored in the DHT

View File

@ -1,13 +1,13 @@
package kademlia.dht; package io.github.chronosx88.kademliadht.dht;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import kademlia.exceptions.ContentExistException; import io.github.chronosx88.kademliadht.exceptions.ContentExistException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* It would be infeasible to keep all content in memory to be send when requested * It would be infeasible to keep all content in memory to be send when requested

View File

@ -1,4 +1,4 @@
package kademlia.exceptions; package io.github.chronosx88.kademliadht.exceptions;
/** /**
* An exception used to indicate that a content already exist on the DHT * An exception used to indicate that a content already exist on the DHT

View File

@ -1,4 +1,4 @@
package kademlia.exceptions; package io.github.chronosx88.kademliadht.exceptions;
/** /**
* An exception used to indicate that a content does not exist on the DHT * An exception used to indicate that a content does not exist on the DHT

View File

@ -1,4 +1,4 @@
package kademlia.exceptions; package io.github.chronosx88.kademliadht.exceptions;
/** /**
* An exception to be thrown whenever the Kad Server is down * An exception to be thrown whenever the Kad Server is down

View File

@ -1,4 +1,4 @@
package kademlia.exceptions; package io.github.chronosx88.kademliadht.exceptions;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package kademlia.exceptions; package io.github.chronosx88.kademliadht.exceptions;
/** /**
* An exception used to indicate an unknown message type or communication identifier * An exception used to indicate an unknown message type or communication identifier

View File

@ -1,9 +1,9 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* A message used to acknowledge a request from a node; can be used in many situations. * A message used to acknowledge a request from a node; can be used in many situations.

View File

@ -1,9 +1,9 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* A message sent to another node requesting to connect to them. * A message sent to another node requesting to connect to them.

View File

@ -1,8 +1,8 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
/** /**
* Receives a ConnectMessage and sends an AcknowledgeMessage as reply. * Receives a ConnectMessage and sends an AcknowledgeMessage as reply.
@ -27,7 +27,7 @@ public class ConnectReceiver implements Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public void receive(Message incoming, int comm) throws IOException public void receive(Message incoming, int comm) throws IOException
@ -49,7 +49,7 @@ public class ConnectReceiver implements Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public void timeout(int comm) throws IOException public void timeout(int comm) throws IOException

View File

@ -1,11 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.util.serializer.JsonSerializer; import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
/** /**
* Messages used to send to another node requesting content. * Messages used to send to another node requesting content.

View File

@ -1,11 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
/** /**
* Responds to a ContentLookupMessage by sending a ContentMessage containing the requested content; * Responds to a ContentLookupMessage by sending a ContentMessage containing the requested content;

View File

@ -1,12 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
import kademlia.util.serializer.JsonSerializer;
/** /**
* A Message used to send content between nodes * A Message used to send content between nodes

View File

@ -1,8 +1,8 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
/** /**
* A factory that handles creating messages and receivers * A factory that handles creating messages and receivers
@ -21,7 +21,7 @@ public interface KademliaMessageFactory
* *
* @return A message * @return A message
* *
* @throws java.io.IOException * @throws IOException
*/ */
public Message createMessage(byte code, DataInputStream in) throws IOException; public Message createMessage(byte code, DataInputStream in) throws IOException;

View File

@ -1,4 +1,4 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
public interface Message extends Streamable public interface Message extends Streamable
{ {

View File

@ -1,11 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
/** /**
* Handles creating messages and receivers * Handles creating messages and receivers

View File

@ -1,10 +1,10 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* A message sent to other nodes requesting the K-Closest nodes to a key sent in this message. * A message sent to other nodes requesting the K-Closest nodes to a key sent in this message.

View File

@ -1,11 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* Receives a NodeLookupMessage and sends a NodeReplyMessage as reply with the K-Closest nodes to the ID sent. * Receives a NodeLookupMessage and sends a NodeReplyMessage as reply with the K-Closest nodes to the ID sent.
@ -33,7 +33,7 @@ public class NodeLookupReceiver implements Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public void receive(Message incoming, int comm) throws IOException public void receive(Message incoming, int comm) throws IOException
@ -63,7 +63,7 @@ public class NodeLookupReceiver implements Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public void timeout(int comm) throws IOException public void timeout(int comm) throws IOException

View File

@ -1,11 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* A message used to connect nodes. * A message used to connect nodes.

View File

@ -1,4 +1,4 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;
@ -17,7 +17,7 @@ public interface Receiver
* @param conversationId The ID of this conversation, used for further conversations * @param conversationId The ID of this conversation, used for further conversations
* @param incoming The incoming * @param incoming The incoming
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void receive(Message incoming, int conversationId) throws IOException; public void receive(Message incoming, int conversationId) throws IOException;

View File

@ -1,4 +1,4 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;

View File

@ -1,12 +1,11 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
import kademlia.util.serializer.JsonSerializer;
/** /**
* A StoreContentMessage used to send a store message to a node * A StoreContentMessage used to send a store message to a node

View File

@ -1,9 +1,9 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.IOException; import java.io.IOException;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
/** /**
* Receiver for incoming StoreContentMessage * Receiver for incoming StoreContentMessage

View File

@ -1,4 +1,4 @@
package kademlia.message; package io.github.chronosx88.kademliadht.message;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -27,7 +27,7 @@ public interface Streamable
* *
* @param out * @param out
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void toStream(DataOutputStream out) throws IOException; public void toStream(DataOutputStream out) throws IOException;
@ -36,7 +36,7 @@ public interface Streamable
* *
* @param out * @param out
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void fromStream(DataInputStream out) throws IOException; public void fromStream(DataInputStream out) throws IOException;
} }

View File

@ -3,7 +3,7 @@
* @created 20140215 * @created 20140215
* @desc Represents a Kademlia Node ID * @desc Represents a Kademlia Node ID
*/ */
package kademlia.node; package io.github.chronosx88.kademliadht.node;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -13,7 +13,9 @@ import java.math.BigInteger;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet; import java.util.BitSet;
import java.util.Random; import java.util.Random;
import kademlia.message.Streamable; import io.github.chronosx88.kademliadht.message.Streamable;
import javax.xml.bind.DatatypeConverter;
public class KademliaId implements Streamable, Serializable public class KademliaId implements Streamable, Serializable
{ {
@ -28,7 +30,7 @@ public class KademliaId implements Streamable, Serializable
*/ */
public KademliaId(String data) public KademliaId(String data)
{ {
keyBytes = data.getBytes(); keyBytes = DatatypeConverter.parseHexBinary(data);
if (keyBytes.length != ID_LENGTH / 8) if (keyBytes.length != ID_LENGTH / 8)
{ {
throw new IllegalArgumentException("Specified Data need to be " + (ID_LENGTH / 8) + " characters long."); throw new IllegalArgumentException("Specified Data need to be " + (ID_LENGTH / 8) + " characters long.");
@ -250,8 +252,7 @@ public class KademliaId implements Streamable, Serializable
public String hexRepresentation() public String hexRepresentation()
{ {
/* Returns the hex format of this NodeId */ /* Returns the hex format of this NodeId */
BigInteger bi = new BigInteger(1, this.keyBytes); return DatatypeConverter.printHexBinary(this.keyBytes);
return String.format("%0" + (this.keyBytes.length << 1) + "X", bi);
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package kademlia.node; package io.github.chronosx88.kademliadht.node;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Comparator; import java.util.Comparator;

View File

@ -1,4 +1,4 @@
package kademlia.node; package io.github.chronosx88.kademliadht.node;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -6,7 +6,7 @@ import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import kademlia.message.Streamable; import io.github.chronosx88.kademliadht.message.Streamable;
/** /**
* A Node in the Kademlia network - Contains basic node network information. * A Node in the Kademlia network - Contains basic node network information.

View File

@ -1,10 +1,10 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* At each time interval t, nodes need to refresh their K-Buckets * At each time interval t, nodes need to refresh their K-Buckets
@ -35,7 +35,7 @@ public class BucketRefreshOperation implements Operation
* Then Do a NodeLookupOperation for each of the generated NodeIds, * Then Do a NodeLookupOperation for each of the generated NodeIds,
* This will find the K-Closest nodes to that ID, and update the necessary K-Bucket * This will find the K-Closest nodes to that ID, and update the necessary K-Bucket
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public synchronized void execute() throws IOException public synchronized void execute() throws IOException

View File

@ -3,19 +3,19 @@
* @created 20140218 * @created 20140218
* @desc Operation that handles connecting to an existing Kademlia network using a bootstrap node * @desc Operation that handles connecting to an existing Kademlia network using a bootstrap node
*/ */
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import kademlia.message.Receiver; import io.github.chronosx88.kademliadht.message.Receiver;
import java.io.IOException; import java.io.IOException;
import kademlia.JKademliaNode;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.message.AcknowledgeMessage; import io.github.chronosx88.kademliadht.message.AcknowledgeMessage;
import kademlia.message.ConnectMessage; import io.github.chronosx88.kademliadht.message.ConnectMessage;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
public class ConnectOperation implements Operation, Receiver public class ConnectOperation implements Operation, Receiver
{ {
@ -122,7 +122,7 @@ public class ConnectOperation implements Operation, Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public synchronized void timeout(int comm) throws IOException public synchronized void timeout(int comm) throws IOException

View File

@ -1,6 +1,6 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import kademlia.message.Receiver; import io.github.chronosx88.kademliadht.message.Receiver;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -10,22 +10,21 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.exceptions.UnknownMessageException;
import kademlia.exceptions.UnknownMessageException; import io.github.chronosx88.kademliadht.message.ContentLookupMessage;
import kademlia.message.ContentLookupMessage; import io.github.chronosx88.kademliadht.message.ContentMessage;
import kademlia.message.ContentMessage; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.NodeReplyMessage;
import kademlia.message.NodeReplyMessage; import io.github.chronosx88.kademliadht.node.KeyComparator;
import kademlia.node.KeyComparator; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.util.RouteLengthChecker;
import kademlia.util.RouteLengthChecker;
/** /**
* Looks up a specified identifier and returns the value associated with it * Looks up a specified identifier and returns the value associated with it
@ -92,8 +91,8 @@ public class ContentLookupOperation implements Operation, Receiver
} }
/** /**
* @throws java.io.IOException * @throws IOException
* @throws kademlia.exceptions.RoutingException * @throws RoutingException
*/ */
@Override @Override
public synchronized void execute() throws IOException, RoutingException public synchronized void execute() throws IOException, RoutingException
@ -287,7 +286,7 @@ public class ContentLookupOperation implements Operation, Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public synchronized void timeout(int comm) throws IOException public synchronized void timeout(int comm) throws IOException
@ -319,7 +318,7 @@ public class ContentLookupOperation implements Operation, Receiver
/** /**
* @return The list of all content found during the lookup operation * @return The list of all content found during the lookup operation
* *
* @throws kademlia.exceptions.ContentNotFoundException * @throws ContentNotFoundException
*/ */
public JKademliaStorageEntry getContentFound() throws ContentNotFoundException public JKademliaStorageEntry getContentFound() throws ContentNotFoundException
{ {

View File

@ -1,17 +1,16 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
import kademlia.dht.KademliaStorageEntryMetadata; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntryMetadata;
import kademlia.dht.StorageEntryMetadata; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.StoreContentMessage;
import kademlia.message.StoreContentMessage; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node;
/** /**
* Refresh/Restore the data on this node by sending the data to the K-Closest nodes to the data * Refresh/Restore the data on this node by sending the data to the K-Closest nodes to the data
@ -41,7 +40,7 @@ public class ContentRefreshOperation implements Operation
We assume that our JKademliaRoutingTable is updated, and we can get the K closest nodes from that table We assume that our JKademliaRoutingTable is updated, and we can get the K closest nodes from that table
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public void execute() throws IOException public void execute() throws IOException

View File

@ -1,10 +1,10 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
/** /**
* An operation that handles refreshing the entire Kademlia Systems including buckets and content * An operation that handles refreshing the entire Kademlia Systems including buckets and content

View File

@ -1,6 +1,6 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import kademlia.message.Receiver; import io.github.chronosx88.kademliadht.message.Receiver;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@ -8,16 +8,16 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.message.NodeLookupMessage; import io.github.chronosx88.kademliadht.message.NodeLookupMessage;
import kademlia.message.NodeReplyMessage; import io.github.chronosx88.kademliadht.message.NodeReplyMessage;
import kademlia.node.KeyComparator; import io.github.chronosx88.kademliadht.node.KeyComparator;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Finds the K closest nodes to a specified identifier * Finds the K closest nodes to a specified identifier
@ -77,8 +77,8 @@ public class NodeLookupOperation implements Operation, Receiver
} }
/** /**
* @throws java.io.IOException * @throws IOException
* @throws kademlia.exceptions.RoutingException * @throws RoutingException
*/ */
@Override @Override
public synchronized void execute() throws IOException, RoutingException public synchronized void execute() throws IOException, RoutingException
@ -252,7 +252,7 @@ public class NodeLookupOperation implements Operation, Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public synchronized void receive(Message incoming, int comm) throws IOException public synchronized void receive(Message incoming, int comm) throws IOException
@ -285,7 +285,7 @@ public class NodeLookupOperation implements Operation, Receiver
* *
* @param comm * @param comm
* *
* @throws java.io.IOException * @throws IOException
*/ */
@Override @Override
public synchronized void timeout(int comm) throws IOException public synchronized void timeout(int comm) throws IOException

View File

@ -1,7 +1,7 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
/** /**
* An operation in the Kademlia routing protocol * An operation in the Kademlia routing protocol
@ -15,7 +15,7 @@ public interface Operation
/** /**
* Starts an operation and returns when the operation is finished * Starts an operation and returns when the operation is finished
* *
* @throws kademlia.exceptions.RoutingException * @throws RoutingException
*/ */
public void execute() throws IOException, RoutingException; public void execute() throws IOException, RoutingException;
} }

View File

@ -5,12 +5,12 @@
* @author Joshua Kissoon * @author Joshua Kissoon
* @since 20140218 * @since 20140218
*/ */
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.exceptions.RoutingException; import io.github.chronosx88.kademliadht.exceptions.RoutingException;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
public class PingOperation implements Operation public class PingOperation implements Operation
{ {

View File

@ -1,16 +1,15 @@
package kademlia.operation; package io.github.chronosx88.kademliadht.operation;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.KadServer; import io.github.chronosx88.kademliadht.KadServer;
import kademlia.KademliaNode; import io.github.chronosx88.kademliadht.KademliaNode;
import kademlia.dht.JKademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.message.Message;
import kademlia.message.Message; import io.github.chronosx88.kademliadht.message.StoreContentMessage;
import kademlia.message.StoreContentMessage; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.Node;
/** /**
* Operation that stores a DHT Content onto the K closest nodes to the content Key * Operation that stores a DHT Content onto the K closest nodes to the content Key

View File

@ -1,6 +1,6 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* Keeps information about contacts of the Node; Contacts are stored in the Buckets in the Routing Table. * Keeps information about contacts of the Node; Contacts are stored in the Buckets in the Routing Table.

View File

@ -1,4 +1,4 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import java.util.Comparator; import java.util.Comparator;

View File

@ -1,11 +1,11 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.TreeSet; import java.util.TreeSet;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* A bucket in the Kademlia routing table * A bucket in the Kademlia routing table

View File

@ -1,12 +1,12 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.node.KeyComparator; import io.github.chronosx88.kademliadht.node.KeyComparator;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Implementation of a Kademlia routing table * Implementation of a Kademlia routing table

View File

@ -1,7 +1,7 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import java.util.List; import java.util.List;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* A bucket used to store Contacts in the routing table. * A bucket used to store Contacts in the routing table.

View File

@ -1,9 +1,9 @@
package kademlia.routing; package io.github.chronosx88.kademliadht.routing;
import java.util.List; import java.util.List;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Specification for Kademlia's Routing Table * Specification for Kademlia's Routing Table

View File

@ -1,11 +1,11 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import kademlia.DefaultConfiguration; import io.github.chronosx88.kademliadht.DefaultConfiguration;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing the Kademlia Auto Content and Node table refresh operations * Testing the Kademlia Auto Content and Node table refresh operations

View File

@ -1,11 +1,11 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import kademlia.DefaultConfiguration; import io.github.chronosx88.kademliadht.DefaultConfiguration;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing the Kademlia Auto Content and Node table refresh operations * Testing the Kademlia Auto Content and Node table refresh operations

View File

@ -1,12 +1,12 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing sending and receiving content between 2 Nodes on a network * Testing sending and receiving content between 2 Nodes on a network

View File

@ -1,11 +1,11 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing sending and receiving content between 2 Nodes on a network * Testing sending and receiving content between 2 Nodes on a network

View File

@ -1,8 +1,8 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import com.google.gson.Gson; import com.google.gson.Gson;
import kademlia.dht.KadContent; import io.github.chronosx88.kademliadht.dht.KadContent;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* A simple DHT Content object to test DHT storage * A simple DHT Content object to test DHT storage

View File

@ -1,8 +1,8 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing connecting 2 nodes to each other * Testing connecting 2 nodes to each other

View File

@ -1,11 +1,11 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
import kademlia.exceptions.ContentNotFoundException; import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing sending and receiving content between 2 Nodes on a network * Testing sending and receiving content between 2 Nodes on a network

View File

@ -1,8 +1,8 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
import kademlia.routing.KademliaRoutingTable; import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
/** /**
* Testing how the routing table works and checking if everything works properly * Testing how the routing table works and checking if everything works properly

View File

@ -1,10 +1,10 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import java.util.Scanner; import java.util.Scanner;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.KadContent; import io.github.chronosx88.kademliadht.dht.KadContent;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing how the routing table works and it's state after different operations * Testing how the routing table works and it's state after different operations

View File

@ -1,7 +1,7 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing the save and retrieve state operations * Testing the save and retrieve state operations

View File

@ -1,9 +1,9 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.dht.GetParameter; import io.github.chronosx88.kademliadht.dht.GetParameter;
import kademlia.dht.KademliaStorageEntry; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
/** /**
* Testing the save and retrieve state operations. * Testing the save and retrieve state operations.

View File

@ -1,10 +1,10 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
import java.io.IOException; import java.io.IOException;
import kademlia.JKademliaNode; import io.github.chronosx88.kademliadht.JKademliaNode;
import kademlia.message.SimpleMessage; import io.github.chronosx88.kademliadht.message.SimpleMessage;
import kademlia.node.KademliaId; import io.github.chronosx88.kademliadht.node.KademliaId;
import kademlia.message.SimpleReceiver; import io.github.chronosx88.kademliadht.message.SimpleReceiver;
/** /**
* Test 1: Try sending a simple message between nodes * Test 1: Try sending a simple message between nodes

View File

@ -1,4 +1,4 @@
package kademlia.simulations; package io.github.chronosx88.kademliadht.simulations;
/** /**
* A class that specifies the structure for simulations. * A class that specifies the structure for simulations.

View File

@ -1,4 +1,4 @@
package kademlia.util; package io.github.chronosx88.kademliadht.util;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -19,7 +19,7 @@ public class HashCalculator
* *
* @return byte[20] The hashed string * @return byte[20] The hashed string
* *
* @throws java.security.NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public static byte[] sha1Hash(String toHash) throws NoSuchAlgorithmException public static byte[] sha1Hash(String toHash) throws NoSuchAlgorithmException
{ {
@ -41,7 +41,7 @@ public class HashCalculator
* *
* @return byte[20] The hashed string * @return byte[20] The hashed string
* *
* @throws java.security.NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public static byte[] sha1Hash(String toHash, String salt) throws NoSuchAlgorithmException public static byte[] sha1Hash(String toHash, String salt) throws NoSuchAlgorithmException
{ {
@ -62,7 +62,7 @@ public class HashCalculator
* *
* @return byte[16] The hashed string * @return byte[16] The hashed string
* *
* @throws java.security.NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public static byte[] md5Hash(String toHash) throws NoSuchAlgorithmException public static byte[] md5Hash(String toHash) throws NoSuchAlgorithmException
{ {
@ -84,7 +84,7 @@ public class HashCalculator
* *
* @return byte[16] The hashed string * @return byte[16] The hashed string
* *
* @throws java.security.NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public static byte[] md5Hash(String toHash, String salt) throws NoSuchAlgorithmException public static byte[] md5Hash(String toHash, String salt) throws NoSuchAlgorithmException
{ {

View File

@ -1,8 +1,8 @@
package kademlia.util; package io.github.chronosx88.kademliadht.util;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import kademlia.node.Node; import io.github.chronosx88.kademliadht.node.Node;
/** /**
* Class that helps compute the route length taken to complete an operation. * Class that helps compute the route length taken to complete an operation.

View File

@ -1,4 +1,4 @@
package kademlia.util.serializer; package io.github.chronosx88.kademliadht.util.serializer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -11,9 +11,9 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import kademlia.dht.DHT; import io.github.chronosx88.kademliadht.dht.DHT;
import kademlia.dht.KademliaDHT; import io.github.chronosx88.kademliadht.dht.KademliaDHT;
import kademlia.dht.KademliaStorageEntryMetadata; import io.github.chronosx88.kademliadht.dht.KademliaStorageEntryMetadata;
/** /**
* A KadSerializer that serializes DHT to JSON format * A KadSerializer that serializes DHT to JSON format

View File

@ -1,4 +1,4 @@
package kademlia.util.serializer; package io.github.chronosx88.kademliadht.util.serializer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -9,12 +9,12 @@ import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import kademlia.routing.JKademliaRoutingTable; import io.github.chronosx88.kademliadht.routing.JKademliaRoutingTable;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import kademlia.KadConfiguration; import io.github.chronosx88.kademliadht.KadConfiguration;
import kademlia.routing.Contact; import io.github.chronosx88.kademliadht.routing.Contact;
import kademlia.routing.KademliaRoutingTable; import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
/** /**
* A KadSerializer that serializes routing tables to JSON format * A KadSerializer that serializes routing tables to JSON format

View File

@ -1,4 +1,4 @@
package kademlia.util.serializer; package io.github.chronosx88.kademliadht.util.serializer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;

View File

@ -1,4 +1,4 @@
package kademlia.util.serializer; package io.github.chronosx88.kademliadht.util.serializer;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -23,7 +23,7 @@ public interface KadSerializer<T>
* @param data The data to write * @param data The data to write
* @param out The output Stream to write to * @param out The output Stream to write to
* *
* @throws java.io.IOException * @throws IOException
*/ */
public void write(T data, DataOutputStream out) throws IOException; public void write(T data, DataOutputStream out) throws IOException;
@ -34,8 +34,8 @@ public interface KadSerializer<T>
* *
* @return T Data of type T * @return T Data of type T
* *
* @throws java.io.IOException * @throws IOException
* @throws java.lang.ClassNotFoundException * @throws ClassNotFoundException
*/ */
public T read(DataInputStream in) throws IOException, ClassNotFoundException; public T read(DataInputStream in) throws IOException, ClassNotFoundException;
} }