...
The above should be executed only once. After that the initial request, you can execute multiple requests can be executed concurrently on the eaglemlApi object.
To stop the eaglemlApi instance and clean up the resources, run the following:
Code Block | ||||
---|---|---|---|---|
| ||||
eaglemlApi.stop(); |
...
Execute the request Asynchronously
The requests can be executed You can execute the requests only after EagleML Client API was is started using the EagleApi.start() method.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
• // THIS IS A SAMPLE OF THE REQUEST EXECUTION. REQUESTS CAN BE EXECUTED ONLY AFTER THE eaglemlApi.start() is called. Map<String, String> parameters = new HashMap<String, String>(); // Add the parameters required to build an URI // Generate a unique correlationId // Add the attachments for the POST request eaglemlApi.executeRestRequestAsync("GET", "/eagle/v2/manager-relationships", parameters, correlationId, businessTaskId, null, 600 /* timeout in seconds */, (result, exception) -> { if(exception != null) { // There was an exception while executing the request. Process it. } else { switch(result.getResultStatus()) { case EagleApiResultStatus.SUCCESS: List<IEagleApiResultDataFile> files = result.getDataFiles(); for (IEagleApiResultDataFile file : files) { // See the java doc for the IEagleApiResultDataFile. The file will represent one extract. // Currently EaglemlApi will produce only one file. // You can get a stream of uncompressed data: try(InputStream stream = file.getStream()) { // Parse the extract and execute any transformations - for example to JSON } // If needed you can get the compressed data and get access to the file with the file.isInMemory(), file.getData(), file.getFile() // The temporary files (if any) created while processing the extracts will be removed when you close the IEagleApiResult instance. // If you want to preserve you'll have to move/copy them here. } break; case EagleApiResultStatus.TIMEOUT: // TIMEOUT - report an error break; case EagleApiResultStatus.ERROR: // ERROR - use result.getErrorMessage to get the error message break; case EagleApiResultStatus.STOPPED: // The request execution was stopped, when eaglemlApi.stop() is called break; case EagleApiResultStatus.NO_DATA: // The extract resulted in no data retrieved. Report this back. break; } } }); |
Execute the
...
Request Synchronously
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// THIS IS A SAMPLE OF THE REQUEST EXECUTION. REQUESTS CAN BE EXECUTED ONLY AFTER THE eaglemlApi.start() is called. Map<String, String> parameters = new HashMap<String, String>(); // Add the parameters required to build an URI // Generate a unique correlationId // Add the attachments for the POST request try (IEagleApiResult result = eaglemlApi.executeRequestAsync("GET", "/eagle/v2/manager-relationships", parameters, correlationId, null, 600 /* timeout in seconds */)) { switch(result.getResultStatus()) { case EagleApiResultStatus.SUCCESS: List<IEagleApiResultDataFile> files = result.getDataFiles(); for (IEagleApiResultDataFile file : files) { // See the java doc for the IEagleApiResultDataFile. The file will represent one extract. // Currently EaglemlApi will produce only one file. // You can get a stream of uncompressed data: try(InputStream stream = file.getStream()) { // Parse the extract and execute any transformations - for example to JSON } // If needed you can get the compressed data and get access to the file with the file.isInMemory(), file.getData(), file.getFile() // The temporary files (if any) created while processing the extracts will be removed when you close the IEagleApiResult instance. // If you want to preserve you'll have to move/copy them here. } break; case EagleApiResultStatus.TIMEOUT: // TIMEOUT - report an error break; case EagleApiResultStatus.ERROR: // ERROR - use result.getErrorMessage to get the error message break; case EagleApiResultStatus.STOPPED: // The request execution was stopped, when eaglemlApi.stop() is called break; case EagleApiResultStatus.NO_DATA: // The extract resulted in no data retrieved. Report this back. break; } } catch(EagleApiException e) { // Process the exception }; |
Command
...
Line Interface for
...
Executing REST
...
Requests
Synchronous Mode
To enable synchronous mode, enter the following in the console:
...
- Creates a callback. It is represented by a Jetty HTTP Servlet server which starts to listen on a random free port. You can set a timeout here, when . When it expires, the callback will be is unregistered and the timeout error will be is displayed. For example, a 5 min t/o:
...
2. The client then executes REST request. The request will contain contains x-eagle-rest-callback header with the IP address of the Eagle API client, the communication port and /eagleapicallback suffix, for . For example:
No Format |
---|
x-eagle-rest-callback: http://99.99.99.999:63345/eagleapicallback |
...
6. Parses the TaskStatusResponse to understand if its task status is SUCCESS, FAILED or NO_DATA.
...
- If the status is SUCCESS, the result data
...
is uploaded as an archive file and saved in the temporary folder with correlation id as its name.
...
The temporary folder is the system %TEMP%
...
. For example: C:\Users\admin\AppData\Local\Temp\
...
. This folder is not purged automatically
...
.
...
- If a folder is specified in the
...
resultsdir parameter, the result data
...
is unzipped and stored in this particular folder.
...
- If “resultsdir” is not specified or empty, the extract remains unzipped in the temp folder.
...
- If the status is FAILED or NO_DATA, an error description
...
is displayed.
...
- If the multipart does not arrive before the
...
timeout expires, the callback
...
is unregistered and
...
a timeout error
...
is displayed.
Available Settings
Name | Valid Values | Description |
---|---|---|
-login | username | Username to log in the environment |
EAGLEAPIPASS | password | Password for the environment set as a global system variable. Can be defined in the command line, for example: set EAGLEAPIPASS=my_password |
-resultsdir | empty or folder path | The folder in which unzipped result file will be stored. If not specified, the result will remain unzipped in the temp folder |
-csvmetricsdir | empty or folder path | The folder in which metrics will be stored |
-threads | even number, 1 or greater | Defines the number of separate threads for an async process. For each thread a separate listener are created. |
-endpoint | address of the environment | Endpoint address |
-file | file path | Path to the file with the query |
-execution | sync or async | Execution mode - synchronous or asynchronous |
...
Example of Use
Synchronous Mode
In this example we launch the example below, the EagleMLAPI Client is launched in synchronous mode from the command line.
- Request The request is formed from in this query:
No Format |
---|
-data="GET|/eagle/v2/manager-relationships?entityselectiontype=EntityID&entityselectionvalue=EMLFUN10&outputformat=XML|ABCDEF" |
- To start execution we , execute the following command:
...
Asynchronous Mode
In this example we are launching , 2 asynchronous requests are launched.
- Requests The requests are formed from the request.txt query file located in testFolder:
...
Two queries are executed in parallel (-threads=2)
- To start execution we , execute the following command:
...