2.17.2: 2011-06-17

net.sf.basedb.core
Class InternalStorageController

java.lang.Object
  extended by net.sf.basedb.core.InternalStorageController
All Implemented Interfaces:
SecondaryStorageController

final class InternalStorageController
extends Object
implements SecondaryStorageController

A simple implementation of a secondary storage controller which just moves files to another directory. In the secondary storage the files are named according to their ID in the database. This is neccessary because we need to be able to detect if a file has been deleted from the database or not.

The configuration is done in the base.config file with the following settings:

Setting Default/possible value(s) Description
secondary.storage.driver net.sf.basedb.core.InternalStorageController The class name of the secondary storage controller.
secondary.storage.init - The path to the seconday storage directory.

This class logs information to a logger named net.sf.basedb.core.storage. Configure the settings for the logger in the log4j.properties file.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-10-28 08:20:24 +0200 (Thu, 28 Oct 2010) $

Nested Class Summary
private static class InternalStorageController.StorageKeyring
          Our own keyring containing the permissions we need to move the files.
 
Field Summary
private static Logger log
          Log storage events.
private  File path
          The path to the directory where the secondary storage is located.
private  SessionControl sc
          The session controller.
 
Constructor Summary
InternalStorageController()
          Create the storage controller.
 
Method Summary
 void close()
          Cleanup
 void init(String settings)
          Initialises the object.
private  void moveToPrimary(int fileId)
           
private  void moveToSecondary(int fileId)
           
 void run()
          Check the database for files for waiting to be moved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
Log storage events.


sc

private SessionControl sc
The session controller. We are logging in using our own keyring: InternalStorageController.StorageKeyring.


path

private File path
The path to the directory where the secondary storage is located.

Constructor Detail

InternalStorageController

InternalStorageController()
Create the storage controller. The one and only instance is created by Application.start

Method Detail

init

public void init(String settings)
          throws BaseException
Description copied from interface: SecondaryStorageController
Initialises the object. The BASE core calls this method immediatly after the object has been created. The contents and syntax of the settings string should be defined by the implementing class. It may for example be the path to another directory of information about how to connect to a remote FTP server.

Specified by:
init in interface SecondaryStorageController
Parameters:
settings - A string containing initialisation parameters
Throws:
BaseException - If the parameters are invalid

run

public void run()
Check the database for files for waiting to be moved.

Specified by:
run in interface SecondaryStorageController

close

public void close()
Cleanup

Specified by:
close in interface SecondaryStorageController

moveToPrimary

private void moveToPrimary(int fileId)
                    throws Throwable
Throws:
Throwable

moveToSecondary

private void moveToSecondary(int fileId)
                      throws Throwable
Throws:
Throwable

2.17.2: 2011-06-17