Space Life Cycle and Persistence

The space life cycle starts when the space is first defined in the metaspace and ends when the space definition is dropped from the metaspace.

A space can be in one of the following states:

  • INITIAL - The space has been defined and is waiting for the minimum number of seeders required by the space's definition to be reached, and for at least one persister to be registered if it is a persisted space.
  • LOADING - The space is a persisted space that has reached the required minimum number of seeders and has at least one registered persister. One of the persister's onLoad methods is being invoked and the space data is being loaded from the persistence layer.
  • READY - The space has the required minimum number of seeders and if persisted, data has been loaded and has at least one registered persister.

Space operations that read or write data in the space are only allowed when the space is in the READY state. The only exception to this rule is that the space's load method can be invoked when the space is in the LOADING state (typically by the registered persister onLoad method).

Your application can check that the space is in the READY state before attempting to use it by using the space's isReady() method.

Your application can also synchronize itself with the space's state by using the space's waitForReady method. This method takes a timeout that is the number of milliseconds for which it will block while waiting for the space to reach the READY state, and returns a boolean value indicating whether the timeout was reached or not (Java also has a convenient version of the method that does not take a timeout and just blocks until the space is ready).

Another way to synchronize an application with the space's state is to rely on the space definition's SpaceWait attribute: a configurable timeout that is used to block space operations when the space is not in the READY state until either the space becomes ready (at which point the operation is executed) or the SpaceWait timeout expires (at which point the operation will fail).