Package edu.jas.util
Class DistributedList
- java.lang.Object
-
- edu.jas.util.DistributedList
-
public class DistributedList extends java.lang.Object
Distributed version of a List. Implemented with a SortedMap / TreeMap to keep the sequence order of elements.- Author:
- Heinz Kredel
-
-
Field Summary
Fields Modifier and Type Field Description protected ChannelFactory
cf
protected SocketChannel
channel
protected edu.jas.util.Listener
listener
protected java.util.SortedMap<edu.jas.util.Counter,java.lang.Object>
theList
-
Constructor Summary
Constructors Constructor Description DistributedList(ChannelFactory cf, java.lang.String host, int port)
Constructor for DistributedList.DistributedList(SocketChannel sc)
Constructor for DistributedList.DistributedList(java.lang.String host)
Constructor for DistributedList.DistributedList(java.lang.String host, int port)
Constructor for DistributedList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.Object o)
Add object to the list and distribute to other lists.void
clear()
Clear the List.java.util.List<java.lang.Object>
getList()
Get the internal list, convert from Collection.void
init()
List thread initialization and start.boolean
isEmpty()
Is the List empty?java.util.Iterator
iterator()
List iterator.int
size()
Size of the (local) list.void
terminate()
Terminate the list thread.
-
-
-
Field Detail
-
theList
protected final java.util.SortedMap<edu.jas.util.Counter,java.lang.Object> theList
-
cf
protected final ChannelFactory cf
-
channel
protected SocketChannel channel
-
listener
protected edu.jas.util.Listener listener
-
-
Constructor Detail
-
DistributedList
public DistributedList(java.lang.String host)
Constructor for DistributedList.- Parameters:
host
- name or IP of server host.
-
DistributedList
public DistributedList(java.lang.String host, int port)
Constructor for DistributedList.- Parameters:
host
- name or IP of server host.port
- of server.
-
DistributedList
public DistributedList(ChannelFactory cf, java.lang.String host, int port)
Constructor for DistributedList.- Parameters:
cf
- ChannelFactory to use.host
- name or IP of server host.port
- of server.
-
DistributedList
public DistributedList(SocketChannel sc)
Constructor for DistributedList.- Parameters:
sc
- SocketChannel to use.
-
-
Method Detail
-
init
public void init()
List thread initialization and start.
-
terminate
public void terminate()
Terminate the list thread.
-
getList
public java.util.List<java.lang.Object> getList()
Get the internal list, convert from Collection.
-
size
public int size()
Size of the (local) list.
-
add
public void add(java.lang.Object o)
Add object to the list and distribute to other lists. Blocks until the object is send and received from the server (actually it blocks until some object is received).- Parameters:
o
-
-
clear
public void clear()
Clear the List. caveat: must be called on all clients.
-
isEmpty
public boolean isEmpty()
Is the List empty?
-
iterator
public java.util.Iterator iterator()
List iterator.
-
-