-
Notifications
You must be signed in to change notification settings - Fork 2
Sources
We define some prebuilt sources that allow you to subscribe to data streams that can be processed by Streaming MASSIF:
A FileSource allows you to easily stream data from a file line by line. It takes two parameters:
- fileName: the location of the file that should be streamed line by line.
- timeOut: the amount of time that should be kept between each line is sent to the platform.
FileSource example:
String fileName=...
long timeOut=...
FileSource fsource = new FileSource(fileName,timeOut);
PipeLineComponent sourceComp = new PipeLineComponent(fsource,Collections.singletonList(windowComp));
fsource.stream();
Allows to continuously pull an HTTP source through an HTTP get request. Parameters:
- url: the URL that should be pulled
- pullTimeOut: the amount of time between pulls.
HTTPGetSource example:
String url=...
long pullTimeOut=...
HTTPGetSource fsource = new HTTPGetSource(url,pullTimeOut);
PipeLineComponent sourceComp = new PipeLineComponent(fsource,Collections.singletonList(windowComp));
fsource.stream();
Provides a Source that can be externally called through the provided url through an HTTP Post request. Parameters:
- path: the path on which the POST request can be called..
HTTPPostSource example:
String path=...
HTTPPostSource fsource = new HTTPGetSource(path);
PipeLineComponent sourceComp = new PipeLineComponent(fsource,Collections.singletonList(windowComp));
fsource.stream();
Allows to connect to a websocket server on a certain url. Parameters:
- wsURL: the websocket URL to connect to.
WebSocketClientSource example:
String wsURL=...
WebSocketClientSource fsource = new WebSocketClientSource(wsURL);
PipeLineComponent sourceComp = new PipeLineComponent(fsource,Collections.singletonList(windowComp));
fsource.stream();
Allows to set up a websocket server, so that websocket clients can transmit data. Parameters:
- wsURL: the websocket URL to connect to.
- port: the port that should be used to host the websocket
WebSocketServerSource example:
String wsURL=...
int port=...
WebSocketServerSource fsource = new WebSocketServerSource(port,wsURL);
PipeLineComponent sourceComp = new PipeLineComponent(fsource,Collections.singletonList(windowComp));
fsource.stream();
Of course, you can implement your own source. Just implement the idlab.massif.interfaces.core.SourceInf
interface.
Just make sure to call the idlab.massif.interfaces.core.ListenerInf.notify(int queryID, String event)
method with the data represented in a serialized ontology format as a String. The queryID can be 0 if none is present.