Mercurial > hg > Database > Alice
annotate src/alice/datasegment/DataSegment.java @ 64:7aaadd08288c
add getLocal method to DataSegment
author | kazz |
---|---|
date | Thu, 09 Feb 2012 19:20:24 +0900 |
parents | 98ab26e09a98 |
children | 6a69891b7232 |
rev | line source |
---|---|
3 | 1 package alice.datasegment; |
2 | |
3 import java.util.concurrent.ConcurrentHashMap; | |
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 | 7 public class DataSegment { |
8 | |
9 private static DataSegment dataSegment = new DataSegment(); | |
64 | 10 private LocalDataSegmentManager local = new LocalDataSegmentManager(); |
3 | 11 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
|
12 private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); |
3 | 13 |
14 private DataSegment() { | |
64 | 15 dataSegmentManageres.put("local", local); |
3 | 16 } |
17 | |
18 public static DataSegmentManager get(String key) { | |
19 return dataSegment.dataSegmentManageres.get(key); | |
20 } | |
64 | 21 |
22 public static LocalDataSegmentManager getLocal() { | |
23 return dataSegment.local; | |
24 } | |
3 | 25 |
26 public static void regist(String key, DataSegmentManager manager) { | |
27 dataSegment.dataSegmentManageres.put(key, manager); | |
28 } | |
29 | |
28
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
30 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
|
31 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
|
32 regist(connectionKey, manager); |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
33 return manager; |
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
34 } |
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
3
diff
changeset
|
35 |
28
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
36 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
|
37 dataSegment.acceptHash.put(key, incoming); |
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
38 } |
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
39 |
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
40 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
|
41 return dataSegment.acceptHash.get(key); |
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
42 } |
98ab26e09a98
Configuration Manager work and implements reverseKey
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
43 |
3 | 44 } |