Mercurial > hg > RemoteEditor > REPSessionManager
view 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 source
package rep; import java.util.LinkedList; public class SessionManagerList extends LinkedList<Forwarder>{ /** * */ 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 setMaster(Forwarder f) { this.parent = f; } public void sendToMaster(REPCommand repCmd) { parent.send(repCmd); } public void sendToSlaves(REPCommand repCmd) { for(Forwarder channel : this){ channel.send(repCmd); } } public boolean isMaster() { return parent==null; } public int addNewSessionManager(Forwarder fw,REPCommand receivedCommand) { add(fw); int sid = ++smid_root; fw.setSID(sid); fw.setName(receivedCommand.string); return sid; } public void setSessionManagerID(int sid) { mySMID = sid; } public int sessionManagerID() { return mySMID; } public void addWaitingSessionManager(Forwarder fw, REPCommand command) { // SID assign 待ちのSessionManager Channelを登録する waiting.add(fw); } public void assignSessionManagerIDtoWaitingSM(int sid) { // 待っていたSession Manager ChannelにSession IDを登録し,Session Manager List // に登録する。この次のsm_join_ackでSIDが確定する。 Forwarder waiter; if ((waiter=waiting.poll())!=null) { waiter.setSID(sid); add(waiter); return; } assert false; } }