Package edu.jas.util
Class DistHashTableMPJ<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- edu.jas.util.DistHashTableMPJ<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class DistHashTableMPJ<K,V> extends java.util.AbstractMap<K,V>
Distributed version of a HashTable using MPI. Implemented with a SortedMap / TreeMap to keep the sequence order of elements. Implemented using MPI transport or TCP transport.- Author:
- Heinz Kredel
-
-
Field Summary
Fields Modifier and Type Field Description static intDHTTAGMessage tag for DHT communicaton.protected mpi.Commengineprotected DHTMPJListener<K,V>listenerprotected java.util.SortedMap<K,V>theList(package private) static booleanuseTCPTransport layer. true: use TCP/IP socket layer, false: use MPI transport layer.
-
Constructor Summary
Constructors Constructor Description DistHashTableMPJ()DistHashTableMPJ.DistHashTableMPJ(java.lang.String[] args)DistHashTableMPJ.DistHashTableMPJ(mpi.Comm cm)DistHashTableMPJ.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the List.booleancontainsKey(java.lang.Object o)Contains key.booleancontainsValue(java.lang.Object o)Contains value.java.util.Set<java.util.Map.Entry<K,V>>entrySet()Get the entries as Set.booleanequals(java.lang.Object o)Equals.Vget(java.lang.Object key)Get value under key from DHT.java.util.SortedMap<K,V>getList()Get the internal sorted map.java.util.List<V>getValueList()Get the internal list, convert from Collection.VgetWait(K key)Get value under key from DHT.inthashCode()Hash code.voidinit()Initialize and start the list thread.booleanisEmpty()Is the List empty?java.util.Iterator<K>iterator()List key iterator.java.util.Set<K>keySet()Get the keys as set.Vput(K key, V value)Put object to the distributed hash table.voidputWait(K key, V value)Put object to the distributed hash table.intsize()Size of the (local) list.voidterminate()Terminate the list thread.java.util.Iterator<V>valueIterator()List value iterator.java.util.Collection<V>values()Get the values as Collection.
-
-
-
Field Detail
-
listener
protected DHTMPJListener<K,V> listener
-
engine
protected final mpi.Comm engine
-
DHTTAG
public static final int DHTTAG
Message tag for DHT communicaton.- See Also:
- Constant Field Values
-
useTCP
static final boolean useTCP
Transport layer. true: use TCP/IP socket layer, false: use MPI transport layer.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DistHashTableMPJ
public DistHashTableMPJ() throws java.io.IOException
DistHashTableMPJ.- Throws:
java.io.IOException
-
DistHashTableMPJ
public DistHashTableMPJ(java.lang.String[] args) throws java.io.IOException
DistHashTableMPJ.- Parameters:
args- command line for MPJ runtime system.- Throws:
java.io.IOException
-
DistHashTableMPJ
public DistHashTableMPJ(mpi.Comm cm) throws java.io.IOException
DistHashTableMPJ.- Parameters:
cm- MPJ communicator to use.- Throws:
java.io.IOException
-
-
Method Detail
-
hashCode
public int hashCode()
Hash code.
-
equals
public boolean equals(java.lang.Object o)
Equals.
-
containsKey
public boolean containsKey(java.lang.Object o)
Contains key.
-
containsValue
public boolean containsValue(java.lang.Object o)
Contains value.
-
getValueList
public java.util.List<V> getValueList()
Get the internal list, convert from Collection.
-
getList
public java.util.SortedMap<K,V> getList()
Get the internal sorted map. For synchronization purpose in normalform.
-
size
public int size()
Size of the (local) list.
-
isEmpty
public boolean isEmpty()
Is the List empty?
-
valueIterator
public java.util.Iterator<V> valueIterator()
List value iterator.
-
putWait
public void putWait(K key, V value)
Put object to the distributed hash table. Blocks until the key value pair is send and received from the server.- Parameters:
key-value-
-
put
public V put(K key, V value)
Put object to the distributed hash table. Returns immediately after sending does not block.
-
getWait
public V getWait(K 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).- Parameters:
key-- Returns:
- the value stored under the key.
-
get
public V 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.
-
init
public void init()
Initialize and start the list thread.
-
terminate
public void terminate()
Terminate the list thread.
-
-