Mercurial > hg > FederatedLinda
changeset 77:5336bafaaf48
added test.topology
author | one |
---|---|
date | Mon, 16 Nov 2009 23:44:18 +0900 |
parents | e8b757d7d0af |
children | 4fd2d1094bb9 |
files | src/fdl/AcceptHandler.java src/fdl/test/topology/NodeManager.java src/fdl/test/transfer/cluster/FDLServWithSendMeta.java src/fdl/test/transfer/cluster/MetaProtocolEngine.java |
diffstat | 4 files changed, 62 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fdl/AcceptHandler.java Mon Nov 16 23:16:40 2009 +0900 +++ b/src/fdl/AcceptHandler.java Mon Nov 16 23:44:18 2009 +0900 @@ -33,6 +33,8 @@ channel.configureBlocking(false); fds.log(Level.INFO,"Server: accepted "+channel.socket()); + // TCP N Delay を ServerSocketChannel のオプションに指定する + // setTcpNoDelay(boolean on) tupleSpace.newUser(); // 入出力用のハンドラを生成し,アタッチする
--- a/src/fdl/test/topology/NodeManager.java Mon Nov 16 23:16:40 2009 +0900 +++ b/src/fdl/test/topology/NodeManager.java Mon Nov 16 23:44:18 2009 +0900 @@ -13,9 +13,9 @@ private MetaLinda mLinda; private int port; private int manageId; - public ArrayList<NodeManager> waitingNodes; - public ArrayList<NodeManager> waitedNodes; - public ArrayList<NodeManager> sendNodes; + private ArrayList<NodeManager> waitingNodes; + private ArrayList<NodeManager> waitedNodes; + private ArrayList<NodeManager> sendNodes; public NodeManager(MetaLinda ml, int port, int manageId) { this.port = port;
--- a/src/fdl/test/transfer/cluster/FDLServWithSendMeta.java Mon Nov 16 23:16:40 2009 +0900 +++ b/src/fdl/test/transfer/cluster/FDLServWithSendMeta.java Mon Nov 16 23:44:18 2009 +0900 @@ -39,14 +39,13 @@ txt = args[++k]; ring = Integer.valueOf(txt); } else { - System.err.println("引数指定の誤り:未知の引数が指定されました"); + System.err.println("引数指定の誤り:未知の引数が指定されました"); } } bufsize = Integer.parseInt(bufstring); try { chkhost(); - FDLServWithSendMeta serv; - serv = new FDLServWithSendMeta(localport); + FDLServWithSendMeta serv = new FDLServWithSendMeta(localport); serv.mainLoop(); } catch (IOException e) { e.printStackTrace();
--- a/src/fdl/test/transfer/cluster/MetaProtocolEngine.java Mon Nov 16 23:16:40 2009 +0900 +++ b/src/fdl/test/transfer/cluster/MetaProtocolEngine.java Mon Nov 16 23:44:18 2009 +0900 @@ -14,14 +14,14 @@ public class MetaProtocolEngine implements MetaEngine { private int id = 10; - + private PSXLinda psxget; MetaLinda fdlmeta; String host; int port = 10000; private PSXLinda psxsend; private int chknum; - + SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS"); private int bufsize; @@ -32,7 +32,7 @@ private String txt; private String transfer; private long transferlong; - + public MetaProtocolEngine(MetaLinda ml, String host, int chknum, int bufsize, String txt) { this.host = host; this.fdlmeta = ml; @@ -43,7 +43,7 @@ public void mainLoop(){ psxget = fdlmeta; - if(chknum == 1){ + if (chknum == 1) { try { sendData(); start = DF.format(new Date()); @@ -51,60 +51,60 @@ } catch (IOException e) { e.printStackTrace(); } - } + } boolean connect = true; while(connect){ - try { - initConnect(); - transfer = DF.format(new Date()); - transferlong = new Date().getTime(); - System.out.println("transfer Time => "+transfer); - for(int l=0; l<1000; l++){ - transfer(); + try { + initConnect(); + transfer = DF.format(new Date()); + transferlong = new Date().getTime(); + System.out.println("transfer Time => "+transfer); + for(int l = 0; l < 1000; l++) { + transfer(); + } + dataChk(); + write(); + connect = false; + } catch (IOException e) { + try { + Thread.sleep(40); + } catch (InterruptedException e1) { + } } - dataChk(); - write(); - connect = false; - } catch (IOException e) { - try { - Thread.sleep(40); - } catch (InterruptedException e1) { - } - } } } private void initConnect(){ boolean connectpsx = true; while(connectpsx){ - try { - psxsend = fdlmeta.open(host,port); - connectpsx = false; - } catch (IOException e) { try { - Thread.sleep(40); - } catch (InterruptedException e1) { - e1.printStackTrace(); + psxsend = fdlmeta.open(host, port); + connectpsx = false; + } catch (IOException e) { + try { + Thread.sleep(40); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } } } - } } - + private void sendData() throws IOException{ boolean connectSend = true; ByteBuffer send = ByteBuffer.allocate(bufsize); byte[] fdata = new byte[bufsize]; -// fdata = InetAddress.getLocalHost().getAddress(); + // fdata = InetAddress.getLocalHost().getAddress(); for(int n=0; n < fdata.length; n++ ){ fdata[n] = 1; } send.put(fdata); send.flip(); while(connectSend){ - psxget.out(id, send); - psxget.sync(1); - System.out.println("Send Data"); - connectSend = false; + psxget.out(id, send); + psxget.sync(1); + System.out.println("Send Data"); + connectSend = false; } } @@ -124,35 +124,35 @@ fdlmeta.sync(); } } - + public void dataChk() throws IOException{ fdlmeta.sync(1); boolean running2 = true; -// ByteBuffer data2 = ByteBuffer.allocate(bufsize); + // ByteBuffer data2 = ByteBuffer.allocate(bufsize); PSXReply in2 = psxget.in(id); -// byte[] fdata2 = new byte[bufsize]; -// byte[] fdata3 = new byte[bufsize]; -// fdata = InetAddress.getLocalHost().getAddress(); -// for(int n=0; n < fdata2.length; n++ ){ -// fdata2[n] = 1; -// } + // byte[] fdata2 = new byte[bufsize]; + // byte[] fdata3 = new byte[bufsize]; + // fdata = InetAddress.getLocalHost().getAddress(); + // for(int n=0; n < fdata2.length; n++ ){ + // fdata2[n] = 1; + // } while (running2) { psxget.sync(1); if(in2.ready()) { -// data2 = in2.getData(); -// data2.get(fdata3); -// if (fdata2 == fdata3){ + // data2 = in2.getData(); + // data2.get(fdata3); + // if (fdata2 == fdata3){ time = DF.format(new Date()); timelong = new Date().getTime(); System.out.println("Around Time => "+time); -// } - running2 = false; - break; + // } + running2 = false; + break; } } } - - + + public void write() throws IOException{ long result = (timelong - transferlong); String diff = String.valueOf(result); @@ -160,16 +160,16 @@ read.createNewFile(); FileWriter filewrite = new FileWriter(read); if (start != "null"){ - filewrite.write("ServerStart => "+start+"\r\n"); + filewrite.write("ServerStart => "+start+"\r\n"); } if (transfer != "null") { - filewrite.write("TransferTime => "+transfer+"\r\n"); + filewrite.write("TransferTime => "+transfer+"\r\n"); } if (time != "null"){ - filewrite.write("AroundTime => "+time+"\r\n"); + filewrite.write("AroundTime => "+time+"\r\n"); } if (diff != "null"){ - filewrite.write("DiffTime => "+diff+"\r\n"); + filewrite.write("DiffTime => "+diff+"\r\n"); } filewrite.close(); }