Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.Storage.LocalObjectStore Class Reference

A local disk implementation of IObjectStore. More...

Inheritance diagram for QuantConnect.Lean.Engine.Storage.LocalObjectStore:
[legend]

Public Member Functions

virtual void Initialize (int userId, int projectId, string userToken, Controls controls)
 Initializes the object store More...
 
void Clear ()
 Will clear the object store state cache. This is useful when the object store is used concurrently by nodes which want to share information More...
 
bool ContainsKey (string path)
 Determines whether the store contains data for the specified path More...
 
byte[] ReadBytes (string path)
 Returns the object data for the specified path More...
 
bool SaveBytes (string path, byte[] contents)
 Saves the object data for the specified path More...
 
bool Delete (string path)
 Deletes the object data for the specified path More...
 
virtual string GetFilePath (string path)
 Returns the file path for the specified path More...
 
virtual void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 
IEnumerator< KeyValuePair< string, byte[]> > GetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 

Static Public Attributes

static string DefaultObjectStore => Path.GetFullPath(Config.Get("object-store-root", "./storage"))
 Gets the default object store location More...
 

Protected Member Functions

virtual string StorageRoot ()
 Storage root path More...
 
bool InternalSaveBytes (string path, byte[] contents)
 Won't trigger persist nor will check storage write permissions, useful on initialization since it allows read only permissions to load the object store More...
 
virtual bool IsWithinStorageLimit (string path, byte[] contents, bool takePersistLock)
 Validates storage limits are respected on a new save operation More...
 
string PathForKey (string path)
 Get's a file path for a given path. Internal use only because it does not guarantee the existence of the file. More...
 
virtual bool PersistData ()
 Overridable persistence function More...
 
virtual void OnErrorRaised (Exception error)
 Event invocator for the ErrorRaised event More...
 

Static Protected Attributes

const string NoReadPermissionsError
 No read permissions error message More...
 
const string NoWritePermissionsError
 No write permissions error message More...
 

Properties

Controls Controls [get]
 Provides access to the controls governing behavior of this instance, such as the persistence interval More...
 
string AlgorithmStorageRoot [get]
 The root storage folder for the algorithm More...
 
FileHandler FileHandler = new () [get, set]
 The file handler instance to use More...
 
ICollection< string > Keys [get]
 Returns the file paths present in the object store. This is specially useful not to load the object store into memory More...
 
- Properties inherited from QuantConnect.Interfaces.IObjectStore
ICollection< string > Keys [get]
 Returns the file paths present in the object store. This is specially useful not to load the object store into memory More...
 

Events

EventHandler< ObjectStoreErrorRaisedEventArgsErrorRaised
 Event raised each time there's an error More...
 
- Events inherited from QuantConnect.Interfaces.IObjectStore
EventHandler< ObjectStoreErrorRaisedEventArgsErrorRaised
 Event raised each time there's an error More...
 

Detailed Description

A local disk implementation of IObjectStore.

Definition at line 35 of file LocalObjectStore.cs.

Member Function Documentation

◆ Initialize()

virtual void QuantConnect.Lean.Engine.Storage.LocalObjectStore.Initialize ( int  userId,
int  projectId,
string  userToken,
Controls  controls 
)
virtual

Initializes the object store

Parameters
userIdThe user id
projectIdThe project id
userTokenThe user token
controlsThe job controls instance

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 91 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ StorageRoot()

virtual string QuantConnect.Lean.Engine.Storage.LocalObjectStore.StorageRoot ( )
protectedvirtual

Storage root path

Definition at line 112 of file LocalObjectStore.cs.

Here is the caller graph for this function:

◆ Clear()

void QuantConnect.Lean.Engine.Storage.LocalObjectStore.Clear ( )

Will clear the object store state cache. This is useful when the object store is used concurrently by nodes which want to share information

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 179 of file LocalObjectStore.cs.

◆ ContainsKey()

bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.ContainsKey ( string  path)

Determines whether the store contains data for the specified path

Parameters
pathThe object path
Returns
True if the key was found

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 192 of file LocalObjectStore.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadBytes()

byte [] QuantConnect.Lean.Engine.Storage.LocalObjectStore.ReadBytes ( string  path)

Returns the object data for the specified path

Parameters
pathThe object path
Returns
A byte array containing the data

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 224 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ SaveBytes()

bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.SaveBytes ( string  path,
byte[]  contents 
)

Saves the object data for the specified path

Parameters
pathThe object path
contentsThe object data
Returns
True if the save operation was successful

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 253 of file LocalObjectStore.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InternalSaveBytes()

bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.InternalSaveBytes ( string  path,
byte[]  contents 
)
protected

Won't trigger persist nor will check storage write permissions, useful on initialization since it allows read only permissions to load the object store

Definition at line 295 of file LocalObjectStore.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWithinStorageLimit()

virtual bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.IsWithinStorageLimit ( string  path,
byte[]  contents,
bool  takePersistLock 
)
protectedvirtual

Validates storage limits are respected on a new save operation

Definition at line 311 of file LocalObjectStore.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Delete()

bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.Delete ( string  path)

Deletes the object data for the specified path

Parameters
pathThe object path
Returns
True if the delete operation was successful

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 365 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ GetFilePath()

virtual string QuantConnect.Lean.Engine.Storage.LocalObjectStore.GetFilePath ( string  path)
virtual

Returns the file path for the specified path

If the key is not already inserted it will just return a path associated with it and add the key with null value

Parameters
pathThe object path
Returns
The path for the file

Implements QuantConnect.Interfaces.IObjectStore.

Definition at line 404 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ Dispose()

virtual void QuantConnect.Lean.Engine.Storage.LocalObjectStore.Dispose ( )
virtual

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Definition at line 426 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ GetEnumerator()

IEnumerator<KeyValuePair<string, byte[]> > QuantConnect.Lean.Engine.Storage.LocalObjectStore.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

Returns
A T:System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection.

<filterpriority>1</filterpriority>

Definition at line 448 of file LocalObjectStore.cs.

◆ PathForKey()

string QuantConnect.Lean.Engine.Storage.LocalObjectStore.PathForKey ( string  path)
protected

Get's a file path for a given path. Internal use only because it does not guarantee the existence of the file.

Definition at line 465 of file LocalObjectStore.cs.

Here is the caller graph for this function:

◆ PersistData()

virtual bool QuantConnect.Lean.Engine.Storage.LocalObjectStore.PersistData ( )
protectedvirtual

Overridable persistence function

Returns
True if persistence was successful, otherwise false

Definition at line 518 of file LocalObjectStore.cs.

Here is the call graph for this function:

◆ OnErrorRaised()

virtual void QuantConnect.Lean.Engine.Storage.LocalObjectStore.OnErrorRaised ( Exception  error)
protectedvirtual

Event invocator for the ErrorRaised event

Definition at line 569 of file LocalObjectStore.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ NoReadPermissionsError

const string QuantConnect.Lean.Engine.Storage.LocalObjectStore.NoReadPermissionsError
staticprotected
Initial value:
= "The current user does not have permission to read from the organization Object Store." +
" Please contact your organization administrator to request permission."

No read permissions error message

Definition at line 40 of file LocalObjectStore.cs.

◆ NoWritePermissionsError

const string QuantConnect.Lean.Engine.Storage.LocalObjectStore.NoWritePermissionsError
staticprotected
Initial value:
= "The current user does not have permission to write to the organization Object Store." +
" Please contact your organization administrator to request permission."

No write permissions error message

Definition at line 46 of file LocalObjectStore.cs.

◆ DefaultObjectStore

string QuantConnect.Lean.Engine.Storage.LocalObjectStore.DefaultObjectStore => Path.GetFullPath(Config.Get("object-store-root", "./storage"))
static

Gets the default object store location

Definition at line 57 of file LocalObjectStore.cs.

Property Documentation

◆ Controls

Controls QuantConnect.Lean.Engine.Storage.LocalObjectStore.Controls
getprotected

Provides access to the controls governing behavior of this instance, such as the persistence interval

Definition at line 72 of file LocalObjectStore.cs.

◆ AlgorithmStorageRoot

string QuantConnect.Lean.Engine.Storage.LocalObjectStore.AlgorithmStorageRoot
getprotected

The root storage folder for the algorithm

Definition at line 77 of file LocalObjectStore.cs.

◆ FileHandler

FileHandler QuantConnect.Lean.Engine.Storage.LocalObjectStore.FileHandler = new ()
getsetprotected

The file handler instance to use

Definition at line 82 of file LocalObjectStore.cs.

◆ Keys

ICollection<string> QuantConnect.Lean.Engine.Storage.LocalObjectStore.Keys
get

Returns the file paths present in the object store. This is specially useful not to load the object store into memory

Definition at line 169 of file LocalObjectStore.cs.

Event Documentation

◆ ErrorRaised

EventHandler<ObjectStoreErrorRaisedEventArgs> QuantConnect.Lean.Engine.Storage.LocalObjectStore.ErrorRaised

Event raised each time there's an error

Definition at line 52 of file LocalObjectStore.cs.


The documentation for this class was generated from the following file: