Class CloudServer
java.lang.Object
com.amalgamasimulation.studies.remote.CloudServer
A singleton object to communicate with the Amalgama Cloud Server.
Can run custom GET/POST requests.
Can check remote server health status and its capability of running a simulation for a specific application type.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancheckAppAvailability(String productID, String clientSuffix, String version) Check server availability of the applicationChecks the health endpoint and preserves details for diagnostics UI.getRunExecutionStatus(String runID) Sends a request to the Cloud Server to get the run execution status.getSimulationResult(String runID) Fetches the simulation result from the Cloud Server for the supplied run id.getUrl()Returns the URL of the cloud server currently in use.static CloudServerinstance()booleanCheck that Amalgama Cloud Server is working and in orderbooleanrunIsKnown(String runID) Checks if a run with such id is known to the Cloud Server.voidChange the URL of the Cloud Server to work with.booleanSends a request to the Cloud Server to stop the run.booleansubmitRun(byte[] fileBytes, String runId, int seed, String productID, String clientSuffix, String version, String computerID) Send a request to Amalgama Cloud Server to add a simulation task to the task queue.
-
Method Details
-
instance
-
setUrl
Change the URL of the Cloud Server to work with.- Parameters:
cloudServerUrl- new URL (e.g., 'https://cloud.example.com:12345')
-
getUrl
Returns the URL of the cloud server currently in use. -
isServiceAlive
public boolean isServiceAlive()Check that Amalgama Cloud Server is working and in order- Returns:
- true if server is available and returned 200 OK status to the health response; false if the request to the server could not be completed or if the returned status code was not 200 OK
-
diagnoseServiceAlive
Checks the health endpoint and preserves details for diagnostics UI. -
checkAppAvailability
Check server availability of the application- Parameters:
productID- application id (license-related)- Returns:
- true if the server is alive and can run simulations for the application with the specified id
-
getRunExecutionStatus
Sends a request to the Cloud Server to get the run execution status. If the request is successful, a RunExecutionStatus object is returned. In case of any error (connection error, JSON parsing error) or if the server does not know the supplied run id,nullis returned. -
runIsKnown
Checks if a run with such id is known to the Cloud Server. -
submitRun
public boolean submitRun(byte[] fileBytes, String runId, int seed, String productID, String clientSuffix, String version, String computerID) Send a request to Amalgama Cloud Server to add a simulation task to the task queue.The method submits a task to the cloud server and does not wait for the server-side simulation to start.
- Parameters:
fileBytes- contents of the scenario file (in EXCEL format)runId- experiment id (e.g., AAA-111-BBB)seed- random number seed used to initialize random number sequences of the simulation model.productID- licensing-related application ID typically located in the singleton object of class `AppInfo` or similarclientSuffix- client-specific string (for generic application, this should be "base")version- product version- Returns:
- true if a new task has been submitted successfully; false otherwise
-
stopRun
Sends a request to the Cloud Server to stop the run.- Parameters:
runID- run id- Returns:
- true if the request was sent successfully; false in case of any errors (e.g. network unavailability)
-
getSimulationResult
Fetches the simulation result from the Cloud Server for the supplied run id. In case of any connection-related error - returns null. If the result is not available yet - also returns null.
-