Run a streaming job to spatially filter the results or perform a nearest neighbors analysis.
post
/spatialviewer/api/v1/spark/streaming
Request
Supported Media Types
- application/json
Query Parameters
-
asynchronous: boolean
if true the operation is runned asynchronously.Default Value:
false
Job details
Root Schema : StreamingJobInfo
Type:
Show Source
object
-
batchDuration(optional):
number(long)
The time interval in seconds at which streaming data will be divided into batches.Example:
15
-
distance(optional):
number(double)
The distance is required when the spatialOperation is WithinDistance. For projected data the distance is in the same unit as the unit of projection. For geodetic data the distance is in meters.Example:
1000
-
geometry(optional):
string
The geometry to determine the nearest neighbors or the query area in case of filtering. The geometry has to be in GeoJSON format.Example:
{"type":"Point", "coordinates":[2.33139, 48.86864]}
-
hostname(optional):
string
Hostname to connect to for receiving data. Specify the hostname when the default streamProviderFunctionClass is used that is when the property streamProviderFunctionClass is not specified.Example:
localhost
-
jarWithNeededClasses(optional):
string
jar name with the user-defined classes like a custom streamProviderFunctionClass or a custom RecordInfoProvider. To be able to use this jar the user must add it in the /opt/oracle/oracle-spatial-graph/spatial/web-server/spatialviewer/WEB-INF/lib directory and restart the server.Example:
myjar.jar
-
k(optional):
integer(int32)
Number of nearest neighbors. Specify this property if the operation is nearestNeighbors.Example:
10
-
operation(optional):
string
The operation to perform on the records. The possible values are filter and nearestNeighbors. The default value is filter.Example:
filter
-
outputPath(optional):
string
The job output path. This property is optional if asynchronous is false.Example:
/user/oracle/spatialviewer/StreamingResult
-
port(optional):
integer(int32)
Port to connect to for receiving data. Specify the port when the default streamProviderFunctionClass is used that is when the property streamProviderFunctionClass is not specified.Example:
9999
-
recordInfoProviderClass(optional):
string
The class that provides the spatial information.Example:
oracle.spatial.spark.vector.recordinfoprovider.GeoJsonRecordInfoProvider
-
spatialOperation(optional):
string
The spatial operation to spatially filter the records. The possible values are None, AnyInteract, IsInside, WithinDistance and Contains. The default value is AnyInteract. Specify this property if the operation is filter.Example:
AnyInteract
-
srid(optional):
integer(int32)
SRID of the geometries.Example:
8307
-
streamDataTypeClass(optional):
string
The same type than the JavaDStream. The default value is java.lang.String.Example:
java.lang.String
-
streamDuration(optional):
number(long)
Maximum duration of the stream in seconds. Optional property.Example:
3600
-
streamProviderFunctionClass(optional):
string
Class that will return a org.apache.spark.streaming.api.java.JavaDStream. The JavaDStream is the basic abstraction in Spark Streaming that represents a continuous stream of data. The class has to implement java.util.function.Function <JavaStreamingContext, JavaDStream>. The default implementation of the apply function is as following": "return sc.socketTextStream(host, port).map(record->{return record.toString();});Example:
mypackage.MyFunction
-
tolerance(optional):
number(double)
Double value that represents the tolerance used when performing spatial operations.Example:
0.05
Response
200 Response
successful request. A response will be received each x seconds as define in the property batchDuration. A line representing the record (using the java toString method of the record class) will be printed for each record.
202 Response
accepted asynchronous request
Root Schema : AsyncStreamingJobResponse
Type:
Show Source
object
-
o:successCode(optional):
string
The success code.Example:
SV-05014
-
response(optional):
string
The response contains the location of the resource manager web application URL to track the job (see in the configuration the Hadoop parameter yarn.resourcemanager.webapp.address).Example:
http://resource.manager.webapp:8088
-
status(optional):
string
success or errorExample:
success
-
title(optional):
string
Service title.Example:
Streaming job started.
Examples
The following example shows how to run a streaming job by submitting a POST request on the REST resource using cURL.
curl -v -X POST "http://localhost:8045/spatialviewer/api/v1/spark/streaming" -H "accept: application/json" -H "content-type: application/json" -d "{ \"operation\": \"filter\", \"hostname\": \"myhost.example.com\", \"port\": 7777, \"recordInfoProviderClass\": \"oracle.spatial.hadoop.vector.console.api.action.CSVRecordInfoProvider\", \"jarWithNeededClasses\": \"myjar.jar\", \"geometry\": \"{\\\"type\\\":\\\"Point\\\", \\\"coordinates\\\":[-122.460449, 37.743520]}\", \"srid\": 8307, \"tolerance\": 0.05, \"spatialOperation\":\"WithinDistance\", \"distance\":5000, \"batchDuration\": 15, \"streamDuration\": 60}"
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 200 OK Date: Wed, 15 Nov 2017 17:50:38 GMT Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, DELETE, PUT Access-Control-Allow-Headers: Content-Type, Accept Transfer-Encoding: chunked Content-Type: application/json
Response Body
A response will be received each x seconds as define in the property batchDuration. A line representing the record (using the java toString method of the record class) will be printed for each record.