Naanou.ResourceExchange
Class ResourceManager

Manages the relationship between resources (files) on disk, a database which keeps track of these and Naanou which then indexes these resources.

Field Summary
int Count
         Debug var, number of resources added on last insert
Naanou.ResourceExchange.ResourceExchanger exchange
System.Collections.ArrayList fileWatchers
bool inited
Naanou.ResourceExchange.IKeyStorage keyStorer
Naanou.Common.ILogger logger
Naanou.Common.WorkPool pool
Naanou.Common.Search.SearchDelegate SearchDelegate
string UserId

Constructor Summary
ResourceManager()
        Initializes a new instance of the ResourceManager class.

Property Summary
Naanou.ResourceExchange.ResourceExchanger Exchange
         Gets the exchanger
int KeyLifetime
         Lifetime (in minutes) for keys
Naanou.ResourceExchange.IKeyStorage KeyStorer
Naanou.Common.ILogger Logger

Method Summary
void AddDirectory(System.IO.DirectoryInfo di, bool recursive, bool threadPool)
void AddFile(string fullPath, bool threadPool)
void AddFile(System.IO.FileInfo file, bool threadPool)
void Close()
         Shuts everything down nicely
Naanou.ResourceExchange.Entry GetEntryFromHashSerial(string hashSerial)
         Gets a resource from its content hash
Naanou.ResourceExchange.Entry GetEntryFromPath(string path)
         Gets a resource from its full path
void Init(Naanou.Common.ILogger log, Naanou.ResourceExchange.IKeyStorage keyStore, string userId, string bindAddress, Naanou.Common.Search.SearchDelegate searchDel)
         Initialises ResourceManager. If already inited, will re-init.
void InitExchange()
         Initialises
bool IsShared(string path)
void Log(string msg, Naanou.Common.LogLevel level)
void Log(string message)
void RefreshLoopThread()
void RemoveAll()
         Remove all resources
void SharePath(string path, string descr, bool recursive, bool threadPool)
         Shares a path. Queues indexing of metadata for path and shares path.
void SharePath(string path, string descr, bool recursive, bool serverMount, bool threadPool)
         Shares a path. Queues indexing of metadata for path and shares path.
void UnSharePath(Naanou.ResourceExchange.ResourceExchanger.SharedMount mount)
         Removes a mount. Path must end in trailing slash if it is a directory
void UnSharePath(string path, bool recursive)
         Unshares a path

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString

Event Summary
Naanou.ResourceExchange.AddedEventHandler Added
         A resource has been added
System.EventHandler Cleared
         All resources have been cleared
Naanou.ResourceExchange.RemovedEventHandler Removed
         A resource has been removed


Field Detail

Count

internal int Count

Debug var, number of resources added on last insert


exchange

private Naanou.ResourceExchange.ResourceExchanger exchange


fileWatchers

private System.Collections.ArrayList fileWatchers


inited

private bool inited


keyStorer

private Naanou.ResourceExchange.IKeyStorage keyStorer


logger

private Naanou.Common.ILogger logger


pool

private Naanou.Common.WorkPool pool


SearchDelegate

internal Naanou.Common.Search.SearchDelegate SearchDelegate


UserId

internal string UserId

Constructor Detail

ResourceManager

private ResourceManager()

Initializes a new instance of the ResourceManager class.

Property Detail

Exchange

public Naanou.ResourceExchange.ResourceExchanger Exchange

Gets the exchanger


KeyLifetime

internal int KeyLifetime

Lifetime (in minutes) for keys


KeyStorer

internal Naanou.ResourceExchange.IKeyStorage KeyStorer


Logger

public Naanou.Common.ILogger Logger

Method Detail

AddDirectory

private void AddDirectory(System.IO.DirectoryInfo di,
                          bool recursive,
                          bool threadPool)


AddFile

private void AddFile(string fullPath,
                     bool threadPool)


AddFile

private void AddFile(System.IO.FileInfo file,
                     bool threadPool)


Close

public void Close()

Shuts everything down nicely


GetEntryFromHashSerial

internal Naanou.ResourceExchange.Entry GetEntryFromHashSerial(string hashSerial)

Gets a resource from its content hash

Parameters:
hashSerial - Hash serial
Returns:
Resource, or null if not found

GetEntryFromPath

internal Naanou.ResourceExchange.Entry GetEntryFromPath(string path)

Gets a resource from its full path

Parameters:
path - Full path
Returns:
Resource, or null if not found

Init

public void Init(Naanou.Common.ILogger log,
                 Naanou.ResourceExchange.IKeyStorage keyStore,
                 string userId,
                 string bindAddress,
                 Naanou.Common.Search.SearchDelegate searchDel)

Initialises ResourceManager. If already inited, will re-init.

Parameters:
log -
keyStore -

InitExchange

private void InitExchange()

Initialises


IsShared

public bool IsShared(string path)


Log

internal void Log(string msg,
                  Naanou.Common.LogLevel level)


Log

internal void Log(string message)


RefreshLoopThread

private void RefreshLoopThread()


RemoveAll

internal void RemoveAll()

Remove all resources


SharePath

public void SharePath(string path,
                      string descr,
                      bool recursive,
                      bool threadPool)

Shares a path. Queues indexing of metadata for path and shares path.

Parameters:
path - Path to add
descr - Description for mount (can be null)
recursive - Should all subdirectories be added also

SharePath

public void SharePath(string path,
                      string descr,
                      bool recursive,
                      bool serverMount,
                      bool threadPool)

Shares a path. Queues indexing of metadata for path and shares path.

Parameters:
path - Path to add
descr - Description for mount (can be null)
recursive - Should all subdirectories be added also
serverMount - If set to true, path will be mounted in server (set to false when sharing a path under an existing shared path)

UnSharePath

public void UnSharePath(Naanou.ResourceExchange.ResourceExchanger.SharedMount mount)

Removes a mount. Path must end in trailing slash if it is a directory

Parameters:
mount - Mount to remove

UnSharePath

internal void UnSharePath(string path,
                          bool recursive)

Unshares a path

Parameters:
path - Path
recursive - Recursive remove
Event Detail

Added

internal Naanou.ResourceExchange.AddedEventHandler Added

A resource has been added


Cleared

internal System.EventHandler Cleared

All resources have been cleared


Removed

internal Naanou.ResourceExchange.RemovedEventHandler Removed

A resource has been removed