Esempio n. 1
0
        public DIIgniteServers()
        {
            // Create a set of mocked configurations for caches the servers was want
            var mockedConfigs = new List <CacheConfiguration>
            {
                new CacheConfiguration(TRexCaches.MutableNonSpatialCacheName()),
                new CacheConfiguration(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Mutable)),
                new CacheConfiguration(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable)),
                new CacheConfiguration(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Mutable)),
                new CacheConfiguration(TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Immutable)),
                new CacheConfiguration(TRexCaches.ImmutableNonSpatialCacheName()),
                new CacheConfiguration(TRexCaches.SiteModelMetadataCacheName()),
                new CacheConfiguration(TRexCaches.DesignTopologyExistenceMapsCacheName()),
                new CacheConfiguration(TRexCaches.TAGFileBufferQueueCacheName()),
                new CacheConfiguration(TRexCaches.SegmentRetirementQueueCacheName()),
                new CacheConfiguration(TRexCaches.SiteModelChangeBufferQueueCacheName()),
                new CacheConfiguration(TRexCaches.ProductionDataExistenceMapCacheName(StorageMutability.Mutable)),
                new CacheConfiguration(TRexCaches.ProductionDataExistenceMapCacheName(StorageMutability.Mutable))
            };

            var igniteConfiguration = new IgniteConfiguration
            {
                CacheConfiguration = mockedConfigs
            };

            // Get the mocked Ignite instance and add the configuration to it
            IgniteMock.Immutable.mockIgnite.Setup(x => x.GetConfiguration()).Returns(igniteConfiguration);
            IgniteMock.Mutable.mockIgnite.Setup(x => x.GetConfiguration()).Returns(igniteConfiguration);
        }
Esempio n. 2
0
        /// <summary>
        /// Executes a request through it's generic types asynchronously
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="key">The spatial affinity key to be used to direct this request to the node owning the partition it maps to</param>
        /// <returns></returns>
        public virtual Task <TResponse> ExecuteAsync(TArgument arg, ISubGridSpatialAffinityKey key)
        {
            if (key == null)
            {
                throw new TRexException("Affinity based result execution requires an affinity key");
            }

            // Construct the function to be used
            var func = new TComputeFunc
            {
                Argument = arg
            };

            // Send the result to the affinity bound node compute pool
            return(Compute != null?Compute.AffinityCallAsync(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable), key, func) : Task.FromResult <TResponse>(null));
        }
Esempio n. 3
0
 public void NonNullNames()
 {
     TRexCaches.DesignTopologyExistenceMapsCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.ImmutableNonSpatialCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Mutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Immutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.SpatialSubGridSegmentCacheName(StorageMutability.Mutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.MutableNonSpatialCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.SegmentRetirementQueueCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.SiteModelMetadataCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.SiteModelsCacheName(StorageMutability.Immutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.SiteModelsCacheName(StorageMutability.Mutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.TAGFileBufferQueueCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.SiteModelChangeMapsCacheName().Should().NotBeNullOrWhiteSpace();
     TRexCaches.ProductionDataExistenceMapCacheName(StorageMutability.Immutable).Should().NotBeNullOrWhiteSpace();
     TRexCaches.ProductionDataExistenceMapCacheName(StorageMutability.Mutable).Should().NotBeNullOrWhiteSpace();
 }
Esempio n. 4
0
        public ICache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> InstantiateSpatialSubGridDirectoryCacheReference()
        {
            var cfg = new CacheConfiguration();

            base.ConfigureImmutableSpatialCache(cfg);

            cfg.Name = TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable);
            cfg.KeepBinaryInStore = true;

            // TODO: No backups for now
            cfg.Backups = 0;

            // Spatial data is partitioned among the server grid nodes according to spatial affinity mapping
            cfg.CacheMode = CacheMode.Partitioned;

            // Configure the function that maps sub grid data into the affinity map for the nodes in the grid
            cfg.AffinityFunction = new SubGridBasedSpatialAffinityFunction();

            return(immutableTRexGrid.GetOrCreateCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(cfg));
        }
Esempio n. 5
0
 /// <summary>
 /// Default no-args constructor that prepares a spatial affinity partition map for the immutable spatial caches
 /// </summary>
 public ImmutableSpatialAffinityPartitionMap() :
     base(DIContext.Obtain <ITRexGridFactory>()?.Grid(StorageMutability.Immutable)
          .GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialSubGridDirectoryCacheName(StorageMutability.Immutable)))
 {
 }
Esempio n. 6
0
        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());
            }
        }