mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-24 11:12:18 +00:00
Migrate project to Gradle, as library.
Fixed hex representation of NodeID.
This commit is contained in:
parent
cc62dff54c
commit
d709113373
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
/dist/
|
||||
/out/
|
||||
/build/
|
||||
/.gradle/
|
||||
/.idea/
|
||||
|
17
build.gradle
Normal file
17
build.gradle
Normal 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'
|
||||
}
|
73
build.xml
73
build.xml
@ -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
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal 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
172
gradlew
vendored
Executable 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
84
gradlew.bat
vendored
Normal 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
|
@ -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
@ -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
|
@ -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
|
@ -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
2
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'kademliadht'
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -11,27 +11,26 @@ import java.net.InetAddress;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.dht.DHT;
|
||||
import kademlia.dht.KadContent;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.message.MessageFactory;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.node.KademliaId;
|
||||
import kademlia.operation.ConnectOperation;
|
||||
import kademlia.operation.ContentLookupOperation;
|
||||
import kademlia.operation.Operation;
|
||||
import kademlia.operation.KadRefreshOperation;
|
||||
import kademlia.operation.StoreOperation;
|
||||
import kademlia.routing.JKademliaRoutingTable;
|
||||
import kademlia.routing.KademliaRoutingTable;
|
||||
import kademlia.util.serializer.JsonDHTSerializer;
|
||||
import kademlia.util.serializer.JsonRoutingTableSerializer;
|
||||
import kademlia.util.serializer.JsonSerializer;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.dht.DHT;
|
||||
import io.github.chronosx88.kademliadht.dht.KadContent;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.message.MessageFactory;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.operation.ConnectOperation;
|
||||
import io.github.chronosx88.kademliadht.operation.ContentLookupOperation;
|
||||
import io.github.chronosx88.kademliadht.operation.Operation;
|
||||
import io.github.chronosx88.kademliadht.operation.KadRefreshOperation;
|
||||
import io.github.chronosx88.kademliadht.operation.StoreOperation;
|
||||
import io.github.chronosx88.kademliadht.routing.JKademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonDHTSerializer;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonRoutingTableSerializer;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws java.io.FileNotFoundException
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws 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
|
||||
*
|
||||
* @throws java.io.FileNotFoundException
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public static JKademliaNode loadFromFile(String ownerId, KadConfiguration iconfig) throws FileNotFoundException, IOException, ClassNotFoundException
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
/**
|
||||
* Interface that defines a KadConfiguration object
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -13,12 +13,11 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import kademlia.exceptions.KadServerDownException;
|
||||
import kademlia.message.KademliaMessageFactory;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.message.MessageFactory;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.message.Receiver;
|
||||
import io.github.chronosx88.kademliadht.exceptions.KadServerDownException;
|
||||
import io.github.chronosx88.kademliadht.message.KademliaMessageFactory;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.message.Receiver;
|
||||
|
||||
/**
|
||||
* The server that handles sending and receiving messages between nodes on the Kad Network
|
||||
@ -66,7 +65,7 @@ public class KadServer
|
||||
* @param config
|
||||
* @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
|
||||
{
|
||||
@ -105,7 +104,7 @@ public class KadServer
|
||||
* @return Integer The communication ID of this message
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws kademlia.exceptions.KadServerDownException
|
||||
* @throws 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 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
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
/**
|
||||
* Specification for class that keeps statistics for a Kademlia instance.
|
@ -1,16 +1,15 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.NoSuchElementException;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.dht.KadContent;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.routing.KademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.dht.KadContent;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void putLocally(KadContent content) throws IOException;
|
||||
|
||||
@ -105,15 +104,15 @@ public interface KademliaNode
|
||||
*
|
||||
* @return DHTContent The content
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws kademlia.exceptions.ContentNotFoundException
|
||||
* @throws IOException
|
||||
* @throws 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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void refresh() throws IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia;
|
||||
package io.github.chronosx88.kademliadht;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia.dht;
|
||||
package io.github.chronosx88.kademliadht.dht;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -9,12 +9,12 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.exceptions.ContentExistException;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import kademlia.util.serializer.JsonSerializer;
|
||||
import kademlia.util.serializer.KadSerializer;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentExistException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.KadSerializer;
|
||||
|
||||
/**
|
||||
* The main Distributed Hash Table class that manages the entire DHT
|
@ -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
|
@ -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
|
@ -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
|
@ -1,13 +1,13 @@
|
||||
package kademlia.dht;
|
||||
package io.github.chronosx88.kademliadht.dht;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import kademlia.util.serializer.KadSerializer;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.KadSerializer;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public boolean store(JKademliaStorageEntry content) throws IOException;
|
||||
|
||||
@ -58,8 +58,8 @@ public interface KademliaDHT
|
||||
*
|
||||
* @return A KadContent object
|
||||
*
|
||||
* @throws java.io.FileNotFoundException
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public JKademliaStorageEntry retrieve(KademliaId key, int hashCode) throws FileNotFoundException, IOException, ClassNotFoundException;
|
||||
|
||||
@ -79,7 +79,7 @@ public interface KademliaDHT
|
||||
*
|
||||
* @return KadContent The content object
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public JKademliaStorageEntry get(GetParameter param) throws NoSuchElementException, IOException;
|
||||
|
||||
@ -100,7 +100,7 @@ public interface KademliaDHT
|
||||
* @param content The Content to Remove
|
||||
*
|
||||
*
|
||||
* @throws kademlia.exceptions.ContentNotFoundException
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
public void remove(KadContent content) throws ContentNotFoundException;
|
||||
|
@ -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
|
@ -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
|
@ -1,7 +1,7 @@
|
||||
package kademlia.dht;
|
||||
package io.github.chronosx88.kademliadht.dht;
|
||||
|
||||
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
|
@ -1,13 +1,13 @@
|
||||
package kademlia.dht;
|
||||
package io.github.chronosx88.kademliadht.dht;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import kademlia.exceptions.ContentExistException;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentExistException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* It would be infeasible to keep all content in memory to be send when requested
|
@ -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
|
@ -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
|
@ -1,4 +1,4 @@
|
||||
package kademlia.exceptions;
|
||||
package io.github.chronosx88.kademliadht.exceptions;
|
||||
|
||||
/**
|
||||
* An exception to be thrown whenever the Kad Server is down
|
@ -1,4 +1,4 @@
|
||||
package kademlia.exceptions;
|
||||
package io.github.chronosx88.kademliadht.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -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
|
@ -1,9 +1,9 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
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.
|
@ -1,9 +1,9 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
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.
|
@ -1,8 +1,8 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
|
||||
/**
|
||||
* Receives a ConnectMessage and sends an AcknowledgeMessage as reply.
|
||||
@ -27,7 +27,7 @@ public class ConnectReceiver implements Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void receive(Message incoming, int comm) throws IOException
|
||||
@ -49,7 +49,7 @@ public class ConnectReceiver implements Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void timeout(int comm) throws IOException
|
@ -1,11 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.util.serializer.JsonSerializer;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
|
||||
|
||||
/**
|
||||
* Messages used to send to another node requesting content.
|
@ -1,11 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.NoSuchElementException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
|
||||
/**
|
||||
* Responds to a ContentLookupMessage by sending a ContentMessage containing the requested content;
|
@ -1,12 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.util.serializer.JsonSerializer;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
|
||||
|
||||
/**
|
||||
* A Message used to send content between nodes
|
@ -1,8 +1,8 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
|
||||
/**
|
||||
* A factory that handles creating messages and receivers
|
||||
@ -21,7 +21,7 @@ public interface KademliaMessageFactory
|
||||
*
|
||||
* @return A message
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public Message createMessage(byte code, DataInputStream in) throws IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
public interface Message extends Streamable
|
||||
{
|
@ -1,11 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
|
||||
/**
|
||||
* Handles creating messages and receivers
|
@ -1,10 +1,10 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
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.
|
@ -1,11 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
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.
|
||||
@ -33,7 +33,7 @@ public class NodeLookupReceiver implements Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void receive(Message incoming, int comm) throws IOException
|
||||
@ -63,7 +63,7 @@ public class NodeLookupReceiver implements Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void timeout(int comm) throws IOException
|
@ -1,11 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
/**
|
||||
* A message used to connect nodes.
|
@ -1,4 +1,4 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -17,7 +17,7 @@ public interface Receiver
|
||||
* @param conversationId The ID of this conversation, used for further conversations
|
||||
* @param incoming The incoming
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void receive(Message incoming, int conversationId) throws IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
@ -1,4 +1,4 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,12 +1,11 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.util.serializer.JsonSerializer;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.util.serializer.JsonSerializer;
|
||||
|
||||
/**
|
||||
* A StoreContentMessage used to send a store message to a node
|
@ -1,9 +1,9 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
|
||||
/**
|
||||
* Receiver for incoming StoreContentMessage
|
@ -1,4 +1,4 @@
|
||||
package kademlia.message;
|
||||
package io.github.chronosx88.kademliadht.message;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -27,7 +27,7 @@ public interface Streamable
|
||||
*
|
||||
* @param out
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void toStream(DataOutputStream out) throws IOException;
|
||||
|
||||
@ -36,7 +36,7 @@ public interface Streamable
|
||||
*
|
||||
* @param out
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void fromStream(DataInputStream out) throws IOException;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* @created 20140215
|
||||
* @desc Represents a Kademlia Node ID
|
||||
*/
|
||||
package kademlia.node;
|
||||
package io.github.chronosx88.kademliadht.node;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -13,7 +13,9 @@ import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
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
|
||||
{
|
||||
@ -28,7 +30,7 @@ public class KademliaId implements Streamable, Serializable
|
||||
*/
|
||||
public KademliaId(String data)
|
||||
{
|
||||
keyBytes = data.getBytes();
|
||||
keyBytes = DatatypeConverter.parseHexBinary(data);
|
||||
if (keyBytes.length != ID_LENGTH / 8)
|
||||
{
|
||||
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()
|
||||
{
|
||||
/* Returns the hex format of this NodeId */
|
||||
BigInteger bi = new BigInteger(1, this.keyBytes);
|
||||
return String.format("%0" + (this.keyBytes.length << 1) + "X", bi);
|
||||
return DatatypeConverter.printHexBinary(this.keyBytes);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package kademlia.node;
|
||||
package io.github.chronosx88.kademliadht.node;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Comparator;
|
@ -1,4 +1,4 @@
|
||||
package kademlia.node;
|
||||
package io.github.chronosx88.kademliadht.node;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -6,7 +6,7 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
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.
|
@ -1,10 +1,10 @@
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
* This will find the K-Closest nodes to that ID, and update the necessary K-Bucket
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void execute() throws IOException
|
@ -3,19 +3,19 @@
|
||||
* @created 20140218
|
||||
* @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 kademlia.JKademliaNode;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.message.AcknowledgeMessage;
|
||||
import kademlia.message.ConnectMessage;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.node.Node;
|
||||
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.message.AcknowledgeMessage;
|
||||
import io.github.chronosx88.kademliadht.message.ConnectMessage;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
public class ConnectOperation implements Operation, Receiver
|
||||
{
|
||||
@ -122,7 +122,7 @@ public class ConnectOperation implements Operation, Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void timeout(int comm) throws IOException
|
@ -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.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -10,22 +10,21 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.exceptions.UnknownMessageException;
|
||||
import kademlia.message.ContentLookupMessage;
|
||||
import kademlia.message.ContentMessage;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.message.NodeReplyMessage;
|
||||
import kademlia.node.KeyComparator;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.util.RouteLengthChecker;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.UnknownMessageException;
|
||||
import io.github.chronosx88.kademliadht.message.ContentLookupMessage;
|
||||
import io.github.chronosx88.kademliadht.message.ContentMessage;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.message.NodeReplyMessage;
|
||||
import io.github.chronosx88.kademliadht.node.KeyComparator;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.util.RouteLengthChecker;
|
||||
|
||||
/**
|
||||
* 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 kademlia.exceptions.RoutingException
|
||||
* @throws IOException
|
||||
* @throws RoutingException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void execute() throws IOException, RoutingException
|
||||
@ -287,7 +286,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
*
|
||||
* @throws kademlia.exceptions.ContentNotFoundException
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
public JKademliaStorageEntry getContentFound() throws ContentNotFoundException
|
||||
{
|
@ -1,17 +1,16 @@
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import kademlia.dht.KademliaStorageEntryMetadata;
|
||||
import kademlia.dht.StorageEntryMetadata;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.message.StoreContentMessage;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntryMetadata;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.message.StoreContentMessage;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws IOException
|
@ -1,10 +1,10 @@
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
|
||||
/**
|
||||
* An operation that handles refreshing the entire Kademlia Systems including buckets and content
|
@ -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.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@ -8,16 +8,16 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.message.NodeLookupMessage;
|
||||
import kademlia.message.NodeReplyMessage;
|
||||
import kademlia.node.KeyComparator;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.message.NodeLookupMessage;
|
||||
import io.github.chronosx88.kademliadht.message.NodeReplyMessage;
|
||||
import io.github.chronosx88.kademliadht.node.KeyComparator;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Finds the K closest nodes to a specified identifier
|
||||
@ -77,8 +77,8 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.io.IOException
|
||||
* @throws kademlia.exceptions.RoutingException
|
||||
* @throws IOException
|
||||
* @throws RoutingException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void execute() throws IOException, RoutingException
|
||||
@ -252,7 +252,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void receive(Message incoming, int comm) throws IOException
|
||||
@ -285,7 +285,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
*
|
||||
* @param comm
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public synchronized void timeout(int comm) throws IOException
|
@ -1,7 +1,7 @@
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
|
||||
/**
|
||||
* An operation in the Kademlia routing protocol
|
||||
@ -15,7 +15,7 @@ public interface Operation
|
||||
/**
|
||||
* Starts an operation and returns when the operation is finished
|
||||
*
|
||||
* @throws kademlia.exceptions.RoutingException
|
||||
* @throws RoutingException
|
||||
*/
|
||||
public void execute() throws IOException, RoutingException;
|
||||
}
|
@ -5,12 +5,12 @@
|
||||
* @author Joshua Kissoon
|
||||
* @since 20140218
|
||||
*/
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.exceptions.RoutingException;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
public class PingOperation implements Operation
|
||||
{
|
@ -1,16 +1,15 @@
|
||||
package kademlia.operation;
|
||||
package io.github.chronosx88.kademliadht.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.KadServer;
|
||||
import kademlia.KademliaNode;
|
||||
import kademlia.dht.JKademliaStorageEntry;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.message.Message;
|
||||
import kademlia.message.StoreContentMessage;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.KadServer;
|
||||
import io.github.chronosx88.kademliadht.KademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.JKademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.message.Message;
|
||||
import io.github.chronosx88.kademliadht.message.StoreContentMessage;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
/**
|
||||
* Operation that stores a DHT Content onto the K closest nodes to the content Key
|
@ -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.
|
@ -1,4 +1,4 @@
|
||||
package kademlia.routing;
|
||||
package io.github.chronosx88.kademliadht.routing;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package kademlia.routing;
|
||||
package io.github.chronosx88.kademliadht.routing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.TreeSet;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.node.Node;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
|
||||
/**
|
||||
* A bucket in the Kademlia routing table
|
@ -1,12 +1,12 @@
|
||||
package kademlia.routing;
|
||||
package io.github.chronosx88.kademliadht.routing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.node.KeyComparator;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.node.KeyComparator;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Implementation of a Kademlia routing table
|
@ -1,7 +1,7 @@
|
||||
package kademlia.routing;
|
||||
package io.github.chronosx88.kademliadht.routing;
|
||||
|
||||
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.
|
@ -1,9 +1,9 @@
|
||||
package kademlia.routing;
|
||||
package io.github.chronosx88.kademliadht.routing;
|
||||
|
||||
import java.util.List;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.node.Node;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.node.Node;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Specification for Kademlia's Routing Table
|
@ -1,11 +1,11 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import kademlia.DefaultConfiguration;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.DefaultConfiguration;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing the Kademlia Auto Content and Node table refresh operations
|
@ -1,11 +1,11 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import kademlia.DefaultConfiguration;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.DefaultConfiguration;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing the Kademlia Auto Content and Node table refresh operations
|
@ -1,12 +1,12 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing sending and receiving content between 2 Nodes on a network
|
@ -1,11 +1,11 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing sending and receiving content between 2 Nodes on a network
|
@ -1,8 +1,8 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import kademlia.dht.KadContent;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.dht.KadContent;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* A simple DHT Content object to test DHT storage
|
@ -1,8 +1,8 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing connecting 2 nodes to each other
|
@ -1,11 +1,11 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.exceptions.ContentNotFoundException;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.exceptions.ContentNotFoundException;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing sending and receiving content between 2 Nodes on a network
|
@ -1,8 +1,8 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.node.KademliaId;
|
||||
import kademlia.routing.KademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
|
||||
|
||||
/**
|
||||
* Testing how the routing table works and checking if everything works properly
|
@ -1,10 +1,10 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.KadContent;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.KadContent;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing how the routing table works and it's state after different operations
|
@ -1,7 +1,7 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing the save and retrieve state operations
|
@ -1,9 +1,9 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.dht.GetParameter;
|
||||
import kademlia.dht.KademliaStorageEntry;
|
||||
import kademlia.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.dht.GetParameter;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntry;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
|
||||
/**
|
||||
* Testing the save and retrieve state operations.
|
@ -1,10 +1,10 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.JKademliaNode;
|
||||
import kademlia.message.SimpleMessage;
|
||||
import kademlia.node.KademliaId;
|
||||
import kademlia.message.SimpleReceiver;
|
||||
import io.github.chronosx88.kademliadht.JKademliaNode;
|
||||
import io.github.chronosx88.kademliadht.message.SimpleMessage;
|
||||
import io.github.chronosx88.kademliadht.node.KademliaId;
|
||||
import io.github.chronosx88.kademliadht.message.SimpleReceiver;
|
||||
|
||||
/**
|
||||
* Test 1: Try sending a simple message between nodes
|
@ -1,4 +1,4 @@
|
||||
package kademlia.simulations;
|
||||
package io.github.chronosx88.kademliadht.simulations;
|
||||
|
||||
/**
|
||||
* A class that specifies the structure for simulations.
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util;
|
||||
package io.github.chronosx88.kademliadht.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@ -19,7 +19,7 @@ public class HashCalculator
|
||||
*
|
||||
* @return byte[20] The hashed string
|
||||
*
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static byte[] sha1Hash(String toHash) throws NoSuchAlgorithmException
|
||||
{
|
||||
@ -41,7 +41,7 @@ public class HashCalculator
|
||||
*
|
||||
* @return byte[20] The hashed string
|
||||
*
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @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
|
||||
*
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static byte[] md5Hash(String toHash) throws NoSuchAlgorithmException
|
||||
{
|
||||
@ -84,7 +84,7 @@ public class HashCalculator
|
||||
*
|
||||
* @return byte[16] The hashed string
|
||||
*
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static byte[] md5Hash(String toHash, String salt) throws NoSuchAlgorithmException
|
||||
{
|
@ -1,8 +1,8 @@
|
||||
package kademlia.util;
|
||||
package io.github.chronosx88.kademliadht.util;
|
||||
|
||||
import java.util.Collection;
|
||||
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.
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util.serializer;
|
||||
package io.github.chronosx88.kademliadht.util.serializer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -11,9 +11,9 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import kademlia.dht.DHT;
|
||||
import kademlia.dht.KademliaDHT;
|
||||
import kademlia.dht.KademliaStorageEntryMetadata;
|
||||
import io.github.chronosx88.kademliadht.dht.DHT;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaDHT;
|
||||
import io.github.chronosx88.kademliadht.dht.KademliaStorageEntryMetadata;
|
||||
|
||||
/**
|
||||
* A KadSerializer that serializes DHT to JSON format
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util.serializer;
|
||||
package io.github.chronosx88.kademliadht.util.serializer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -9,12 +9,12 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import kademlia.routing.JKademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.routing.JKademliaRoutingTable;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import kademlia.KadConfiguration;
|
||||
import kademlia.routing.Contact;
|
||||
import kademlia.routing.KademliaRoutingTable;
|
||||
import io.github.chronosx88.kademliadht.KadConfiguration;
|
||||
import io.github.chronosx88.kademliadht.routing.Contact;
|
||||
import io.github.chronosx88.kademliadht.routing.KademliaRoutingTable;
|
||||
|
||||
/**
|
||||
* A KadSerializer that serializes routing tables to JSON format
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util.serializer;
|
||||
package io.github.chronosx88.kademliadht.util.serializer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.stream.JsonReader;
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util.serializer;
|
||||
package io.github.chronosx88.kademliadht.util.serializer;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -23,7 +23,7 @@ public interface KadSerializer<T>
|
||||
* @param data The data to write
|
||||
* @param out The output Stream to write to
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public T read(DataInputStream in) throws IOException, ClassNotFoundException;
|
||||
}
|
Loading…
Reference in New Issue
Block a user