edu.jas.util
Class DistHashTable

java.lang.Object
  extended by edu.jas.util.DistHashTable

public class DistHashTable
extends java.lang.Object

Distributed version of a HashTable. Implemented with a SortedMap / TreeMap to keep the sequence order of elements.


Field Summary
protected  edu.unima.ky.parallel.ChannelFactory cf
           
protected  edu.unima.ky.parallel.SocketChannel channel
           
protected  DHTListener listener
           
protected  java.util.SortedMap theList
           
 
Constructor Summary
DistHashTable(edu.unima.ky.parallel.ChannelFactory cf, java.lang.String host, int port)
           
DistHashTable(edu.unima.ky.parallel.SocketChannel sc)
           
DistHashTable(java.lang.String host)
          Constructs a new DistHashTable
DistHashTable(java.lang.String host, int port)
           
 
Method Summary
 void clear()
          Clear the List caveat: must be called on all clients
 java.lang.Object get(java.lang.Object key)
          Get value under key from DHT.
 java.util.ArrayList getArrayList()
          Get the internal list, convert from Collection
 java.lang.Object getWait(java.lang.Object key)
          Get value under key from DHT.
 boolean isEmpty()
          Is the List empty?
 java.util.Iterator iterator()
          List key iterator
 void put(java.lang.Object key, java.lang.Object value)
          Put object to the distributed hash table.
 void putWait(java.lang.Object key, java.lang.Object value)
          Put object to the distributed hash table.
 int size()
          Size of the (local) list
 void terminate()
          Terminate the list thread
 java.util.Iterator valueIterator()
          List value iterator
 java.util.Collection values()
          Get the internal list, do not convert from Collection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theList

protected final java.util.SortedMap theList

cf

protected final edu.unima.ky.parallel.ChannelFactory cf

channel

protected edu.unima.ky.parallel.SocketChannel channel

listener

protected DHTListener listener
Constructor Detail

DistHashTable

public DistHashTable(java.lang.String host)
Constructs a new DistHashTable

Parameters:
host - Name or IP of server host

DistHashTable

public DistHashTable(java.lang.String host,
                     int port)

DistHashTable

public DistHashTable(edu.unima.ky.parallel.ChannelFactory cf,
                     java.lang.String host,
                     int port)

DistHashTable

public DistHashTable(edu.unima.ky.parallel.SocketChannel sc)
Method Detail

values

public java.util.Collection values()
Get the internal list, do not convert from Collection


getArrayList

public java.util.ArrayList getArrayList()
Get the internal list, convert from Collection


size

public int size()
Size of the (local) list


isEmpty

public boolean isEmpty()
Is the List empty?


iterator

public java.util.Iterator iterator()
List key iterator


valueIterator

public java.util.Iterator valueIterator()
List value iterator


putWait

public void putWait(java.lang.Object key,
                    java.lang.Object value)
Put object to the distributed hash table. Blocks until the key value pair is send and received from the server.


put

public void put(java.lang.Object key,
                java.lang.Object value)
Put object to the distributed hash table. Returns immediately after sending does not block.


getWait

public java.lang.Object getWait(java.lang.Object key)
Get value under key from DHT. Blocks until the object is send and received from the server (actually it blocks until some value under key is received).


get

public java.lang.Object get(java.lang.Object key)
Get value under key from DHT. If no value is jet available null is returned.


clear

public void clear()
Clear the List caveat: must be called on all clients


terminate

public void terminate()
Terminate the list thread