view src/alice/datasegment/DataSegment.java @ 215:1fd7067f0044 working

remove conversion flag
author one
date Wed, 27 Mar 2013 18:35:43 +0900
parents 6a69891b7232
children 9982e1c4f099
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>(); //TODO Over Head 
	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);
	}
	
}