mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 10:12:19 +00:00
Statistics
- Renamed the statistics class to Statistician since that's is what it is - a statistician that manages the Kad statistics - Passed the statistician to our Server to collect data
This commit is contained in:
parent
7817100253
commit
899390b4a3
@ -67,6 +67,14 @@ public class KademliaNode
|
|||||||
/* Factories */
|
/* Factories */
|
||||||
private final transient MessageFactory messageFactory;
|
private final transient MessageFactory messageFactory;
|
||||||
|
|
||||||
|
/* Statistics */
|
||||||
|
private final Statistician statistician;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
statistician = new Statistician();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Kademlia DistributedMap using the specified name as filename base.
|
* Creates a Kademlia DistributedMap using the specified name as filename base.
|
||||||
* If the id cannot be read from disk the specified defaultId is used.
|
* If the id cannot be read from disk the specified defaultId is used.
|
||||||
@ -93,7 +101,7 @@ public class KademliaNode
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
this.routingTable = routingTable;
|
this.routingTable = routingTable;
|
||||||
this.messageFactory = new MessageFactory(this, this.dht, this.config);
|
this.messageFactory = new MessageFactory(this, this.dht, this.config);
|
||||||
this.server = new KadServer(udpPort, this.messageFactory, this.localNode, this.config);
|
this.server = new KadServer(udpPort, this.messageFactory, this.localNode, this.config, this.statistician);
|
||||||
this.startRefreshOperation();
|
this.startRefreshOperation();
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ package kademlia;
|
|||||||
* @author Joshua Kissoon
|
* @author Joshua Kissoon
|
||||||
* @since 20140505
|
* @since 20140505
|
||||||
*/
|
*/
|
||||||
public class Statistics
|
public class Statistician
|
||||||
{
|
{
|
||||||
|
|
||||||
/* How much data was sent and received by the server over the network */
|
/* How much data was sent and received by the server over the network */
|
@ -13,6 +13,7 @@ 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.Statistician;
|
||||||
import kademlia.exceptions.KadServerDownException;
|
import kademlia.exceptions.KadServerDownException;
|
||||||
import kademlia.message.Message;
|
import kademlia.message.Message;
|
||||||
import kademlia.message.MessageFactory;
|
import kademlia.message.MessageFactory;
|
||||||
@ -46,6 +47,8 @@ public class KadServer
|
|||||||
/* Factories */
|
/* Factories */
|
||||||
private final MessageFactory messageFactory;
|
private final MessageFactory messageFactory;
|
||||||
|
|
||||||
|
private final Statistician statistician;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
@ -61,18 +64,17 @@ public class KadServer
|
|||||||
* @param mFactory Factory used to create messages
|
* @param mFactory Factory used to create messages
|
||||||
* @param localNode Local node on which this server runs on
|
* @param localNode Local node on which this server runs on
|
||||||
* @param config
|
* @param config
|
||||||
|
* @param statistician A statistician to manage the server statistics
|
||||||
*
|
*
|
||||||
* @throws java.net.SocketException
|
* @throws java.net.SocketException
|
||||||
*/
|
*/
|
||||||
public KadServer(int udpPort, MessageFactory mFactory, Node localNode, KadConfiguration config) throws SocketException
|
public KadServer(int udpPort, MessageFactory mFactory, Node localNode, KadConfiguration config, Statistician statistician) throws SocketException
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
this.socket = new DatagramSocket(udpPort);
|
this.socket = new DatagramSocket(udpPort);
|
||||||
|
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
|
||||||
this.messageFactory = mFactory;
|
this.messageFactory = mFactory;
|
||||||
|
this.statistician = statistician;
|
||||||
|
|
||||||
/* Start listening for incoming requests in a new thread */
|
/* Start listening for incoming requests in a new thread */
|
||||||
this.startListener();
|
this.startListener();
|
||||||
|
Loading…
Reference in New Issue
Block a user