diff rep/SessionManagerList.java @ 356:b18c24dcc5d2

Before chaning put/join scheme for ditributed select.
author kono
date Sat, 18 Oct 2008 19:01:40 +0900
parents 98607350f7d1
children b25f832f875d
line wrap: on
line diff
--- a/rep/SessionManagerList.java	Fri Oct 17 22:11:34 2008 +0900
+++ b/rep/SessionManagerList.java	Sat Oct 18 19:01:40 2008 +0900
@@ -1,18 +1,18 @@
 package rep;
 
 import java.util.LinkedList;
-import rep.channel.REPSocketChannel;
+
+public class SessionManagerList extends LinkedList<Forwarder>{
 
-public class SessionManagerList {
-
-	private LinkedList<Forwarder> list = new LinkedList<Forwarder>();
-	private int mySMID;
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private int mySMID=0;
+	private int smid_root=0;
 	private Forwarder parent=null;
 	private LinkedList<Forwarder> waiting= new LinkedList<Forwarder>();
 
-	public void add(Forwarder channel) {
-		list.add(channel);
-	}
 
 	public void setMaster(Forwarder f) {
 		this.parent = f;
@@ -23,7 +23,7 @@
 	}
 
 	public void sendToSlaves(REPCommand repCmd) {
-		for(Forwarder channel : list){
+		for(Forwarder channel : this){
 			channel.send(repCmd);
 		}
 	}
@@ -33,19 +33,13 @@
 	}
 
 	public int addNewSessionManager(Forwarder fw,REPCommand receivedCommand) {
-		list.add(fw);
-		int sid = list.size();
+		add(fw);
+		int sid = ++smid_root;
 		fw.setSID(sid);
 		fw.setName(receivedCommand.string);
 		return sid;
 	}
 
-	public boolean isSessionManagerChannel(REPSocketChannel<REPCommand> channel) {
-		for(Forwarder f : list){
-			if (f.channel==channel) return true;
-		}
-		return false;
-	}
 
 	public void setSessionManagerID(int sid) {
 		mySMID = sid;
@@ -67,7 +61,7 @@
 		Forwarder waiter;
 		if ((waiter=waiting.poll())!=null) {
 			waiter.setSID(sid);
-			list.add(waiter);
+			add(waiter);
 			return;
 		}
 		assert false;