frameSender.start();
LOG.info("Attemping login");
if (!authorize()) {
throw new ConnectionException("Authorization failed");
}
LOG.info("Successful login");
// send registration info to the SDC server
registration.sendRegistrationInfo(frameSender);
// setup to start receiving and processing registration response
frameReceiver.registerDispatcher(FrameInfo.Type.REGISTRATION, registration);
// Setup Healthcheck
if (localConf.getRunHeartBeatThread()) {
LOG.info("Starting hearbeat/ health check thread.");
healthCheckHandler.setFrameSender(frameSender);
healthCheckHandler.setFailCallback(this);
frameReceiver.registerDispatcher(FrameInfo.Type.HEALTH_CHECK, healthCheckHandler);
healthCheckHandler.start();
}
// Setup Socket Data.
socksDataHandler.setFrameSender(frameSender);
frameReceiver.registerDispatcher(FrameInfo.Type.SOCKET_DATA, socksDataHandler);
// Setup AgentRequest handler
agentRequestHandler.setFrameSender(frameSender);
frameReceiver.registerDispatcher(FrameInfo.Type.FETCH_REQUEST, agentRequestHandler);
// Setup SocketSessionRequestHandler
socketSessionRequestHandler.setFrameSender(frameSender);
frameReceiver.registerDispatcher(FrameInfo.Type.SOCKET_SESSION, socketSessionRequestHandler);
// a thread to watch for changes in the resources.xml file
// make this thread a daemon - so it can't hold up the process from exiting
LOG.info("starting a thread to watch resources file");
resourcesFileWatcher.setFrameSender(frameSender);
resourcesFileWatcher.start();
// Add to shutdown manager so it gets gracefully shutdown.
shutdownManager.addStoppable(this);
frameReceiver.startDispatching();
} catch (IOException e) {
throw new ConnectionException(e);
} catch (FramingException e) {
throw new ConnectionException(e);
}
}