public NodeAgent nodeAgent() throws Exception {
try {
camelContext = common.camelContext();
camelContext.disableJMX();
NodeAgent agent = new NodeAgent(nodeIdentity(), launcher(), camelContext, this);
// optionally configures Camel Context for JMS. Checks the 'agentRequestEndpoint' to
// to determine type of transport. If the the endpoint starts with "activemq:", a
// special ActiveMQ component will be activated to enable JMS transport
agentTransport.configureJMSTransport(logger,common.agentRequestEndpoint, camelContext);
AgentEventListener delegateListener = agentDelegateListener(agent);
if (common.managedProcessStateUpdateEndpointType != null
&& common.managedProcessStateUpdateEndpointType.equalsIgnoreCase("socket")) {
String agentSocketParams = "";
if (common.managedProcessStateUpdateEndpointParams != null) {
agentSocketParams = "?" + common.managedProcessStateUpdateEndpointParams;
}
int agentPort = Utils.findFreePort();
common.managedProcessStateUpdateEndpoint = "mina:tcp://localhost:" + agentPort
+ agentSocketParams;
// Remember the agent port since we need to tell JPs where to send their state updates
System.setProperty(NodeAgent.ProcessStateUpdatePort, String.valueOf(agentPort));
}
camelContext
.addRoutes(this.routeBuilderForManagedProcessStateUpdate(agent, delegateListener));
camelContext.addRoutes(this.routeBuilderForIncomingRequests(agent, delegateListener));
camelContext.addRoutes(this.routeBuilderForNodeInventoryPost(agent,
common.nodeInventoryEndpoint, Integer.parseInt(common.nodeInventoryPublishRate)));
metricsRouteBuilder = this.routeBuilderForNodeMetricsPost(agent, common.nodeMetricsEndpoint,
Integer.parseInt(common.nodeMetricsPublishRate));
camelContext.addRoutes(metricsRouteBuilder);
logger.info("nodeAgent", null, "------- Agent Initialized - Identity Name:"
+ agent.getIdentity().getName() + " IP:" + agent.getIdentity().getIp()
+ " JP State Update Endpoint:" + common.managedProcessStateUpdateEndpoint);
return agent;
} catch (Exception e) {
e.printStackTrace();