Mercurial > hg > RemoteEditor > REPSessionManager
changeset 218:827c439d0da4
*** empty log message ***
author | pin |
---|---|
date | Sun, 31 Aug 2008 07:53:28 +0900 |
parents | 4deaaaa6354e |
children | 13e0520470dc |
files | rep/REPActionEvent.java rep/RPanel.java rep/handler/REPHandlerImpl.java test/sematest/JoinTester.java test/sematest/PutTester.java test/sematest/TestSessionManager.java test/sematest/Tester.java |
diffstat | 7 files changed, 133 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/REPActionEvent.java Sun Aug 31 00:26:35 2008 +0900 +++ b/rep/REPActionEvent.java Sun Aug 31 07:53:28 2008 +0900 @@ -29,7 +29,6 @@ } public void exec() { - // TODO Auto-generated method stub manager.selectSession(this); }
--- a/rep/RPanel.java Sun Aug 31 00:26:35 2008 +0900 +++ b/rep/RPanel.java Sun Aug 31 07:53:28 2008 +0900 @@ -108,8 +108,10 @@ actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(), (SessionPlus)comboSession.getSelectedItem())); */ - actionListener.selectOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()), - (SessionPlus)s_list.get(session_table.getSelectedRow()), listener)); + //actionListener.selectOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()), + // (SessionPlus)s_list.get(session_table.getSelectedRow()), listener)); + manager.selectOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()), + (SessionPlus)s_list.get(session_table.getSelectedRow()), manager)); } } @@ -166,7 +168,7 @@ } protected void setTableSession(LinkedList<Session> list) { - e_tableModel.setRowCount(0); + s_tableModel.setRowCount(0); for(Session session : list){ setTableSession(session.getSID(), session.getName()); }
--- a/rep/handler/REPHandlerImpl.java Sun Aug 31 00:26:35 2008 +0900 +++ b/rep/handler/REPHandlerImpl.java Sun Aug 31 07:53:28 2008 +0900 @@ -1,6 +1,8 @@ package rep.handler; import java.io.IOException; +import java.nio.channels.SelectableChannel; + import rep.REPCommand; import rep.REPCommandPacker; import rep.SessionManager; @@ -18,7 +20,11 @@ @SuppressWarnings("unchecked") public void handle(REPSelectionKey<REPCommand> key) throws IOException { - REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>) key.accept(new REPCommandPacker()); + SelectableChannel s = key.channel(); + if(!(s instanceof REPSocketChannel) ){ + System.out.println("error"); + } + REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>) key.channel(new REPCommandPacker()); REPCommand command = channel.read(); manager.manage(channel, command);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sematest/JoinTester.java Sun Aug 31 07:53:28 2008 +0900 @@ -0,0 +1,30 @@ +package test.sematest; + +import java.io.IOException; + +import rep.REP; +import rep.REPCommand; +import rep.channel.REPSocketChannel; + +public class JoinTester extends Tester { + + public JoinTester(String name, String _host, int _port) { + super(name, _host, _port); + } + + @Override + public void sendCommand(REPSocketChannel<REPCommand> channel)throws IOException { + REPCommand command = new REPCommand(); + command.setCMD(REP.SMCMD_JOIN); + command.setString("join test"); + channel.write(command); + + channel.read(); + } + + public static void main(String[] args){ + Thread tester = new JoinTester("JoinTester", "localhost", 8766); + tester.start(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sematest/PutTester.java Sun Aug 31 07:53:28 2008 +0900 @@ -0,0 +1,32 @@ +package test.sematest; + +import java.io.IOException; + +import rep.REP; +import rep.REPCommand; +import rep.channel.REPSocketChannel; + +public class PutTester extends Tester { + + public PutTester(String name, String _host, int _port) { + super(name, _host, _port); + } + + @Override + public void sendCommand(REPSocketChannel<REPCommand> channel)throws IOException { + + REPCommand command = new REPCommand(); + command.setCMD(REP.SMCMD_PUT); + command.setString("put test"); + channel.write(command); + + channel.read(); + + } + + public static void main(String[] args){ + Thread tester = new PutTester("PutTester", "localhost", 8766); + tester.start(); + } + +}
--- a/test/sematest/TestSessionManager.java Sun Aug 31 00:26:35 2008 +0900 +++ b/test/sematest/TestSessionManager.java Sun Aug 31 07:53:28 2008 +0900 @@ -19,7 +19,7 @@ } public static void main(String[] args){ - REPServerSocketChannel.isSimulation = true; + REPServerSocketChannel.isSimulation = false; TestSessionManager test = new TestSessionManager(1, 0, 2); logger.setLogLevel(5); test.startTest(); @@ -32,12 +32,12 @@ startSessionManager(strs); - for (int i=0; i<numberEditor; i++){ - logger.writeLog("create Editors", 1); - TestEditor te = new TestEditor("Editor"+i,host, masterPort); - editorList.add(te); - te.start(); - } +// for (int i=0; i<numberEditor; i++){ +// logger.writeLog("create Editors", 1); +// TestEditor te = new TestEditor("Editor"+i,host, masterPort); +// editorList.add(te); +// te.start(); +// } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sematest/Tester.java Sun Aug 31 07:53:28 2008 +0900 @@ -0,0 +1,52 @@ +package test.sematest; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.SocketAddress; + +import rep.REPCommand; +import rep.REPCommandPacker; +import rep.channel.REPLogger; +import rep.channel.REPSocketChannel; +import test.channeltest.StringPacker; + +public abstract class Tester extends Thread{ + private SocketAddress semaIP; + private REPLogger ns; + + public Tester(String name, String _host,int _port){ + super(name); + semaIP = new InetSocketAddress(_host, _port); + ns = REPLogger.singleton(); + ns.setLogLevel(5); + } + + public void run(){ + try { + REPSocketChannel<REPCommand> channel; + channel = REPSocketChannel.<REPCommand>create(new REPCommandPacker()); + channel.configureBlocking(true); + + ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1); + while (!channel.connect(semaIP)){ + ns.writeLog("SeMa not listen to socket yet, wait", 1); + Thread.yield(); + } + ns.writeLog("successes to connect", 1); + + sendCommand(channel); + ns.writeLog("wrote packet", 1); + + REPCommand packet = channel.read(); + + ns.writeLog("gets return string==> `"+packet+"\'", 1); + + ns.writeLog("testEditor exits.", 1); + + channel.close1(); + + } catch (IOException e) {} + } + + public abstract void sendCommand(REPSocketChannel<REPCommand> channel) throws IOException; +}