Mercurial > hg > Database > Alice
view src/main/java/alice/datasegment/DataSegment.java @ 350:388e7d4b0624
heart beat may finish.
author | sugi |
---|---|
date | Tue, 22 Apr 2014 04:21:22 +0900 |
parents | 8f71c3e6f11d |
children | 514af34ca062 |
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> dataSegmentManagers = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); private DataSegment() { dataSegmentManagers.put("local", local); } public static DataSegmentManager get(String key) { return dataSegment.dataSegmentManagers.get(key); } public static LocalDataSegmentManager getLocal() { return dataSegment.local; } public static void register(String key, DataSegmentManager manager) { dataSegment.dataSegmentManagers.put(key, manager); } public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port, boolean rFlag) { RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port, rFlag); register(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); } public static void remove(String key){ dataSegment.dataSegmentManagers.remove(key); } }