Plugins for secondary file storage

NOTE! This document is outdated and has been replaced with newer documentation. See Plug-in developer: Secondary file storage plugins
This document describes how to create a plugin for managing the secondary file storage.

Contents

  1. Primary vs. secondary storage
  2. The SecondaryStorageController interface
  3. Configuration settings

See also

Last updated: $Date: 2009-04-06 14:52:39 +0200 (må, 06 apr 2009) $

1. Primary vs. secondary storage

BASE has support for storing files in two locations, the primary storage and the secondary storage. The primary storage is always disk-based and must be accessible by the BASE server as a path on the file system. The path to the primary storage is configured by the userfiles setting in the base.config file. The primary storage is internal to the core. Client applications don't get access to read or manipulate the files directly from the file system.

The secondary storage can be anything that can store files. It could for example be another directory, a remote FTP server, or a tape based archiving system. A file located in the secondary storage is not accessible by the core or client applications. The secondary storage can only be accessed by the secondary storage controller and the core (and client) applications uses flags on the File item to handle the interaction with the secondary storage.

Each file has an action attribute which default's to File.Action.NOTHING. It can take two other values:

  1. File.Action.MOVE_TO_SECONDARY
  2. File.Action.MOVE_TO_PRIMARY

All files with the action attribute set to MOVE_TO_SECONDARY should be moved to the secondary storage by the controller, and all files with the action attribute set to MOVE_TO_PRIMARY should be brought back to primary storage.

The moving of files between primary and secondary storage doesn't happen immediately. It is up to the server administrator to configure how often and at what times the controller should check for files that should be moved. This is configured by the secondary.storage.interval and secondary.storage.time settings in the base.config file.

2. The SecondaryStorageController interface

All you have to do to create a secondary storage controller is to create a class that implements the SecondaryStorageController interface. In your base.config file you then specify the class name in the secondary.storage.driver setting and it's initialisation parameters in the secondary.storage.driver setting.

Your class must have a public no-argument constructor. The BASE application will create only one instance of the class for lifetime of the BASE server. Here are the methods that you must implement:

public void init(String settings);
This method is called just after the object has been created with it's argument taken from the secondary.storage.driver setting in your base.config file. This method is only called once for an object.
public void run();
This method is called whenever the core thinks it is time to do some management of the secondary storage. How often the run() method is called is controlled by the secondary.storage.interval and secondary.storage.time settings in the base.config file.

When this method is called the controller should:

As a final act the method should send a message to each user owning files that has been moved from one location to the other. The message should include a list of files that has been moved to the secondary storage and a list of files moved from the secondary storage and a list of files that has been deleted due to some of the reasons above.

public void close();
This method is called when the server is closing down. After this the object is never used again.

3. Configuration settings

The configuration settings for the secondary storage controller is located in the base.config file. Here is an overview of the settings. For more information read the base.config reference

secondary.storage.driver
The class name of the secondary storage plugin.
secondary.storage.init
Initialisation parameters sent to the plugin by calling the init() method.
secondary.storage.interval
Interval in seconds between each execution of the controller plugin.
secondary.storage.time
Time points per day when the controller plugin should be executed.