@Override
public void startUp() throws Exception {
for (String inputName : spec.getInputSchemas().keySet()) {
Map.Entry<InputStreamFormat, StreamSchema> streamInfo = spec.getInputSchemas().get(inputName);
ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
InputServerSocket service;
switch(streamInfo.getKey()) {
case GDAT:
service = new InputServerSocket(factory, inputName, streamInfo.getValue(),
portMap.get(Constants.TCP_INGESTION_PORT_PREFIX + inputName));
break;
case JSON:
service = new JsonInputServerSocket(factory, inputName, streamInfo.getValue(),
portMap.get(Constants.TCP_INGESTION_PORT_PREFIX + inputName));
break;
default:
throw new Exception("Unknown Input Format. Only JSON and GDAT Formats are supported.");
}
service.startAndWait();
portMap.put(Constants.TCP_INGESTION_PORT_PREFIX + inputName, service.getIngestionPort());
inputServerMap.put(inputName, service.getSocketAddressMap());
dataIngressServerMap.put(inputName, service.getSocketAddressMap().get(Constants.StreamIO.TCP_DATA_INGESTION));
dataSourceServerMap.put(inputName, service.getSocketAddressMap().get(Constants.StreamIO.DATASOURCE));
inputServerSocketServices.add(service);
}
for (Map.Entry<String, String> output : spec.getQuery().entrySet()) {
ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
StreamSocketServer service = new OutputServerSocket(factory, output.getKey(), output.getValue(), recordQueue);
service.startAndWait();
outputServerMap.put(output.getKey(), service.getSocketAddressMap());
dataEgressServerMap.put(output.getKey(), service.getSocketAddressMap().get(Constants.StreamIO.DATASINK));