public void SpatialCacheName() { TRexCaches.SpatialCacheName(StorageMutability.Mutable, FileSystemStreamType.SubGridDirectory).Should().Be(TRexCaches.kSpatialSubGridDirectoryMutable); TRexCaches.SpatialCacheName(StorageMutability.Mutable, FileSystemStreamType.SubGridSegment).Should().Be(TRexCaches.kSpatialSubGridSegmentMutable); TRexCaches.SpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.SubGridDirectory).Should().Be(TRexCaches.kSpatialSubGridDirectoryImmutable); TRexCaches.SpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.SubGridSegment).Should().Be(TRexCaches.kSpatialSubGridSegmentImmutable); TRexCaches.SpatialCacheName(StorageMutability.Mutable, FileSystemStreamType.SubGridExistenceMap).Should().Be(TRexCaches.kProductionDataExistenceMapCacheMutable); TRexCaches.SpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.SubGridExistenceMap).Should().Be(TRexCaches.kProductionDataExistenceMapCacheImmutable); }
/// <summary> /// Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex /// </summary> private static void AddDIEntries() { DIBuilder.Continue() .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory())) //*********************************************** // Injected factories for non-transacted proxies // ********************************************** .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType))))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType))))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => { // SiteModel change maps are only maintained on the immutable grid if (mutability != StorageMutability.Immutable) { return(null); } return(new StorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)))); })) //*********************************************** // Injected factories for transacted proxies // ********************************************** .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => { // SiteModel change maps are only maintained on the immutable grid if (mutability != StorageMutability.Immutable) { return(null); } return(new StorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer())); })); }
public void AddProxyCacheFactoriesToDI() { _tagFileBufferQueue = null; DIBuilder .Continue() // Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex ///////////////////////////////////////////////////// // Injected standard storage proxy cache factories ///////////////////////////////////////////////////// .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer()))) ///////////////////////////////////////////////////// // Injected transacted storage proxy cache factories ///////////////////////////////////////////////////// .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > > (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer()))) .Add(x => x.AddSingleton <Func <ITAGFileBufferQueue> >(factory => () => { _tagFileBufferQueue ??= new TAGFileBufferQueue(); return(_tagFileBufferQueue); })) .Build(); // Set up a singleton storage proxy for mutable and immutable contexts for tests when there is no Ignite mock available var mutableStorageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable); var immutableStorageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Immutable); DIBuilder .Continue() // Add the factory to create a single storage proxy instance. .Add(x => x.AddSingleton <Func <StorageMutability, IStorageProxy> >(factory => mutability => mutability == StorageMutability.Mutable ? mutableStorageProxy : immutableStorageProxy)) .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory())) .Build(); }