public StorageActor(IPecanLogger logger) { this.Logger = logger; logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Creating {nameof(StorageReadActor)} .. "); //multi reader IActorRef actorReadPool = Context.ActorOf(Props.Create(() => new StorageReadActor(logger)).WithRouter(new RoundRobinPool(1000)), TypeOfWrapper.TypeOf(typeof(StorageReadActor)).Name); logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Creating {nameof(StorageWriteActor)} .. "); //single writer IActorRef actorWriteRef = Context.ActorOf(Props.Create(() => new StorageWriteActor(logger)), TypeOfWrapper.TypeOf(typeof(StorageWriteActor)).Name); this.Receive <Func <bool> >( message => { logger?.Trace(this.GetType().Name, $"{this.GetType().Name} forwarding message {message?.GetType().Name} to {actorWriteRef.Path.ToStringWithAddress()}"); actorWriteRef.Forward(message); }); this.Receive <Func <object> >( message => { logger?.Trace(this.GetType().Name, $"{this.GetType().Name} forwarding message {message?.GetType().Name} to {actorReadPool.Path.ToStringWithAddress()}"); actorReadPool.Forward(message); }); this.Receive <Terminated>( t => { string message = "Actor just got terminated : " + t.ActorRef.Path; logger?.Fatal(this.GetType().Name, message); }); }
internal Session(DatabaseService databaseService, IPecanLogger logger, string remoteServerAdrress) { this.RemoteServerAdrress = remoteServerAdrress; this.RunAsHttpClient = !string.IsNullOrEmpty(remoteServerAdrress); this.Logger = logger; this.TrackingDictionary = new Dictionary <string, TrackedObject>(); this.databaseService = databaseService; this.SessionId = Guid.NewGuid(); }
public DatabaseService(string databaseDirectory, string databaseName, ISerializationFactory serializationFactory, IStorageIO fileIo, IPecanLogger logger, bool useInMemoryStorage = false, string storageName = null) { this.Logger = logger; if (useInMemoryStorage) { fileIo = new InMemoryStorageIO(this.Logger); } this.DataBaseSettings = new DataBaseSettings(databaseName, serializationFactory, fileIo, storageName, logger, databaseDirectory); this.DirectDocumentManipulator = new DirectDocumentManipulator(this.DataBaseSettings.StorageMechanismMech, this, logger); }
public StorageReadActor(IPecanLogger logger) { this.Receive <Func <object> >( message => { if (message == null) { logger?.Fatal(this.GetType().Name, $"Error null{this.GetType().Name} message {message?.GetType().Name}"); } else { logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Executing message {message?.GetType().Name}"); this.Sender.Tell(message()); } }); }
public StorageDatabase(IStorageMechanism storageMechanism, string documentName, DatabaseService dataBaseSettings, IPecanLogger logger) { this.Logger = logger; this.Logger?.Trace(this.GetType().Name, $"Initializing storage database ..."); this.DataBaseSettings = dataBaseSettings; this.storageMechanism = storageMechanism; string dname = PecanDatabaseUtilityObj.DetermineDatabaseName <TDocumentWithObject, TObjectOnly>(documentName); this.DocumentName = dname; CurrentCount = this.storageMechanism.Count <TDocumentWithObject>(this.DocumentName, true); this.Logger?.Trace(this.GetType().Name, $"Initialized storage. Document Name {this.DocumentName} and current count {CurrentCount}"); }
public JsonStorageMechanism(IStorageSystem fileSystem, string databaseName, string rootFolder, IPecanLogger logger) { this.Logger = logger; if (string.IsNullOrEmpty(databaseName)) { throw new ArgumentNullException(nameof(databaseName)); } this._rootFolder = rootFolder; this.db = this._rootFolder + "\\" + databaseName; this.FileSystem = fileSystem; if (!this.FileSystem.DirectoryExists(this.db)) { this.FileSystem.CreateDirectory(this.db); } this.Logger?.Trace(this.GetType().Name, $"Initialized {this.GetType().Name} {this.GetContextDescription()}"); }
public DataBaseSettings(string databaseName, ISerializationFactory serializationFactory, IStorageIO fileio, string storageName, IPecanLogger logger, string baseDirectory) { if (databaseName == null) { throw new ArgumentNullException(nameof(databaseName)); } this.FileIo = fileio ?? new StorageIO(logger); if (baseDirectory != null) { baseDirectory = baseDirectory.TrimEnd('/').TrimEnd('\\').TrimEnd('/').TrimEnd('\\'); if (!this.FileIo.DirectoryExists(baseDirectory)) { this.FileIo.CreateDirectory(baseDirectory); } } DbStorageLocation = (string.IsNullOrEmpty(baseDirectory) ? AppDomain.CurrentDomain.BaseDirectory : baseDirectory) + "\\" + (string.IsNullOrEmpty(storageName) ? "pecan" : storageName); this.StorageMechanismMech = new JsonStorageMechanism( new FileStorageSystem(this, this.FileIo, serializationFactory ?? new JsonSerializationFactory(logger), logger), databaseName, DbStorageLocation, logger ); Type pecanDbLoggerType = typeof(PecanDbLogger); PecanDbLogger.DefaultPecanLogger = logger; Config akkaConfig = $@"akka.loglevel = DEBUG akka.loggers=[""{pecanDbLoggerType.FullName}, {pecanDbLoggerType.GetTypeInfo().Assembly.GetName().Name}""]"; this.AppActorSystemystem = ActorSystem.Create("StorageActorSystem-" + Guid.NewGuid().ToString(), akkaConfig); this.StorageActor = this.AppActorSystemystem.ActorOf(Props.Create(() => new StorageActor(logger)), TypeOfWrapper.TypeOf(typeof(StorageActor)).Name); this.AkkaCommonStorageMechanism = new AkkaActorSystemMechanism(this.StorageActor, this.StorageMechanismMech, this, logger); }
public FileStorageSystem(DataBaseSettings DdtaBaseSettings, IStorageIO fileIO, ISerializationFactory sf, IPecanLogger logger) { this.Logger = logger; this.DataBaseSettings = DdtaBaseSettings; this._fileIO = fileIO; this.SerializationFactory = sf; }
public AkkaActorSystemMechanism(IActorRef storageActorRef, IStorageMechanism worker, DataBaseSettings DdtaBaseSettings, IPecanLogger logger) { this.Logger = logger; this._storageActorRef = storageActorRef; this._worker = worker; this.FileSystem = this._worker?.FileSystem; this.DataBaseSettings = DdtaBaseSettings; }
public DirectDocumentManipulator(IStorageMechanism s, DatabaseService _DatabaseService, IPecanLogger logger) { this.Logger = logger; this.DatabaseService = _DatabaseService; this.sMech = s ?? throw new ArgumentNullException(nameof(s)); }
private static void LogEvent(IPecanLogger logger, TraceType level, string logSource, Exception exception, string message, params object[] parameters) { logger.Trace(logger.Name + " > " + logSource, message + " > " + exception?.Message + " > " + exception?.InnerException?.Message, null, level, parameters); }
private static void LogEvent(IPecanLogger logger, TraceType level, string logSource, string message, params object[] parameters) { LogEvent(logger, level, logSource, null, message, parameters); }
public StorageIO(IPecanLogger logger) { this.Logger = logger; }
public InMemoryStorageIO(IPecanLogger logger) { this.Logger = logger; }
public JsonSerializationFactory(IPecanLogger logger) { this.Logger = logger; }