channelServerMap =
collectionsFactory.newMap(CHANNEL_SERVER_MAP_PREFIX);
}
}
contextFactory = new ContextFactory(contextMap);
WatchdogService watchdogService =
txnProxy.getService(WatchdogService.class);
sessionService = txnProxy.getService(ClientSessionService.class);
localNodeId = watchdogService.getLocalNodeId();
writeBufferSize = wrappedProps.getIntProperty(
WRITE_BUFFER_SIZE_PROPERTY, DEFAULT_WRITE_BUFFER_SIZE,
8192, Integer.MAX_VALUE);
/*
* Get the property for controlling channel event processing.
*/
eventsPerTxn = wrappedProps.getIntProperty(
EVENTS_PER_TXN_PROPERTY, DEFAULT_EVENTS_PER_TXN,
1, Integer.MAX_VALUE);
/*
* Export the ChannelServer.
*/
int serverPort = wrappedProps.getIntProperty(
SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
serverImpl = new ChannelServerImpl();
exporter = new Exporter<ChannelServer>(ChannelServer.class);
try {
int port = exporter.export(serverImpl, serverPort);
serverProxy = exporter.getProxy();
logger.log(
Level.CONFIG,
"ChannelServer export successful. port:{0,number,#}", port);
} catch (Exception e) {
try {
exporter.unexport();
} catch (RuntimeException re) {
}
throw e;
}
/*
* Check service version.
*/
transactionScheduler.runTask(
new AbstractKernelRunnable("CheckServiceVersion") {
public void run() {
checkServiceVersion(
VERSION_KEY, MAJOR_VERSION, MINOR_VERSION);
} }, taskOwner);
/*
* Create channel server map, keyed by node ID. Then store
* channel server in the channel server map.
*/
transactionScheduler.runTask(
new AbstractKernelRunnable("StoreChannelServerProxy") {
public void run() {
getChannelServerMap().put(
Long.toString(localNodeId), serverProxy);
} },
taskOwner);
/*
* Add listeners for handling recovery and for receiving
* notification of client session disconnection.
*/
watchdogService.addRecoveryListener(
new ChannelServiceRecoveryListener());
watchdogService.addNodeListener(new ChannelServiceNodeListener());
sessionService.registerSessionDisconnectListener(
new ChannelSessionDisconnectListener());
/* Create our service profiling info and register our MBean. */