Some comments and fixes

This commit is contained in:
Joshua Kissoon 2014-04-02 18:39:16 +05:30
parent 3e236f4d17
commit cc1d03ba81
3 changed files with 23 additions and 9 deletions

View File

@ -1,13 +1,11 @@
package kademlia.dht;
import com.google.gson.Gson;
import kademlia.node.NodeId;
/**
* Any piece of content that needs to be stored on the DHT
*
* @author Joshua Kissoon
* @param <T>
*
* @since 20140224
*/
@ -45,7 +43,23 @@ public interface KadContent
*/
public String getOwnerId();
/**
* Each content needs to be in byte format for transporting and storage,
* this method takes care of that.
*
* Each object is responsible for transforming itself to byte format since the
* structure of methods may differ.
*
* @return byte[] The content in byte format
*/
public byte[] toBytes();
/**
* Given the Content in byte format, read it
*
* @param data The object in byte format
*
* @return A new object from the given byte[]
*/
public KadContent fromBytes(byte[] data);
}

View File

@ -38,7 +38,6 @@ public class ContentSendingTest
*/
System.out.println("Retrieving Content");
GetParameter gp = new GetParameter(c.getKey(), DHTContentImpl.TYPE);
gp.setType(DHTContentImpl.TYPE);
gp.setOwnerId(c.getOwnerId());
System.out.println("Get Parameter: " + gp);
List<StorageEntry> conte = kad2.get(gp, 4);

View File

@ -13,6 +13,8 @@ import kademlia.node.NodeId;
public class DHTContentImpl implements KadContent
{
public static final transient String TYPE = "DHTContentImpl";
private NodeId key;
private String data;
private String ownerId;
@ -76,7 +78,6 @@ public class DHTContentImpl implements KadContent
return this.updateTs;
}
@Override
public byte[] toBytes()
{