public void AcquireIgniteTopologyProjections_FailWithNullOrEmptyRole() { string GridName = TRexGrids.GridName(StorageMutability.Immutable); string Role = null; Action act = () => new BaseIgniteClass(GridName, Role); act.Should().Throw <TRexException>().WithMessage("Role name not defined when acquiring topology projection"); act = () => new BaseIgniteClass(GridName, ""); act.Should().Throw <TRexException>().WithMessage("Role name not defined when acquiring topology projection"); }
public void AcquireIgniteTopologyProjections_Success() { var igniteMock = new IgniteMock(); DIBuilder.Continue() .Add(TRexGridFactory.AddGridFactoriesToDI) // Override the main Ignite grid factory method DI'ed from TRexGridFactory.AddGridFactoriesToDI() .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => igniteMock.mockIgnite.Object)) .Complete(); var ignite = new BaseIgniteClass(TRexGrids.GridName(StorageMutability.Immutable), "TestRole"); ignite.AcquireIgniteTopologyProjections(); }
public void AcquireIgniteTopologyProjections_FailWithNullComputeProjection() { var igniteMock = new IgniteMock(); // Nobble the ICompute setup to mimic a null compute projection igniteMock.mockClusterGroup.Setup(x => x.GetCompute()).Returns((ICompute)null); DIBuilder.Continue() .Add(TRexGridFactory.AddGridFactoriesToDI) // Override the main Ignite grid factory method DI'ed from TRexGridFactory.AddGridFactoriesToDI() .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => igniteMock.mockIgnite.Object)) .Complete(); var GridName = TRexGrids.GridName(StorageMutability.Immutable); var Role = "TestRole"; Action act = () => new BaseIgniteClass(GridName, Role); act.Should().Throw <TRexException>().WithMessage($"Compute projection is null in AcquireIgniteTopologyProjections on grid {GridName}"); }
public void AcquireIgniteTopologyProjections_FailWithNullIgnite() { // Ensure any injected IIgnite anf ITRexGridFactory are removed DIBuilder.Continue() .RemoveSingle <IIgnite>() .RemoveSingle <ITRexGridFactory>() .Complete(); var gridName = TRexGrids.GridName(StorageMutability.Immutable); var role = "TestRole"; Action act = () => _ = new BaseIgniteClass(gridName, role); if (DIContext.DefaultIsRequired) { act.Should().Throw <InvalidOperationException>().WithMessage("No service for type 'VSS.TRex.GridFabric.Grids.ITRexGridFactory' has been registered."); } else { act.Should().Throw <TRexException>().WithMessage("Ignite reference is null in AcquireIgniteTopologyProjections"); } }
public void AcquireIgniteTopologyProjections_FailWithEmptyClusterGroup() { var igniteMock = new IgniteMock(); // Nobble the IClusterNodes.Count() setup to mimic an empty cluster group igniteMock.mockClusterNodes.Setup(x => x.Count).Returns(0); igniteMock.mockCluster.Setup(x => x.GetNodes()).Returns((List <IClusterNode>)null); DIBuilder.Continue() .Add(TRexGridFactory.AddGridFactoriesToDI) // Override the main Ignite grid factory method DI'ed from TRexGridFactory.AddGridFactoriesToDI() .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => igniteMock.mockIgnite.Object)) .Complete(); string GridName = TRexGrids.GridName(StorageMutability.Immutable); string Role = "TestRole"; Action act = () => new BaseIgniteClass(GridName, Role); act.Should().Throw <TRexException>().WithMessage($"Group cluster topology is empty for role {Role} on grid {GridName}"); }
/// <summary> /// Default no-arg constructor supplied default TRex grid and MutableNonSpatial cache name for surveyed surface information /// </summary> public SurveyedSurfaceService(StorageMutability mutability) : base(TRexGrids.GridName(mutability), "SurveyedSurfaceService") { CacheName = TRexCaches.ImmutableNonSpatialCacheName(); }
public void dumpKeysToFile(StorageMutability mutability, string fileName) { try { var ignite = DIContext.Obtain <ITRexGridFactory>()?.Grid(mutability); if (ignite == null) { Console.WriteLine($@"----> No ignite reference for {TRexGrids.GridName(mutability)} grid"); return; } using (var outFile = new FileStream(fileName, FileMode.Create)) { using (var writer = new StreamWriter(outFile) { NewLine = "\r\n" }) { if (mutability == StorageMutability.Immutable) { Console.WriteLine($"----> Writing keys for {TRexCaches.ImmutableNonSpatialCacheName()}"); try { writeKeys(TRexCaches.ImmutableNonSpatialCacheName(), writer, ignite.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.ImmutableNonSpatialCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.DesignTopologyExistenceMapsCacheName()}"); try { writeKeys(TRexCaches.DesignTopologyExistenceMapsCacheName(), writer, ignite.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.DesignTopologyExistenceMapsCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable)}"); try { WriteKeysSpatial(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable), writer, ignite.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable))); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Immutable)}"); try { WriteKeysSpatial(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Immutable), writer, ignite.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Immutable))); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SiteModelChangeMapsCacheName()}"); try { writeSiteModelChangeMapQueueKeys(TRexCaches.SiteModelChangeMapsCacheName(), writer, ignite.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SiteModelChangeMapsCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } } if (mutability == StorageMutability.Mutable) { Console.WriteLine($"----> Writing keys for {TRexCaches.MutableNonSpatialCacheName()}"); try { writeKeys(TRexCaches.MutableNonSpatialCacheName(), writer, ignite.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.MutableNonSpatialCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Mutable)}"); try { WriteKeysSpatial(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Mutable), writer, ignite.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Mutable))); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Mutable)}"); try { WriteKeysSpatial(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Mutable), writer, ignite.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Mutable))); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.TAGFileBufferQueueCacheName()}"); try { writeTAGFileBufferQueueKeys(TRexCaches.TAGFileBufferQueueCacheName(), writer, ignite.GetCache <ITAGFileBufferQueueKey, TAGFileBufferQueueItem>(TRexCaches.TAGFileBufferQueueCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } Console.WriteLine($"----> Writing keys for {TRexCaches.SegmentRetirementQueueCacheName()}"); try { writeSegmentRetireeQueueKeys(TRexCaches.SegmentRetirementQueueCacheName(), writer, ignite.GetCache <ISegmentRetirementQueueKey, SegmentRetirementQueueItem>(TRexCaches.SegmentRetirementQueueCacheName())); } catch (Exception E) { writer.WriteLine($"Exception occurred: {E.Message}"); } } } } } catch (Exception ee) { Console.WriteLine(ee.ToString()); } }
public void ImmutableGridName() { TRexGrids.GridName(StorageMutability.Immutable).Should().NotBeNullOrWhiteSpace(); TRexGrids.MutableGridName().Should().Be(TRexGrids.GridName(StorageMutability.Mutable)); }
public void GridNames() { TRexGrids.GridNames().Should().Contain(TRexGrids.GridName(StorageMutability.Mutable), TRexGrids.GridName(StorageMutability.Immutable)); }
/// <summary> /// Default no-arg constructor that sets the grid and cache name to default values /// </summary> public DesignsService(StorageMutability Mutability) : base(TRexGrids.GridName(Mutability), "DesignsService") { CacheName = TRexCaches.ImmutableNonSpatialCacheName(); }