annotate src/alice/datasegment/DataSegment.java @ 28:98ab26e09a98

Configuration Manager work and implements reverseKey
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 08:41:34 +0900
parents 54bf607118ae
children 7aaadd08288c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
1 package alice.datasegment;
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
2
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
3 import java.util.concurrent.ConcurrentHashMap;
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
4
28
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
5 import alice.daemon.IncomingTcpConnection;
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
6
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
7 public class DataSegment {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
8
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
9 private static DataSegment dataSegment = new DataSegment();
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
10 private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManageres = new ConcurrentHashMap<String, DataSegmentManager>();
28
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
11 private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>();
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
12
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
13 private DataSegment() {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
14 dataSegmentManageres.put("local", new LocalDataSegmentManager());
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
15 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
16
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
17 public static DataSegmentManager get(String key) {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
18 return dataSegment.dataSegmentManageres.get(key);
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
19 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
20
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
21 public static void regist(String key, DataSegmentManager manager) {
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
22 dataSegment.dataSegmentManageres.put(key, manager);
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
23 }
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
24
28
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
25 public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port) {
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
26 RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port);
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
27 regist(connectionKey, manager);
23
54bf607118ae change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
28 return manager;
54bf607118ae change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
29 }
54bf607118ae change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
30
28
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
31 public static void setAccept(String key, IncomingTcpConnection incoming) {
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
32 dataSegment.acceptHash.put(key, incoming);
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
33 }
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
34
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
35 public static IncomingTcpConnection getAccept(String key) {
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
36 return dataSegment.acceptHash.get(key);
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
37 }
98ab26e09a98 Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
38
3
91057e15065f add DataSegment API and CodeSegment
one
parents:
diff changeset
39 }