Aller au contenu principal
Version: Next

Remote datastores

A remote datastore is a reference, on a local 4D application (4D or 4D Server), to a datastore stored in another 4D application.

The local 4D application connects to and references the remote datastore through a call to the Open datastore command.

On the remote machine, 4D opens a session to handle requests from the application that call Open datastore. Requests internally use the REST API, which means that they might require available licenses.

Using web sessions

When you work with a remote datastore referenced through calls to the Open datastore command, the connection with the requesting processes is handled via web sessions on the remote machine.

The web session created on the remote datastore is identified using a internal session ID which is associated to the localID on the 4D application side. Cette session gère automatiquement l'accès aux données, aux sélections d'entités ou aux entités.

The localID is local to the machine that connects to the remote datastore, which means:

  • If other processes of the same application need to access the same remote datastore, they can use the same localID and thus, share the same session.
  • If another process of the same application opens the same remote datastore but with another localID, it will create a new session on the remote datastore.
  • If another machine connects to the same remote datastore with the same localID, it will create another session with another cookie.

Ces principes sont illustrés dans les graphiques suivants :

Visualiser les sessions

Les process qui gèrent les sessions d'accès aux datastore apparaissent dans la fenêtre d'administration de 4D Server :

  • name: "REST Handler: \<process name>"
  • type : type Worker Server HTTP
  • session: session name is the user name passed to the Open datastore command.

Dans l'exemple suivant, deux process sont en cours d'exécution pour la même session :

Fermeture des sessions

As described in the session lifetime paragraph, a web session is automatically closed by 4D when there has been no activity during its timeout period. The default timeout is 60 mn, but this value can be modified using the connectionInfo parameter of the Open datastore command.

Si une demande est envoyée au datastore distant après la fermeture de la session, elle est automatiquement recréée si possible (licence disponible, serveur non arrêté, etc.). However, keep in mind that the context of the session regarding locks and transactions is lost (see below).

Verrouillage et transactions

Les fonctionnalités ORDA relatives au verrouillage d'entité et aux transactions sont gérées au niveau du process dans les datastore distants, tout comme en mode client/serveur ORDA :

  • If a process locks an entity from a remote datastore, the entity is locked for all other processes, even when these processes share the same session (see Entity locking). Si plusieurs entités pointant vers le même enregistrement ont été verrouillées dans un process, elles doivent toutes être déverrouillées dans le process pour supprimer le verrou. Si un verrou a été mis sur une entité, il est supprimé lorsqu'il n'existe plus de référence à cette entité en mémoire.
  • Transactions can be started, validated or cancelled separately on each remote datastore using the dataStore.startTransaction(), dataStore.cancelTransaction(), and dataStore.validateTransaction() functions. Elles n’ont pas d’incidences sur les autres datastore.
  • Classic 4D language commands (START TRANSACTION, VALIDATE TRANSACTION, CANCEL TRANSACTION) only apply to the main datastore (returned by ds). Si une entité d'un datastore distant est verrouillée par une transaction dans un process, les autres process ne peuvent pas la mettre à jour, même si ces process partagent la même session.
  • Les verrous sur les entités sont supprimés et les transactions sont annulées :
    • lorsque le process est tué.
    • quand la session est fermée sur le serveur
    • lorsque la session est arrêtée à partir de la fenêtre d’administration du serveur.