Mercurial > hg > Database > Alice
view 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 |
line wrap: on
line source
package alice.datasegment; import java.util.concurrent.ConcurrentHashMap; import alice.daemon.IncomingTcpConnection; public class DataSegment { private static DataSegment dataSegment = new DataSegment(); private LocalDataSegmentManager local = new LocalDataSegmentManager(); private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManageres = new ConcurrentHashMap<String, DataSegmentManager>(); private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); private DataSegment() { dataSegmentManageres.put("local", local); } public static DataSegmentManager get(String key) { return dataSegment.dataSegmentManageres.get(key); } public static LocalDataSegmentManager getLocal() { return dataSegment.local; } public static void regist(String key, DataSegmentManager manager) { dataSegment.dataSegmentManageres.put(key, manager); } public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port) { RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port); regist(connectionKey, manager); return manager; } public static void setAccept(String key, IncomingTcpConnection incoming) { dataSegment.acceptHash.put(key, incoming); } public static IncomingTcpConnection getAccept(String key) { return dataSegment.acceptHash.get(key); } }