org.kth.dks
Class JDHT

java.lang.Object
  extended by org.kth.dks.JDHT
All Implemented Interfaces:
java.util.Map

public class JDHT
extends java.lang.Object
implements java.util.Map


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
JDHT()
          Creates an empty local Distributed Hash Table (DHT), listening on default port 4440 Other nodes can connect to this DHT using a reference to this instance An IMPORTANT invariant is to call close() upon exit to disconnect.
JDHT(int port)
          Creates an empty local Distributed Hash Table (DHT), listening on default port 4440 Other nodes can connect to this DHT using a reference to this instance An IMPORTANT invariant is to call close() upon exit to disconnect.
JDHT(int port, java.lang.String url)
          Joins an existing Distributed Hash Table (DHT) running on some machines, will bind to the supplied local port number An IMPORTANT invariant is to call close() upon exit to disconnect.
JDHT(java.lang.String url)
          Joins an existing Distributed Hash Table (DHT) running on some machines, will bind to local port 4444 An IMPORTANT invariant is to call close() upon exit to disconnect.
 
Method Summary
 void clear()
          Currently unimplemented, will throw UnsupportedOperationException
 void close()
          Unbinds from the local port and disconnects from the DHT.
 boolean containsKey(java.lang.Object key)
          Returns whether the key exists in the DHT Makes use of hashCode() in key
 boolean containsValue(java.lang.Object value)
          Currently unimplemented, will throw UnsupportedOperationException
 java.util.Set entrySet()
          Currently unimplemented, will throw UnsupportedOperationException
 boolean equals(java.lang.Object o)
          Currently unimplemented, will throw UnsupportedOperationException
 java.lang.Object get(java.lang.Object key)
          Gets the value associated with key in the DHT Makes use of hashCode() in key
 java.lang.String getReference()
          Returns a stringified reference to the current DHT instance.
 boolean isEmpty()
          Currently unimplemented, will throw UnsupportedOperationException
 java.util.Set keySet()
          Currently unimplemented, will throw UnsupportedOperationException
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Inserts an item (key/value pair) into the DHT It requires the value to be serializable, and depends on the hashCode() implementation of key
 void putAll(java.util.Map t)
          Currently unimplemented, will throw UnsupportedOperationException
 java.lang.Object remove(java.lang.Object key)
          Currently unimplemented, will throw UnsupportedOperationException
 int size()
          Currently unimplemented, will throw UnsupportedOperationException
 java.util.Collection values()
          Currently unimplemented, will throw UnsupportedOperationException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
hashCode
 

Constructor Detail

JDHT

public JDHT()
     throws java.io.IOException
Creates an empty local Distributed Hash Table (DHT), listening on default port 4440 Other nodes can connect to this DHT using a reference to this instance An IMPORTANT invariant is to call close() upon exit to disconnect.

Throws:
java.io.IOException - thrown if it cannot bind to the local port
See Also:
close(), getReference()

JDHT

public JDHT(int port)
     throws java.io.IOException
Creates an empty local Distributed Hash Table (DHT), listening on default port 4440 Other nodes can connect to this DHT using a reference to this instance An IMPORTANT invariant is to call close() upon exit to disconnect.

Parameters:
port - int port number to bind to
Throws:
java.io.IOException - thrown if it cannot bind to the local port
See Also:
close(), getReference()

JDHT

public JDHT(java.lang.String url)
     throws java.io.IOException,
            DKSTooManyRestartJoins,
            DKSIdentifierAlreadyTaken,
            DKSRefNoResponse
Joins an existing Distributed Hash Table (DHT) running on some machines, will bind to local port 4444 An IMPORTANT invariant is to call close() upon exit to disconnect.

Parameters:
url - String reference to an existing node running a DHT
Throws:
java.io.IOException - thrown if there is a problem binding to the local port
DKSTooManyRestartJoins - if it cannot join (see DKS documentation)
DKSIdentifierAlreadyTaken - if the internal DKS identifier is already taken
DKSRefNoResponse - if the existing node (url) does not respond
See Also:
getReference(), close()

