annotate src/fdl/AcceptHandler.java @ 110:8ae522e1a4bf

add jar (junit and protobuf)
author kazz
date Wed, 04 Aug 2010 21:41:39 +0900
parents 9cdc24bae625
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
1
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
2 package fdl;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
3 import java.io.IOException;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
4 import java.nio.channels.ClosedChannelException;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
5 import java.nio.channels.SelectionKey;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
6 import java.nio.channels.ServerSocketChannel;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
7 import java.nio.channels.SocketChannel;
40
046feb56a196 message logging
kono
parents: 35
diff changeset
8 import java.util.logging.Level;
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
9
17
609b288f47f9 *** empty log message ***
kono
parents: 16
diff changeset
10 public class AcceptHandler implements TupleHandler {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
11
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
12 public TupleSpace tupleSpace;
35
fe338d497c72 FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents: 22
diff changeset
13 public ServerSocketChannel ss;
40
046feb56a196 message logging
kono
parents: 35
diff changeset
14 private FDLindaServ fds;
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
15
40
046feb56a196 message logging
kono
parents: 35
diff changeset
16 public AcceptHandler(FDLindaServ fds,ServerSocketChannel ss, TupleSpace tupleSpace) {
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
17 // 読みこんだデータを格納するためのリストの初期化
35
fe338d497c72 FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents: 22
diff changeset
18 this.tupleSpace = tupleSpace;
fe338d497c72 FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents: 22
diff changeset
19 this.ss = ss;
40
046feb56a196 message logging
kono
parents: 35
diff changeset
20 this.fds = fds;
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
21 }
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
22
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
23 public void handle(SelectionKey key)
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
24 throws ClosedChannelException, IOException {
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
25 ServerSocketChannel serverChannel
40
046feb56a196 message logging
kono
parents: 35
diff changeset
26 = (ServerSocketChannel)key.channel();
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
27
35
fe338d497c72 FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents: 22
diff changeset
28 if (ss!=serverChannel) {
40
046feb56a196 message logging
kono
parents: 35
diff changeset
29 fds.log(Level.SEVERE,"Wrong server socket channel.");
35
fe338d497c72 FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents: 22
diff changeset
30 }
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
31 // アクセプト処理
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
32 SocketChannel channel = serverChannel.accept();
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
33 channel.configureBlocking(false);
90
9cdc24bae625 ring test
one
parents: 77
diff changeset
34 //channel.socket().setTcpNoDelay(true);
40
046feb56a196 message logging
kono
parents: 35
diff changeset
35 fds.log(Level.INFO,"Server: accepted "+channel.socket());
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
36
77
5336bafaaf48 added test.topology
one
parents: 40
diff changeset
37 // TCP N Delay を ServerSocketChannel のオプションに指定する
5336bafaaf48 added test.topology
one
parents: 40
diff changeset
38 // setTcpNoDelay(boolean on)
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
39 tupleSpace.newUser();
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
40
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
41 // 入出力用のハンドラを生成し,アタッチする
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
42 // 監視する操作は読み込みのみ
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
43 channel.register(key.selector(),
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
44 SelectionKey.OP_READ,
40
046feb56a196 message logging
kono
parents: 35
diff changeset
45 new IOHandler(fds, tupleSpace,channel));
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
46 }
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
47
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
48 }