Package oracle.nosql.driver.ops

# Class SystemResult

java.lang.Object
oracle.nosql.driver.ops.Result
oracle.nosql.driver.ops.SystemResult

public class SystemResult extends Result
On-premises only.

SystemResult is returned from `NoSQLHandle.systemStatus(oracle.nosql.driver.ops.SystemStatusRequest)` and `NoSQLHandle.systemRequest(oracle.nosql.driver.ops.SystemRequest)` operations. It encapsulates the state of the operation requested.

Some operations performed by `NoSQLHandle.systemRequest(oracle.nosql.driver.ops.SystemRequest)` are asynchronous. When such an operation has been performed it is necessary to call `NoSQLHandle.systemStatus(oracle.nosql.driver.ops.SystemStatusRequest)` until the status of the operation is known. The method `waitForCompletion(oracle.nosql.driver.NoSQLHandle, int, int)` exists to perform this task and should be used whenever possible.

Asynchronous operations (e.g. create namespace) can be distinguished from synchronous System operations in this way:

- Asynchronous operations may return a non-null operationId
- Asynchronous operations modify state, while synchronous operations are read-only
- Synchronous operations return a state of `SystemResult.State.COMPLETE` and have a non-null resultString

`NoSQLHandle.systemStatus(oracle.nosql.driver.ops.SystemStatusRequest)` is synchronous, returning the known state of the operation. It should only be called if the operation was asynchronous and returned a non-null operationId.

See Also:
  - `NoSQLHandle.systemStatus(oracle.nosql.driver.ops.SystemStatusRequest)`
  - `NoSQLHandle.systemRequest(oracle.nosql.driver.ops.SystemRequest)`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `SystemResult.State`
  On-premises only.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SystemResult()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getOperationId()`
  Returns the operation id for the operation if it was asynchronous.
  `SystemResult.State`
  `getOperationState()`
  Returns the operation state.
  `String`
  `getResultString()`
  Returns the result string for the operation.
  `String`
  `getStatement()`
  Returns the statement used for the operation.
  `String`
  `toString()`
  `void`
  `waitForCompletion(NoSQLHandle handle, int waitMillis, int delayMillis)`
  Waits for the operation to be complete.

  ### Methods inherited from class oracle.nosql.driver.ops.Result

  `getRateLimitDelayedMs, getRetryStats`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### SystemResult

    public SystemResult()

- ## Method Details

  - ### getOperationState

    public SystemResult.State getOperationState()
    Returns the operation state.
    Returns:
      the state

  - ### getOperationId

    public String getOperationId()
    Returns the operation id for the operation if it was asynchronous. This is null if the request did not generate a new operation and/or the operation state is `SystemResult.State.COMPLETE`. The value can be used in `SystemStatusRequest.setOperationId(java.lang.String)` to get status and find potential errors resulting from the operation. This method is only useful for the result of asynchronous operations.
    Returns:
      the operation id or null if not set

  - ### getResultString

    public String getResultString()
    Returns the result string for the operation. This is null if the request was asynchronous or did not return an actual result. For example the "show" operations return a non-null result string, but "create, drop, grant, etc" operations return a null result string.
    Returns:
      the string

  - ### getStatement

    public String getStatement()
    Returns the statement used for the operation.
    Returns:
      the statement

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### waitForCompletion

    public void waitForCompletion(NoSQLHandle handle, int waitMillis, int delayMillis)
    Waits for the operation to be complete. This is a blocking, polling style wait that delays for the specified number of milliseconds between each polling operation. This instance is modified with any changes in state.
    Parameters:
      `handle` - the NoSQLHandle to use
      `waitMillis` - the total amount of time to wait, in millseconds. This value must be non-zero and greater than delayMillis
      `delayMillis` - the amount of time to wait between polling attempts, in milliseconds. If 0 it will default to 500.
    Throws:
      `IllegalArgumentException` - if the operation times out or the parameters are not valid.
      `NoSQLException` - if the operation id used is unknown or the operation has failed.