Network Sensor

The Network Sensor system works as follows

    Components

  1. NetworkSensorService - Generates a stream of sensor data that contains the following Also randomly we send in an error reading by sending time = -1 and load = -1.0
  2. GraphService - Splits the data generated by Network Sensor by IP address and prints out a
    graph of % load. Each graph line is sent to a different outputstream which essentially a
    different topic. The graph is just a string of asterix.
  3. An output Service writes the data on each of the above topics to different files
The workflow does the following

    Working

  1. The Network Sensor generates a stream of sensor data
  2. The Graph Service writes the graph corresponding to each service. In the event an erroneous
    reading is detected, the Graph Service throws a
    org.hpsearch.demo.NetworkSensor.Exceptions.IncorrectReadingException exception.
    For simplicity, we just ignore this error.
  3. A new feature is the ability to specify custom script as a handler for errors / events.
    Thus on an EOF i.e. when the Network sensor is done sending the data and sends an EOF,
    the subsequent read by the Graph Service results in an EOF exception. We specify
    execution of the notifyEOF() function. In our case it just prints out a
    string saying that EOF was detected in the stream. However a complete script may be
    included here. For e.g. one that executes a custom Webservice call, sends a notification
    on another stream or other custom action to handle the fault / event. More extensions
    and a couple of modifications are required for higher customizability.

Script

	notifyError = function() {
		java.lang.System.out.println("fn(): -> ERROR in STREAM");
	}
	
	notifyEOF = function() {
		java.lang.System.out.println("fn(): -> EOF in STREAM");
	}

	networkSensorService    = "org.hpsearch.demo.NetworkSensor.NetworkSensorDataGenerator";
	networkSensorServiceLoc = "http://156.56.104.176:10025/axis/services/WSSConnector?wsdl" ; //NBDiscover.discover(networkSensorService);
	
	networkSensor = new WebServiceHandler(networkSensorService);
	networkSensor.setEndPointURI(networkSensorServiceLoc);
	networkSensor.setOutput("topic:///cgl/workflow/demo/networkSensor-data");
	
	
	graphService    = "org.hpsearch.demo.NetworkSensor.GraphService";
	graphServiceLoc = "http://156.56.104.176:7500/axis/services/WSSConnector?wsdl"; // NBDiscover.discover(graphService);
	graphGenerator  = new WebServiceHandler(graphService);
	graphGenerator.setEndPointURI(graphServiceLoc);
	
	graphGenerator.setInput("topic:///cgl/workflow/demo/networkSensor-data");
	graphGenerator.setOutput("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.162");
	graphGenerator.setOutput("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.170");
	graphGenerator.setOutput("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.176");
	graphGenerator.setOutput("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.100");
	graphGenerator.setOutput("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.155");
	
	graphGenerator.setErrorHandler("java.io.IOException", "notifyError()");
	graphGenerator.setErrorHandler("java.io.EOFException", "notifyEOF()");
	graphGenerator.setErrorHandler("org.hpsearch.demo.NetworkSensor.Exceptions.IncorrectReadingException", "ignore");
	
	output = new Resource("OutputFiles");
	
	output.port[0].subscribeFrom("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.162");
	output.port[1].subscribeFrom("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.170");
	output.port[2].subscribeFrom("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.176");
	output.port[3].subscribeFrom("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.100");
	output.port[4].subscribeFrom("topic:///cgl/workflow/demo/networkSensor/ip-156.56.104.155");
	
	output.port[0].publishTo("file:///u/hgadgil/ip-156.56.104.162.txt");
	output.port[1].publishTo("file:///u/hgadgil/ip-156.56.104.170.txt");
	output.port[2].publishTo("file:///u/hgadgil/ip-156.56.104.176.txt");
	output.port[3].publishTo("file:///u/hgadgil/ip-156.56.104.100.txt");
	output.port[4].publishTo("file:///u/hgadgil/ip-156.56.104.155.txt");
	

	networkSensorFlow = new Flow();
	networkSensorFlow.addComponents(graphGenerator, output);
	networkSensorFlow.addStartActivities(networkSensor);
	networkSensorFlow.start("1");