annotate src/alice/daemon/AliceDaemon.java @ 22:2ca2d961a8d2

implements outline of TopologyManager
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 00:40:27 +0900
parents e3f1b21718b0
children 3155337e754e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
1 package alice.daemon;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
2
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
3 import java.io.IOException;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
4 import java.net.InetAddress;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
5 import java.net.InetSocketAddress;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
6 import java.net.ServerSocket;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
7 import java.nio.channels.ServerSocketChannel;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
8
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
9 public class AliceDaemon {
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
10
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
11 private Config conf;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
12 private AcceptThread acceptThread;
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
13
14
e3f1b21718b0 implements RemoteDataSegment
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
14 public AliceDaemon(Config conf) {
e3f1b21718b0 implements RemoteDataSegment
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
15 this.conf = conf;
12
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
16 }
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
17
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
18 public void listen() {
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
19 try {
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
20 ServerSocketChannel ssChannel = ServerSocketChannel.open();
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
21 ServerSocket ss = ssChannel.socket();
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
22 ss.setReuseAddress(true);
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
23 ss.bind(new InetSocketAddress(InetAddress.getLocalHost(), conf.localPort));
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
24 acceptThread = new AcceptThread(ss, "ACCEPT" + conf.localPort);
12
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
25 acceptThread.start();
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
26
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
27 } catch (IOException e) {
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
28 e.printStackTrace();
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
29 }
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
30
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
31 }
c4d6ff56b9bf unite Command and Reply
one
parents:
diff changeset
32 }