Mercurial > hg > Database > Alice
view src/main/java/alice/datasegment/DataSegment.java @ 548:b44a2bf16eb3 dispose
add IDS ODS constructor & work TestLocalAlice
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 25 Aug 2015 19:54:30 +0900 |
parents | f3f7e256ee03 |
children |
line wrap: on
line source
package alice.datasegment; import java.util.concurrent.ConcurrentHashMap; import alice.daemon.AliceDaemon; import alice.daemon.IncomingTcpConnection; import alice.datasegment.MulticastDataSegmentManager.SocketType; import org.apache.log4j.Logger; public class DataSegment { private final AliceDaemon alice; private LocalDataSegmentManager local = new LocalDataSegmentManager(); private CompressedLocalDataSegmentManager compressedLocal = new CompressedLocalDataSegmentManager(local);//追加 private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManagers = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); public DataSegment(AliceDaemon alice) { dataSegmentManagers.put("local", local); dataSegmentManagers.put("compressedlocal", compressedLocal); this.alice = alice; } public DataSegmentManager get(String key) { if (key == null){ return alice.dataSegment.dataSegmentManagers.get("local"); } else { return alice.dataSegment.dataSegmentManagers.get(key); } } public LocalDataSegmentManager getLocal() { return alice.dataSegment.local; } public CompressedLocalDataSegmentManager getCompressedLocal() {//追加 return alice.dataSegment.compressedLocal; } public void register(String key, DataSegmentManager manager) { alice.dataSegment.dataSegmentManagers.put(key, manager); } public RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port) { if (connectionKey.startsWith("compressed")){//compressedが含まれていたらエラーを返して終了 System.out.println("You can't use 'compressed' for DataSegmentManager name."); System.exit(0); } RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port, alice); CompressedRemoteDataSegmentManager compressedManager = new CompressedRemoteDataSegmentManager(manager); register(connectionKey, manager); register("compressed" + connectionKey, compressedManager); return manager; } public MulticastDataSegmentManager connectMulticast(String connectionKey ,String MCSTADDR, int port, String nis, SocketType type){ MulticastDataSegmentManager manager = new MulticastDataSegmentManager(connectionKey ,MCSTADDR, port, nis, type, alice); if (type!=SocketType.Receiver) register(connectionKey, manager); return manager; } public void setAccept(String key, IncomingTcpConnection incoming) { alice.dataSegment.acceptHash.put(key, incoming); } public IncomingTcpConnection getAccept(String key) { return alice.dataSegment.acceptHash.get(key); } public void remove(String key){ alice.dataSegment.dataSegmentManagers.remove(key); } public boolean contains(String key){ return alice.dataSegment.dataSegmentManagers.containsKey(key); } }