Backup Cabinets


Table of Contents

Introduction

Backup cabinets allow the telemonitoring system to atomically backup and restore backable objects. Encapsulators are implemented to be backables and therefore enjoy the support of our implemented backup cabinets.

Using the backup cabinet

To obtain a backup cabinet for encapsulators, you can instantiate an object of the class BackableEncapsulatorBackupCabinet. Each cabinet requires a location on disk for its operation; therefore, the following code snippet is a skeleton of initializing a backup cabinet for encapsulators.

File cabinetPath = new File("/path/to/cabinet");
BackableEncapsulatorBackupCabinet cabinet = BackableEncapsulatorBackupCabinet(cabinetPath);

This backup cabinet can now be used to backup and restore (short: manage) any number of encapsulators. In order to have the cabinet manage an encapsulator myEnc, invoke the method registerBackable(myEnc). Once an encapsulator is registered with a cabinet, if a previous backup exists for the encapsulator (based on its identifier), the cabinet will restore that data to the encapsulator. The restoration will succeed only if the encapsulator is empty (in which case, myEnc will trigger the event RESTORED as well). If a previous backup exists for myEnc, but myEnc is not empty, then a CabinetException gets raised. If myEnc is already registered with the cabinet (or any other encapsulator with the same identifier), a CabinetIllegalStateException gets raised.

Once an encapsulator is successfully registered with a cabinet, the cabinet will monitor changes in the data stored inside it, and will update the backup automatically in the background without any extra required attention from you.

To relieve the cabinet from managing the encapsulator myEnc, invoke the methodunRegisterBackable(myEnc). This will not remove the backup associated with the encapsulator, but will merely stop automatically monitoring the encapsulator for updating the backups as the data within it change.

In order to remove an existing backup for an encapsulator identifier myEncID, invoke removeBackupForBackable(myEncID).