Splitting Endpoint Data
As an Akula API operates, there is sometimes a need to pass large amounts of endpoint data between the Akula Server and the client, and large JSON messages from the server cannot be handled by the client due to client memory constraints.
The Akula Splitter is designed to help with this issue:
- Clients are able to re-request a failed split data piece
- Splitter will not delete a piece until the next piece has been requested
- Clients are able to tell server that all split pieces have been processed
- New server endpoint has been created for "Done Processing" Split Response
- When the endpoint is called, the server deletes any split pieces for this request
- Clients are notified to call a new endpoint when last chunk has finished being processed
Using the Splitter requires Akula Server 2.5 or later.
This section describes the following topics:
Configuring a Data Splitter for a Server API
To specify splitting strategy on a particular endpoint, add a new XML element to the endpoint configuration in your app scope:
You can define custom splitters using the AKSplitter interface. For example:
Splitting JSON Data
Akula provides a built-in splitter for splitting JSON data. Here is an example showing how the built-in splitter could be used:
- The data will be split after every 100000 bytes
- The split data will remain valid for 120000 milliseconds
- If the response is a JSONObject, objectArrayFields will be used to split large arrays corresponding to the keys MyData1 and MyData2
Rejoining Split Data on a Client API
Here is an example of how you might retrieve data from a split endpoint on iOS:
Splitter REST API
Get Split Endpoint
The X-Ak-Split-Next header contains the ID of the next split in sequence to be retrieved.
The X-Ak-Split-Id header contains the ID of the split that was just retrieved.
The X-Ak-Split-Remain header contains the amount of data that remains in all split pieces which have not yet been retrieved, usually in bytes.
The X-Ak-Split-Total header contains the total amount of data in all split pieces generated by the original request, usually in bytes.
This header contains the ID of the split to retrieve. This is the header value returned from the previous request.
To get the first split ID, you must first make the request to the original endpoint. If the data is large enough, it will return an X-Ak-Split-Next header to indicate that more pieces must be retrieved.
|Potential Error Codes|
|Example Response Body||varies||The response body is the output from the |
|This endpoint is used to retrieve pieces of data when a request to an endpoint caused the data to be split.|
Delete Splitter Data Endpoint
|This endpoint is used to delete the splitter data from the server when the client has finished processing it.|
Call this endpoint when you are finished processing the request data or wish to cancel to free up database space.
This header contains the ID of any split in the splitter data. With any ID from any data that still exists on the server, ALL pieces from the splitter that correspond to the same initial request will be removed from the server.
|Example Response Body|
|Potential Error Codes|