/// <summary> /// </summary> /// <param name="runtime"></param> /// <param name="token"></param> protected BaseCallbackStore(IInsightRuntime runtime, CancellationToken token) { this.singleAccessLock = new SemaphoreSlim(1); this.callbackMap = new Dictionary <NotifyFilter, IList <Func <ScenarioData, Task> > >(); this.Runtime = runtime; string typeName = this.GetType().ToString(); this.Logger = this.Runtime.GetLogProvider().CreateLoggerInstance(typeName.Split('.').Last()); this.taskRunner = runtime.TaskRunner; this.InternalTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); token = this.InternalTokenSource.Token; this.Query = this.Runtime.GetService(typeof(IClusterQuery)) as IClusterQuery; Assert.IsNotNull(this.Query, "Runtime doesn't contain valid Cluster Query object"); // Some signals may not show up immedietly so we don't want their last seen time bailing on us. this.signalSeenTillThisTimeStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForTimeAsync(SignalSeenTillTimeStoreName, AgeBasedRetentionPolicy.TwoWeek, token).GetAwaiter().GetResult(); // This store keeps track of unique Ids of signals seen to avoid duplicate reporting. The entries in this // collection needs to be long lived. Consider a signal that is living in the system for a long time // If we don't track that this has been reported, we may try to report it again. this.reportedSignalsUniqueIdsStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForIntAsync(ReportedSignalUniqueIdsStoreName, AgeBasedRetentionPolicy.OneWeek, token).GetAwaiter().GetResult(); this.signalsInDispatchQueuePersistentStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForStringsAsync(SignalsInDispatchQueueStoreName, AgeBasedRetentionPolicy.OneHour, token).GetAwaiter().GetResult(); this.producerConsumerBufferBlock = new BufferBlock <ScenarioNotificationData>(); this.InitSignalSeenBookmarkStoreAsync(token).Wait(token); }
public SizeTracker(uint shardId, IPersistentStore store, IClock clock, PersistentCacheOptions options) { this.shardId = shardId; this.store = store; this.options = options; this.clock = clock; }
private void CreateContext() { ServiceContainer container = new ServiceContainer(); container.AddService(typeof(UserSession), Session); ObjectContext context = new ObjectContext(container); var mapperRegistry = context.GetService <IObjectMapperFactoryRegistry>(); mapperRegistry.RegisterFactory(typeof(SystemCardsMapperFactory)); mapperRegistry.RegisterFactory(typeof(BackOfficeMapperFactory)); mapperRegistry.RegisterFactory(typeof(ApprovalDesignerMapperFactory)); //mapperRegistry.RegisterFactory(typeof(ACSGroup.NormativeDocumentManagement.ObjectModel.Mapping.NormativeDocumentManagementMapperFactory)); var serviceRegistry = context.GetService <IServiceFactoryRegistry>(); serviceRegistry.RegisterFactory(typeof(SystemCardsServiceFactory)); serviceRegistry.RegisterFactory(typeof(BackOfficeServiceFactory)); serviceRegistry.RegisterFactory(typeof(ApprovalDesignerServiceFactory)); // serviceRegistry.RegisterFactory(typeof(ACSGroup.NormativeDocumentManagement.ObjectModel.Services.NormativeDocumentManagementServiceFactory)); IMetadataProvider metaProvider = DocsVisionObjectFactory.CreateMetadataProvider(Session); IMetadataManager metaManager = DocsVisionObjectFactory.CreateMetadataManager(metaProvider, Session); context.AddService(metaManager); context.AddService(metaProvider); IPersistentStore store = DocsVisionObjectFactory.CreatePersistentStore(Session, null); context.AddService(store); Context = context; }
public override NodeAVL Last(IPersistentStore store, NodeAVL x) { if (x == null) { return(null); } NodeAVL nLeft = x.nLeft; if (nLeft != null) { x = nLeft; for (NodeAVL eavl3 = x.nRight; eavl3 != null; eavl3 = x.nRight) { x = eavl3; } return(x); } NodeAVL eavl4 = x; x = x.nParent; while ((x != null) && (eavl4 == x.nLeft)) { eavl4 = x; x = x.nParent; } return(x); }
protected BaseCallbackStore(IStoreProvider storeProvider, ITaskRunner taskRunner, ILogProvider logProvider, CancellationToken token) { Assert.IsNotNull(storeProvider, "Store Provider can't be null"); Assert.IsNotNull(taskRunner, "Task Runner can't be null"); Assert.IsNotNull(logProvider, "Log Provider can't be null"); this.singleAccessLock = new SemaphoreSlim(1); this.callbackMap = new Dictionary <NotifyFilter, IList <Func <ScenarioData, Task> > >(); this.Logger = logProvider.CreateLoggerInstance(this.GetType().ToString().Split('.').Last()); this.taskRunner = taskRunner; this.InternalTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); token = this.InternalTokenSource.Token; // Some signals may not show up immedietly so we don't want their last seen time bailing on us. this.callBackCheckPointTimeStore = storeProvider.CreatePersistentStoreForTimeAsync(CallbackTimeBookmarkStore, AgeBasedRetentionPolicy.OneDay, token) .GetAwaiter().GetResult(); // This store keeps track of unique Ids of signals seen to avoid duplicate reporting. The entries in this // collection needs to be long lived. Consider a signal that is living in the system for a long time // If we don't track that this has been reported, we may try to report it again. this.reportedSignalsUniqueIdsStore = storeProvider .CreatePersistentStoreKeyGuidValueStringAsync(ReportedSignalUniqueIdsStoreName, AgeBasedRetentionPolicy.OneWeek, token).GetAwaiter() .GetResult(); this.signalsInDispatchQueuePersistentStore = storeProvider .CreatePersistentStoreKeyGuidValueStringAsync(SignalsInDispatchQueueStoreName, AgeBasedRetentionPolicy.OneHour, token).GetAwaiter().GetResult(); this.producerConsumerBufferBlock = new BufferBlock <ScenarioNotificationData>(); this.InitSignalSeenBookmarkStoreAsync(token).Wait(token); }
public override void Replace(IPersistentStore store, Index index, NodeAVL n) { NodeAVLDisk node = this; RowAVLDisk row = this.row; if (!row.KeepInMemory(true)) { row = (RowAVLDisk)store.Get(this.row, true); node = (NodeAVLDisk)row.GetNode(this._iId); } if (node._iParent == -1) { if (n != null) { n = n.SetParent(store, null); } store.SetAccessor(index, n); } else { bool isLeft = node.IsFromLeft(store); node.GetParent(store).Set(store, isLeft, n); } row.KeepInMemory(false); }
public override NodeAVL SetParent(IPersistentStore store, NodeAVL n) { NodeAVLDisk node = this; RowAVLDisk row = this.row; if (!row.KeepInMemory(true)) { row = (RowAVLDisk)store.Get(this.row, true); node = (NodeAVLDisk)row.GetNode(this._iId); } if (!row.IsInMemory()) { row.KeepInMemory(false); throw Error.RuntimeError(0xc9, "NodeAVLDisk"); } row.SetNodesChanged(); node._iParent = (n == null) ? -1 : n.GetPos(); if ((n != null) && !n.IsInMemory()) { n = this.FindNode(store, n.GetPos()); } node.nParent = n; row.KeepInMemory(false); return(node); }
public override NodeAVL Next(Session session, IPersistentStore store, NodeAVL x) { if (x == null) { return(null); } lock (base._lock) { Label_0012: x = this.Next(store, x); if ((x != null) && (session != null)) { Row memoryRow = x.MemoryRow; if (!session.database.TxManager.CanRead(session, memoryRow, 0, null)) { goto Label_0012; } } else { return(x); } return(x); } }
/// <summary> /// Initializes a new instance of the <see cref="CTStore"/> class /// </summary> /// <param name="persistentStore">Persistent store for CT store</param> /// <param name="cache">Cache for CT store</param> public CTStore(IPersistentStore persistentStore, ICache cache) { this.persistentStore = persistentStore; this.cache = cache; this.config = new Configuration(); this.executionManager = new ExecutionManager(this.persistentStore, this.cache, this.config); }
public virtual NodeAVL Last(IPersistentStore store, NodeAVL x) { if (x == null) { return(null); } NodeAVL left = x.GetLeft(store); if (left != null) { x = left; for (NodeAVL eavl3 = x.GetRight(store); eavl3 != null; eavl3 = x.GetRight(store)) { x = eavl3; } return(x); } NodeAVL eavl4 = x; x = x.GetParent(store); while ((x != null) && eavl4.Equals(x.GetLeft(store))) { eavl4 = x; x = x.GetParent(store); } return(x); }
public bool IsEmpty(IPersistentStore store) { lock (this._lock) { return(this.GetAccessor(store) == null); } }
public int Size(Session session, IPersistentStore store) { lock (this._lock) { return(store.ElementCount(session)); } }
public IRowIterator FirstRow(IPersistentStore store) { IRowIterator iterator; int num = 0; Monitor.Enter(this._lock); try { NodeAVL accessor = this.GetAccessor(store); NodeAVL left = accessor; while (left != null) { accessor = left; left = accessor.GetLeft(store); num++; } iterator = this.GetIterator(null, store, accessor, false, false); } finally { this.Depth = num; Monitor.Exit(this._lock); } return(iterator); }
public IRowIterator FirstRow(Session session, IPersistentStore store) { IRowIterator iterator; int num = 0; Monitor.Enter(this._lock); try { NodeAVL accessor = this.GetAccessor(store); NodeAVL left = accessor; while (left != null) { accessor = left; left = accessor.GetLeft(store); num++; } while ((session != null) && (accessor != null)) { Row row = accessor.GetRow(store); if (session.database.TxManager.CanRead(session, row, 0, null)) { break; } accessor = this.Next(store, accessor); } iterator = this.GetIterator(session, store, accessor, false, false); } finally { this.Depth = num; Monitor.Exit(this._lock); } return(iterator); }
public void CheckInsert(Session session, Table table, object[] data, bool isNew) { int constType = this.ConstType; if (constType == 0) { IPersistentStore rowStore = session.sessionData.GetRowStore(this.Core.MainTable); if (ArrayUtil.HasNull(data, this.Core.RefCols)) { if (this.Core.MatchType == 0x3b) { return; } if (this.Core.RefCols.Length == 1) { return; } if (ArrayUtil.HasAllNull(data, this.Core.RefCols)) { return; } } else if (this.Core.MainIndex.ExistsParent(session, rowStore, data, this.Core.RefCols)) { return; } throw this.GetException(data); } if ((constType == 3) && !this._isNotNull) { this.CheckCheckConstraint(session, table, data); } }
public int SizeUnique(IPersistentStore store) { lock (this._lock) { return(store.ElementCountUnique(this)); } }
public override void Delete(IPersistentStore store) { for (NodeAVL eavl = this.NPrimaryNode; eavl != null; eavl = eavl.nNext) { eavl.Delete(); } }
public virtual ICachedObject Get(ICachedObject obj, IPersistentStore store, bool keep) { int pos; lock (this.Lock) { if (obj.IsInMemory()) { if (keep) { obj.KeepInMemory(true); } return(obj); } pos = obj.GetPos(); if (pos < 0) { return(null); } obj = this.cache.Get(pos); if (obj != null) { if (keep) { obj.KeepInMemory(true); } return(obj); } } return(this.GetFromFile(pos, store, keep)); }
/// <summary> /// Resets a list of <see cref="WorkQueue"/> items. /// </summary> /// <param name="items">List of <see cref="WorkQueue"/> to be reset</param> /// <param name="newScheduledTime">The new scheduled start date/time for the entries</param> /// <param name="expirationTime">The new expiration start date/time for the entries</param> public void ResetWorkQueueItems(IList <WorkQueue> items, DateTime newScheduledTime, DateTime expirationTime) { if (items == null || items.Count == 0) { return; } IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IReadContext ctx = store.OpenReadContext()) { IWebResetWorkQueue broker = ctx.GetBroker <IWebResetWorkQueue>(); foreach (WorkQueue item in items) { WebResetWorkQueueParameters parameters = new WebResetWorkQueueParameters { WorkQueueKey = item.Key, NewScheduledTime = newScheduledTime, NewExpirationTime = expirationTime }; if (!broker.Execute(parameters)) { Platform.Log(LogLevel.Error, "Unexpected error when calling WebResetWorkQueue stored procedure. Could not reset {0} work queue entry {1}", item.WorkQueueTypeEnum.Description, item.Key); } } } }
protected override void OnProcess(Model.ServiceLock item) { _store = PersistentStoreRegistry.GetDefaultStore(); using (ServerExecutionContext context = new ServerExecutionContext()) { IServerPartitionEntityBroker broker = context.ReadContext.GetBroker <IServerPartitionEntityBroker>(); ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria(); criteria.AeTitle.SortAsc(0); _partitions = broker.Find(criteria); } ServerFilesystemInfo info = FilesystemMonitor.Instance.GetFilesystemInfo(item.FilesystemKey); Platform.Log(LogLevel.Info, "Starting reinventory of filesystem: {0}", info.Filesystem.Description); ReinventoryFilesystem(info.Filesystem); item.ScheduledTime = item.ScheduledTime.AddDays(1); if (CancelPending) { Platform.Log(LogLevel.Info, "Filesystem Reinventory of {0} has been canceled, rescheduling. Note that the entire Filesystem will be reinventoried again.", info.Filesystem.Description); UnlockServiceLock(item, true, Platform.Time.AddMinutes(1)); } else { Platform.Log(LogLevel.Info, "Filesystem Reinventory of {0} has completed.", info.Filesystem.Description); UnlockServiceLock(item, false, Platform.Time.AddDays(1)); } }
/// <summary> /// Initializes a new instance of the <see cref="CTStore"/> class /// </summary> /// <param name="persistentStore">Persistent store for CT store</param> /// <param name="cache">Cache for CT store</param> /// <param name="config">Store configuration</param> public CTStore(IPersistentStore persistentStore, ICache cache, Configuration config) { this.persistentStore = persistentStore; this.cache = cache; this.config = config; this.executionManager = new ExecutionManager(persistentStore, cache, config); }
public NodeAVL Last(Session session, IPersistentStore store, NodeAVL x) { if (x == null) { return(null); } lock (this._lock) { Label_0012: x = this.Last(store, x); if (x != null) { if (session == null) { return(x); } Row row = x.GetRow(store); if (!session.database.TxManager.CanRead(session, row, 0, null)) { goto Label_0012; } } else { return(x); } return(x); } }
public IPersistentStore GetSubqueryRowStore(TableBase table) { IPersistentStore store = this.persistentStoreCollection.GetStore(table); store.RemoveAll(); return(store); }
public Result InsertSingleRow(Session session, IPersistentStore store, object[] data) { if (base.BaseTable.TriggerLists[6].Length != 0) { base.BaseTable.FireTriggers(session, 6, null, data, null); } base.BaseTable.InsertSingleRow(session, store, data, null); PerformIntegrityChecks(session, base.BaseTable, null, data, null); if (session.database.IsReferentialIntegrity()) { int index = 0; int length = base.BaseTable.FkConstraints.Length; while (index < length) { base.BaseTable.FkConstraints[index].CheckInsert(session, base.BaseTable, data, true); index++; } } if (base.BaseTable.TriggerLists[3].Length != 0) { base.BaseTable.FireTriggers(session, 3, null, data, null); } if (base.BaseTable.TriggerLists[0].Length != 0) { base.BaseTable.FireTriggers(session, 0, null); } return(Result.UpdateOneResult); }
public override Result GetResult(Session session) { this.CheckAccessRights(session); object[] dynamicArguments = session.sessionContext.DynamicArguments; IPersistentStore rowStore = base.BaseTable.GetRowStore(session); int actionType = this.ActionType; switch (actionType) { case 0x12: { Row row = this.GetRow(session, dynamicArguments); if ((row == null) || row.IsDeleted(session, rowStore)) { throw Error.GetError(0xe25); } RowSetNavigatorDataChange navigator = new RowSetNavigatorDataChange(); navigator.AddRow(row); StatementDML.Delete(session, base.BaseTable, navigator); break; } case 50: { object[] newRowData = base.BaseTable.GetNewRowData(session); for (int i = 0; i < newRowData.Length; i++) { newRowData[base.BaseColumnMap[i]] = dynamicArguments[i]; } return(base.InsertSingleRow(session, rowStore, newRowData)); } default: if (actionType == 0x51) { Row row = this.GetRow(session, dynamicArguments); if ((row == null) || row.IsDeleted(session, rowStore)) { throw Error.GetError(0xe25); } RowSetNavigatorDataChange navigator = new RowSetNavigatorDataChange(); object[] data = (object[])row.RowData.Clone(); bool[] newColumnCheckList = base.BaseTable.GetNewColumnCheckList(); for (int i = 0; i < base.BaseColumnMap.Length; i++) { if (this.Types[i] != SqlType.SqlAllTypes) { data[base.BaseColumnMap[i]] = dynamicArguments[i]; newColumnCheckList[base.BaseColumnMap[i]] = true; } } int[] columnMap = ArrayUtil.BooleanArrayToIntIndexes(newColumnCheckList); navigator.AddRow(session, row, data, base.BaseTable.GetColumnTypes(), columnMap); base.Update(session, base.BaseTable, navigator); } break; } return(Result.UpdateOneResult); }
public override NodeAVL Child(IPersistentStore store, bool isleft) { if (!isleft) { return(this.GetRight(store)); } return(this.GetLeft(store)); }
public static async Task <IEnumerable <TOutput> > RetreiveAllObjectFromStringStoreAsync <TOutput, TKey>( this IPersistentStore <TKey, string> store, CancellationToken token) { var inMemoryState = await store.GetAllValuesAsync(token).ConfigureAwait(false); return(inMemoryState.Select(one => InsightsUtil.DeSerialize <TOutput>(one.Value)).ToList()); }
public override NodeAVL Set(IPersistentStore store, bool isLeft, NodeAVL n) { if (n != null) { n.SetParent(store, this); } return(isLeft ? this.SetLeft(store, n) : this.SetRight(store, n)); }
public RangeIteratorBase(Session session, IPersistentStore store, TableBase t, int position) { this.session = session; this.rangePosition = position; this.Store = store; this.It = t.GetRowIterator(store); this.isBeforeFirst = true; }
public virtual bool IsFromLeft(IPersistentStore store) { if (this.nParent != null) { return(this == this.nParent.nLeft); } return(true); }
//public event EventHandler<NetLogWatcherEventArgs> SystemFound; public NetLogWatcher(IPersistentStore persistentStore) { if (persistentStore == null) throw new ArgumentNullException("persistentStore"); _persistentStore = persistentStore; Watcher = new FileSystemWatcher(); VisitedSystems = new List<SystemPosition>(); _netlogfiles = new Dictionary<string, NetLogFileInfo>(); Watcher.Changed += Watcher_Changed; Status = NetLogWatcherStatus.Initialized; }
private static FakeBus StickABusInIt(IPersistentStore store) { var bus = new FakeBus(); var depositDetector = new DepositDetector(new Repository<LabelDepositJob>(new EventStore(bus))); bus.RegisterHandler<FileDeposit>(depositDetector.Handle); var depositHandler = new DepositHandler(store); bus.RegisterHandler<DepositDetected>(depositHandler.Handle); return bus; }
public CommandComponent(ITinyMessengerHub hub, IPersistentStore store) : base(hub) { if (hub == null) throw new ArgumentNullException("hub"); log.Info("Initializing Command component..."); this.store = store; hub.Subscribe<InvokeCommandMessage>(this.OnBotCommandMessage); Commands = new List<ICommand>(); LoadCommands(); RegisterCommands(); }
public Bot(string configFilePath) { BasicConfigurator.Configure(); log.Info("Initalizing bot..."); ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; configSource = new IniConfigSource(configFilePath); IConfig config = configSource.Configs["global"]; store = new JsonPersistentStore("store.json"); components.Add(new CommandComponent(hub, store)); components.Add(new ProcessorComponent(hub, config)); //components.Add(new CliComponent(hub)); components.Add(new TaskComponent(hub, store)); components.Add(new ClojureComponent(hub)); irc = new IrcComponent(hub, config); components.Add(irc); }
public NowPlaying([Import("Store")] IPersistentStore store) { this.store = store; }
protected override void OnProcess(Model.ServiceLock item) { _store = PersistentStoreRegistry.GetDefaultStore(); using (ServerExecutionContext context = new ServerExecutionContext()) { IServerPartitionEntityBroker broker = context.ReadContext.GetBroker<IServerPartitionEntityBroker>(); ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria(); criteria.AeTitle.SortAsc(0); _partitions = broker.Find(criteria); } ServerFilesystemInfo info = FilesystemMonitor.Instance.GetFilesystemInfo(item.FilesystemKey); Platform.Log(LogLevel.Info, "Starting reinventory of filesystem: {0}", info.Filesystem.Description); ReinventoryFilesystem(info.Filesystem); item.ScheduledTime = item.ScheduledTime.AddDays(1); if (CancelPending) { Platform.Log(LogLevel.Info, "Filesystem Reinventory of {0} has been canceled, rescheduling. Note that the entire Filesystem will be reinventoried again.", info.Filesystem.Description); UnlockServiceLock(item, true, Platform.Time.AddMinutes(1)); } else { Platform.Log(LogLevel.Info, "Filesystem Reinventory of {0} has completed.", info.Filesystem.Description); UnlockServiceLock(item, false, Platform.Time.AddDays(1)); } }
// events private async void EliteExplorer_Load(object sender, EventArgs e) { if (ParseUser.CurrentUser != null) { // do stuff with the user _user = UserMapper.Map(ParseUser.CurrentUser); } else { // show the signup or login screen if (!ConfigurationManager.AppSettings.HasKeys()) { // TODO: Form Popup to signup ConfigurationManager.AppSettings.Add("commander", "The Mule"); } else { // TODO: Login screen popup var login = new Login(); var a = true; while (a) if (login.ShowDialog() == DialogResult.OK) { var commander = login.UsernameText; var pass = login.PasswordText; try { await ParseUser.LogInAsync(commander, pass); // Login was successful. a = !a; } catch (Exception ex) { // The login failed. Check the error to see why. MessageBox.Show(ex.Message); } } } } _persistentStore = new ParsePersistentStore(_user); _watcher = new NetLogWatcher(_persistentStore); _watcher.Watcher.Path = @"C:\Users\John Goode\AppData\Local\Frontier_Developments\Products\FORC-FDEV-D-1003\Logs"; // C:\Users\John Goode\AppData\Local\Frontier_Developments\Products\FORC-FDEV-D-1003\Logs _watcher.OnNewPosition += new NetLogWatcherHandler(this.NewPosition); //_watcher.SystemFound += _watcher_SystemFound; _watcher.Start(); }