JDHT

public JDHT(int port,
            java.lang.String url)
     throws java.io.IOException,
            DKSTooManyRestartJoins,
            DKSIdentifierAlreadyTaken,
            DKSRefNoResponse
Joins an existing Distributed Hash Table (DHT) running on some machines, will bind to the supplied local port number An IMPORTANT invariant is to call close() upon exit to disconnect.

Parameters:
port - int local port number to bind to
url - String reference to an existing node running a DHT
Throws:
java.io.IOException - thrown if there is a problem binding to the local port
DKSTooManyRestartJoins - if it cannot join (see DKS documentation)
DKSIdentifierAlreadyTaken - if the internal DKS identifier is already taken
DKSRefNoResponse - if the existing node (url) does not respond
See Also:
close(), getReference()
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Inserts an item (key/value pair) into the DHT It requires the value to be serializable, and depends on the hashCode() implementation of key

Specified by:
put in interface java.util.Map
Parameters:
key - Object key of the item
value - Object value of the item
Returns:
Object always null

get

public java.lang.Object get(java.lang.Object key)
Gets the value associated with key in the DHT Makes use of hashCode() in key

Specified by:
get in interface java.util.Map
Parameters:
key - Object key of the item
Returns:
Object value associated with key in the DHT, null if none found

getReference

public java.lang.String getReference()
Returns a stringified reference to the current DHT instance. This is used to supply other nodes with a reference, such that they can connect to the running DHT

Returns:
String a string representing this DHT instance (dksref://hostname:port/gid/id/guid/nonce)

close

public void close()
Unbinds from the local port and disconnects from the DHT. Has to be called before exit.


containsKey

public boolean containsKey(java.lang.Object key)
Returns whether the key exists in the DHT Makes use of hashCode() in key

Specified by:
containsKey in interface java.util.Map
Parameters:
key - Object key of the item
Returns:
boolean is true if key exists in DHT, fales otherwise

remove

public java.lang.Object remove(java.lang.Object key)
                        throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
remove in interface java.util.Map
Parameters:
key - Object
Returns:
Object
Throws:
java.lang.UnsupportedOperationException

clear

public void clear()
           throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
clear in interface java.util.Map
Throws:
java.lang.UnsupportedOperationException

containsValue

public boolean containsValue(java.lang.Object value)
                      throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
containsValue in interface java.util.Map
Parameters:
value - Object
Returns:
boolean
Throws:
java.lang.UnsupportedOperationException

entrySet

public java.util.Set entrySet()
                       throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
entrySet in interface java.util.Map
Returns:
Set
Throws:
java.lang.UnsupportedOperationException

equals

public boolean equals(java.lang.Object o)
               throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object
Parameters:
o - Object
Returns:
boolean
Throws:
java.lang.UnsupportedOperationException

isEmpty

public boolean isEmpty()
                throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
isEmpty in interface java.util.Map
Returns:
boolean
Throws:
java.lang.UnsupportedOperationException

keySet

public java.util.Set keySet()
                     throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
keySet in interface java.util.Map
Returns:
Set
Throws:
java.lang.UnsupportedOperationException

putAll

public void putAll(java.util.Map t)
            throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
putAll in interface java.util.Map
Parameters:
t - Map
Throws:
java.lang.UnsupportedOperationException

size

public int size()
         throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
size in interface java.util.Map
Returns:
int
Throws:
java.lang.UnsupportedOperationException

values

public java.util.Collection values()
                            throws java.lang.UnsupportedOperationException
Currently unimplemented, will throw UnsupportedOperationException

Specified by:
values in interface java.util.Map
Returns:
Collection
Throws:
java.lang.UnsupportedOperationException


Copyright © 2010. All Rights Reserved.