-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KIRSTEN W. HILDRUM
committed
Sep 30, 2015
1 parent
e4ff217
commit 08d31b1
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
|
||
composite Main { | ||
|
||
graph | ||
stream<rstring result> NoNewline = com.ibm.streamsx.inet::InetSource() { | ||
param | ||
// the data returned by this URL does not have a newline at the end. | ||
URIList: ["http://services.faa.gov/airport/status/ATL?format=application/xml"]; | ||
fetchInterval: 5.0; | ||
|
||
} | ||
|
||
// make sure we got the last line. | ||
() as checkNoNewline = Custom(NoNewline) { | ||
logic state: { | ||
mutable int32 numEnter = 0; | ||
mutable int32 numExits = 0; | ||
} | ||
onTuple NoNewline: { | ||
if (size(regexMatch(result,"\\s*<AirportStatus>\\s*")) > 0) { | ||
numEnter++; | ||
} | ||
else if (size(regexMatch(result,"\\s*</AirportStatus\\s*"))>0) { | ||
numExits++; | ||
} | ||
if (numEnter-numExits > 1) { | ||
abort(); | ||
} | ||
if (numEnter == numExits && numExits > 0) { | ||
shutdownPE(); | ||
} | ||
} | ||
} | ||
} |