Class CloudServer

java.lang.Object
com.amalgamasimulation.studies.remote.CloudServer

public class CloudServer extends Object
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 Details

    • instance

      public static CloudServer instance()
    • setUrl

      public void setUrl(String cloudServerUrl)
      Change the URL of the Cloud Server to work with.
      Parameters:
      cloudServerUrl - new URL (e.g., 'https://cloud.example.com:12345')
    • getUrl

      public String 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

      public ConnectivityDiagnosis diagnoseServiceAlive()
      Checks the health endpoint and preserves details for diagnostics UI.
    • checkAppAvailability

      public boolean checkAppAvailability(String productID, String clientSuffix, String version)
      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

      public RunExecutionStatus getRunExecutionStatus(String runID)
      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, null is returned.
    • runIsKnown

      public boolean runIsKnown(String runID)
      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 similar
      clientSuffix - 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

      public boolean stopRun(String runID)
      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

      public SimulationRunResult getSimulationResult(String runID)
      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.