package edu.mit.streamjit.impl.distributed.runtimer;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import edu.mit.streamjit.impl.distributed.api.NodeInfo;
import edu.mit.streamjit.impl.distributed.node.Connection;

/**
 * {@link CommunicationManager} manages all type of communications. keep track of all {@link Connection} and manages them. TODO: Need
 * to handle the connection loss and reconnection. Assigns machineID based on the connecting order.
 * 
 * @author Sumanan sumanan@mit.edu
 * @since May 13, 2013
 */
public interface CommunicationManager {

	public enum CommunicationType {
		TCP, LOCAL, UDP, BUFFER;
	}

	public <T> T readObject(int machineID) throws IOException, ClassNotFoundException;

	public void writeObject(int machineID, Object obj) throws IOException;

	// blocking call
	/**
	 * Makes all connections based on the argument comTypeCount. But only one local connection can be created. So the value for the key
	 * {@link CommunicationType}.LOCAL in the argument comTypeCount has no effect.
	 * 
	 * @param comTypeCount
	 *            Map that tells the number of connections need to be established for each {@link CommunicationType}.
	 * @throws IOException
	 */
	public void connectMachines(Map<CommunicationType, Integer> comTypeCount) throws IOException;

	// non blocking call
	public void connectMachines(long timeOut) throws IOException;

	public void closeAllConnections() throws IOException;

	public void closeConnection(int machineID) throws IOException;

	public boolean isConnected(int machineID);

	/**
	 * MachineID 0 is reserved for controller node.
	 */
	public List<Integer> getConnectedMachineIDs();

}
@@ -319,16 +319,19 @@
 ep track
+%0A *
  of all 
@@ -377,19 +377,16 @@
 DO: Need
-%0A *
  to hand
@@ -387,24 +387,27 @@
 o handle the
+%0A *
  connection 
@@ -470,16 +470,19 @@
 nnecting
+%0A *
  order.%0A
@@ -588,16 +588,83 @@
 ager %7B%0A%0A
+%09/**%0A%09 * The type of communication between two machine nodes.%0A%09 */%0A
 %09public 
@@ -778,17 +778,20 @@
 ception,
- 
+%0A%09%09%09
 ClassNot
@@ -977,16 +977,20 @@
 only one
+%0A%09 *
  local c
@@ -1111,16 +1111,20 @@
 t has no
+%0A%09 *
  effect.
@@ -1219,16 +1219,31 @@
 ed to be
+%0A%09 *           
  establi
@@ -1386,17 +1386,20 @@
 peCount)
- 
+%0A%09%09%09
 throws I

Format changes.