Пример #1
0
        public void GeoTrackerServerSettings_ConfigDefault()
        {
            try
            {
                Config.SetConfig(string.Empty);

                var settings = GeoTrackerServerSettings.LoadConfig("Test");

                Assert.AreEqual("logical://LillTek/GeoTracker/Server", settings.ServerEP);
                Assert.AreEqual("logical://LillTek/GeoTracker/Cluster", settings.ClusterEP);
                Assert.AreEqual(typeof(DynamicHashedTopology), settings.ClusterTopology);
                Assert.AreEqual(0, settings.ClusterArgs.Count);
                Assert.AreEqual(typeof(NullGeoFixArchiver), settings.GeoFixArchiver);
                Assert.AreEqual(0, settings.GeoFixArchiverArgs.Count);
                Assert.AreEqual(TimeSpan.FromHours(1), settings.GeoFixRetentionInterval);
                Assert.AreEqual(TimeSpan.FromMinutes(1), settings.GeoFixPurgeInterval);
                Assert.AreEqual(30, settings.MaxEntityGeoFixes);
                Assert.AreEqual(1000, settings.IndexHighWatermarkLimit);
                Assert.AreEqual(750, settings.IndexLowWatermarkLimit);
                Assert.AreEqual(2, settings.IndexMaxGroupTableLevel);
                Assert.AreEqual(TimeSpan.FromMinutes(5), settings.IndexBalancingInterval);
                Assert.AreEqual(true, settings.IPGeocodeEnabled);
                Assert.AreEqual(new Uri("http://www.lilltek.com/Config/GeoTracker/IP2City.encrypted.dat"), settings.IPGeocodeSourceUri);
                Assert.AreEqual(DefRsaKey, settings.IPGeocodeSourceRsaKey);
                Assert.AreEqual(TimeSpan.FromDays(1), settings.IPGeocodeSourcePollInterval);
                Assert.AreEqual(TimeSpan.FromMinutes(5), settings.IPGeocodeSourceTimeout);
                Assert.AreEqual(TimeSpan.FromMinutes(2.5), settings.SweepInterval);
                Assert.AreEqual(TimeSpan.FromSeconds(1), settings.BkInterval);
            }
            finally
            {
                Config.SetConfig(null);
            }
        }
Пример #2
0
        public void GeoFixCache_Group_GetFixes()
        {
            // Verify that we can get the set of entities in a group along with
            // all of their cached location fixes.

            var settings = new GeoTrackerServerSettings();
            var cache    = new GeoFixCache(settings);

            try
            {
                cache.AddEntityFix("jeff", "group", new GeoFix()
                {
                    Latitude = 10, Longitude = 10
                });
                cache.AddEntityFix("jeff", "group", new GeoFix()
                {
                    Latitude = 20, Longitude = 10
                });
                cache.AddEntityFix("jeff", "group", new GeoFix()
                {
                    Latitude = 30, Longitude = 10
                });

                cache.AddEntityFix("bob", "group", new GeoFix()
                {
                    Latitude = 40, Longitude = 10
                });
                cache.AddEntityFix("bob", "group", new GeoFix()
                {
                    Latitude = 50, Longitude = 10
                });
                cache.AddEntityFix("bob", "group", new GeoFix()
                {
                    Latitude = 60, Longitude = 10
                });

                EntityState[] groupEntities = cache.GetGroupEntities("group");
                EntityState   entity;

                Assert.AreEqual(2, groupEntities.Length);

                entity = groupEntities.Where(ef => ef.EntityID == "jeff").First();
                Assert.AreEqual(3, entity.GetFixes().Length);
                Assert.AreEqual(30, entity.CurrentFix.Latitude);

                entity = groupEntities.Where(ef => ef.EntityID == "bob").First();
                Assert.AreEqual(3, entity.GetFixes().Length);
                Assert.AreEqual(60, entity.CurrentFix.Latitude);
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #3
0
        public void GeoFixCache_Group_Multiple()
        {
            // Verify that multiple groups and entities belonging to multiple groups works properly.

            var settings = new GeoTrackerServerSettings();
            var cache    = new GeoFixCache(settings);

            try
            {
                cache.AddEntityFix("jeff", "group1", new GeoFix()
                {
                    Latitude = 10, Longitude = 10
                });
                cache.AddEntityFix("bob", "group1", new GeoFix()
                {
                    Latitude = 60, Longitude = 10
                });

                cache.AddEntityFix("jeff", "group2", new GeoFix()
                {
                    Latitude = 20, Longitude = 10
                });
                cache.AddEntityFix("andy", "group2", new GeoFix()
                {
                    Latitude = 50, Longitude = 10
                });

                EntityFix[] entityFixes;
                EntityFix   entity;

                entityFixes = cache.GetGroupCurrentEntityFixes("group1");
                Assert.AreEqual(2, entityFixes.Length);

                entity = entityFixes.Where(ef => ef.EntityID == "jeff").First();
                Assert.AreEqual(20, entity.Fix.Latitude);

                entity = entityFixes.Where(ef => ef.EntityID == "bob").First();
                Assert.AreEqual(60, entity.Fix.Latitude);

                entityFixes = cache.GetGroupCurrentEntityFixes("group2");
                Assert.AreEqual(2, entityFixes.Length);

                entity = entityFixes.Where(ef => ef.EntityID == "jeff").First();
                Assert.AreEqual(20, entity.Fix.Latitude);

                entity = entityFixes.Where(ef => ef.EntityID == "andy").First();
                Assert.AreEqual(50, entity.Fix.Latitude);
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #4
0
        public void GeoFixCache_Purge_EntityFixes()
        {
            var settings = new GeoTrackerServerSettings()
            {
                GeoFixRetentionInterval = TimeSpan.FromSeconds(1),
                GeoFixPurgeInterval     = TimeSpan.FromSeconds(0.25),
                BkInterval = TimeSpan.FromSeconds(1)
            };

            var cache = new GeoFixCache(settings);

            try
            {
                DateTime timeOld = DateTime.UtcNow;
                DateTime timeNew = timeOld + TimeSpan.FromSeconds(5);    // Actually, 5 seconds in the future
                GeoFix[] fixes;

                // Verify that old fixes are purged from entities.

                cache.AddEntityFix("test", null, new GeoFix()
                {
                    TimeUtc = timeOld, Latitude = 10, Longitude = 10
                });
                cache.AddEntityFix("test", null, new GeoFix()
                {
                    TimeUtc = timeNew, Latitude = 10, Longitude = 10
                });

                fixes = cache.GetEntityFixes("test");
                Assert.AreEqual(2, fixes.Length);
                Assert.IsTrue(fixes.Any(f => f.TimeUtc == timeOld));
                Assert.IsTrue(fixes.Any(f => f.TimeUtc == timeNew));

                Thread.Sleep(TimeSpan.FromSeconds(3));  // Wait long enough for the purge thread to do its thing.

                fixes = cache.GetEntityFixes("test");
                Assert.AreEqual(1, fixes.Length);
                Assert.IsFalse(fixes.Any(f => f.TimeUtc == timeOld));
                Assert.IsTrue(fixes.Any(f => f.TimeUtc == timeNew));

                // Wait long enough for the second fix to expire and verify that
                // the entire entity is purged.

                Thread.Sleep(TimeSpan.FromSeconds(4));

                Assert.IsNull(cache.GetEntityFixes("test"));
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #5
0
        private void TestInit(string appConfig)
        {
            Config.SetConfig((RouterConfig + appConfig).Replace('&', '#'));
            router = new LeafRouter();
            router.Start();

            client = new GeoTrackerClient(router, null);

            var serverSettings = GeoTrackerServerSettings.LoadConfig("LillTek.GeoTracker.Server");

            serverSettings.IPGeocodeEnabled = false;

            server = new GeoTrackerNode();
            server.Start(router, serverSettings, null, null);
        }
Пример #6
0
        private void TestInit(bool enable, bool copyDatabase)
        {
            const string cfg =
                @"
MsgRouter.AppName               = Test
MsgRouter.AppDescription        = Test Description
MsgRouter.DiscoveryMode         = MULTICAST
MsgRouter.RouterEP				= physical://DETACHED/$(LillTek.DC.DefHubName)/$(Guid)
MsgRouter.CloudEP               = $(LillTek.DC.CloudEP)
MsgRouter.CloudAdapter          = ANY
MsgRouter.UdpEP					= ANY:0
MsgRouter.TcpEP					= ANY:0
MsgRouter.TcpBacklog			= 100
MsgRouter.TcpDelay				= off
MsgRouter.BkInterval			= 1s
MsgRouter.MaxIdle				= 5m
MsgRouter.EnableP2P             = yes
MsgRouter.AdvertiseTime			= 1m
MsgRouter.DefMsgTTL				= 5
MsgRouter.SharedKey             = PLAINTEXT
MsgRouter.SessionCacheTime      = 2m
MsgRouter.SessionRetries        = 3
MsgRouter.SessionTimeout        = 10s
";

            Config.SetConfig(cfg);
            router = new LeafRouter();
            router.Start();
            Thread.Sleep(1000);

            client = new GeoTrackerClient(router, null);

            var serverSettings = new GeoTrackerServerSettings()
            {
                IPGeocodeEnabled       = enable,
                IPGeocodeSourceTimeout = TimeSpan.FromMinutes(2),
            };

            if (copyDatabase)
            {
                Helper.DeleteFile(IPGeocoder.DataPath);
                File.Copy(exteralDataPath, IPGeocoder.DataPath);
            }

            server = new GeoTrackerNode();
            server.Start(router, serverSettings, null, null);
            Thread.Sleep(2000);
        }
Пример #7
0
        public void GeoFixCache_Add_OldReject()
        {
            // Verify that the cache won't add fixes older than the retention interval.

            var settings = new GeoTrackerServerSettings();
            var cache    = new GeoFixCache(settings);

            try
            {
                DateTime time0   = DateTime.UtcNow;
                DateTime time1   = DateTime.UtcNow + TimeSpan.FromSeconds(1);
                DateTime tooTime = DateTime.UtcNow - (settings.GeoFixRetentionInterval + TimeSpan.FromSeconds(1));

                Assert.AreEqual(0, cache.EntityCount);

                cache.AddEntityFix("Jeff", null, new GeoFix()
                {
                    TimeUtc = time0, Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Bob", null, new GeoFix()
                {
                    TimeUtc = time1, Latitude = 20, Longitude = 30
                });
                cache.AddEntityFix("Judy", null, new GeoFix()
                {
                    TimeUtc = tooTime, Latitude = 40, Longitude = 50
                });

                Assert.AreEqual(2, cache.EntityCount);

                Assert.IsNotNull(cache.GetCurrentEntityFix("Jeff"));
                Assert.IsNotNull(cache.GetCurrentEntityFix("Bob"));
                Assert.IsNull(cache.GetCurrentEntityFix("Judy"));       // Fix was too old
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #8
0
        private void TestInit()
        {
            const string cfg =
                @"
MsgRouter.AppName               = Test
MsgRouter.AppDescription        = Test Description
MsgRouter.DiscoveryMode         = MULTICAST
MsgRouter.RouterEP				= physical://DETACHED/$(LillTek.DC.DefHubName)/$(Guid)
MsgRouter.CloudEP               = $(LillTek.DC.CloudEP)
MsgRouter.CloudAdapter          = ANY
MsgRouter.UdpEP					= ANY:0
MsgRouter.TcpEP					= ANY:0
MsgRouter.TcpBacklog			= 100
MsgRouter.TcpDelay				= off
MsgRouter.BkInterval			= 1s
MsgRouter.MaxIdle				= 5m
MsgRouter.EnableP2P             = yes
MsgRouter.AdvertiseTime			= 1m
MsgRouter.DefMsgTTL				= 5
MsgRouter.SharedKey             = PLAINTEXT
MsgRouter.SessionCacheTime      = 2m
MsgRouter.SessionRetries        = 3
MsgRouter.SessionTimeout        = 10s
";

            Config.SetConfig(cfg);
            router = new LeafRouter();
            router.Start();

            client = new GeoTrackerClient(router, null);

            var serverSettings = new GeoTrackerServerSettings();

            serverSettings.IPGeocodeEnabled = false;

            server = new GeoTrackerNode();
            server.Start(router, serverSettings, null, null);
        }
Пример #9
0
        private void TestInit()
        {
            const string cfg =
                @"
Diagnostics.TraceEnable[-] = 0:LillTek.Messaging
--Diagnostics.TraceEnable[-] = 1:LillTek.GeoTracker

MsgRouter.AppName               = Test
MsgRouter.AppDescription        = Test Description
MsgRouter.DiscoveryMode         = MULTICAST
MsgRouter.RouterEP				= physical://DETACHED/$(LillTek.DC.DefHubName)/$(Guid)
MsgRouter.CloudEP               = $(LillTek.DC.CloudEP)
MsgRouter.CloudAdapter          = ANY
MsgRouter.UdpEP					= ANY:0
MsgRouter.TcpEP					= ANY:0
MsgRouter.TcpBacklog			= 100
MsgRouter.TcpDelay				= off
MsgRouter.BkInterval			= 1s
MsgRouter.MaxIdle				= 5m
MsgRouter.EnableP2P             = yes
MsgRouter.AdvertiseTime			= 1s
MsgRouter.DefMsgTTL				= 5
MsgRouter.SharedKey             = PLAINTEXT
MsgRouter.SessionCacheTime      = 2m
MsgRouter.SessionRetries        = 3
MsgRouter.SessionTimeout        = 10s
";

            Config.SetConfig(cfg);
            //NetTrace.Start();

            router = new LeafRouter();
            router.Start();
            Thread.Sleep(1000);

            client = new GeoTrackerClient(router, null);

            var serverSettings = new GeoTrackerServerSettings();

            serverSettings.IPGeocodeEnabled = false;

            // Crank up the cluster instances on separate threads.

            var threads = new List <Thread>();
            var fail    = false;

            clusterInstances = new ClusterInstance[InstanceCount];

            for (int i = 0; i < InstanceCount; i++)
            {
                clusterInstances[i] = new ClusterInstance();
            }

            for (int i = 0; i < InstanceCount; i++)
            {
                threads.Add(
                    Helper.StartThread(null, i,
                                       index =>
                {
                    try
                    {
                        clusterInstances[(int)index].Start();
                    }
                    catch (Exception e)
                    {
                        SysLog.LogException(e);
                        fail = true;
                    }
                }));
            }

            foreach (var thread in threads)
            {
                thread.Join();
            }

            if (fail)
            {
                Assert.Fail("Instance Creation Failure");
            }

            Thread.Sleep(5000);     // Wait for routes to be replicated
        }
Пример #10
0
        public void GeoFixCache_Load()
        {
            // Run the cache under significant load and with continuous purging for a couple minutes
            // to try to cause thred synchronization issues.

            var settings = new GeoTrackerServerSettings()
            {
                GeoFixPurgeInterval     = TimeSpan.Zero,
                GeoFixRetentionInterval = TimeSpan.FromSeconds(1),
                BkInterval = TimeSpan.Zero
            };

            var cache = new GeoFixCache(settings);

            try
            {
                const int EntityCount = 100000;
                const int GroupCount  = 20;

                bool   stopThreads = false;
                bool   threadError = false;
                Thread add1Thread;
                Thread add2Thread;
                Thread query1Thread;
                Thread query2Thread;

                add1Thread = new Thread(new ThreadStart(
                                            () =>
                {
                    Random rand = new Random(Thread.CurrentThread.ManagedThreadId);

                    while (!stopThreads)
                    {
                        try
                        {
                            string entityID = string.Format("entity-{0}", rand.Next(EntityCount));
                            string groupID  = string.Format("group-{0}", rand.Next(GroupCount));

                            cache.AddEntityFix(entityID, groupID, new GeoFix()
                            {
                                Latitude = 10, Longitude = 20
                            });
                        }
                        catch (Exception e)
                        {
                            threadError = true;
                            SysLog.LogException(e);
                        }
                    }
                }));

                add2Thread = new Thread(new ThreadStart(
                                            () =>
                {
                    Random rand = new Random(Thread.CurrentThread.ManagedThreadId);

                    while (!stopThreads)
                    {
                        try
                        {
                            string entityID = string.Format("entity-{0}", rand.Next(EntityCount));
                            string groupID  = string.Format("group-{0}", rand.Next(GroupCount));

                            cache.AddEntityFix(entityID, groupID, new GeoFix()
                            {
                                Latitude = 10, Longitude = 20
                            });
                        }
                        catch (Exception e)
                        {
                            threadError = true;
                            SysLog.LogException(e);
                        }
                    }
                }));

                query1Thread = new Thread(new ThreadStart(
                                              () =>
                {
                    Random rand = new Random(Thread.CurrentThread.ManagedThreadId);

                    while (!stopThreads)
                    {
                        try
                        {
                            string entityID = string.Format("entity-{0}", rand.Next(EntityCount));
                            string groupID  = string.Format("group-{0}", rand.Next(GroupCount));
                            int cEntities   = cache.EntityCount;
                            int cGroups     = cache.GroupCount;

                            cache.GetEntityFixes(entityID);
                            cache.GetCurrentEntityFix(entityID);

                            var groupFixes = cache.GetGroupEntities(groupID);

                            foreach (var entity in groupFixes)
                            {
                                entity.GetFixes();
                            }

                            var entityFixes = cache.GetGroupCurrentEntityFixes(groupID);
                            int c           = 0;

                            foreach (var fix in entityFixes)
                            {
                                c++;
                            }
                        }
                        catch (Exception e)
                        {
                            threadError = true;
                            SysLog.LogException(e);
                        }
                    }
                }));

                query2Thread = new Thread(new ThreadStart(
                                              () =>
                {
                    Random rand = new Random(Thread.CurrentThread.ManagedThreadId);

                    while (!stopThreads)
                    {
                        try
                        {
                            string entityID = string.Format("entity-{0}", rand.Next(EntityCount));
                            string groupID  = string.Format("group-{0}", rand.Next(GroupCount));
                            int cEntities   = cache.EntityCount;
                            int cGroups     = cache.GroupCount;

                            cache.GetEntityFixes(entityID);
                            cache.GetCurrentEntityFix(entityID);

                            var groupFixes = cache.GetGroupEntities(groupID);

                            foreach (var entity in groupFixes)
                            {
                                entity.GetFixes();
                            }

                            var entityFixes = cache.GetGroupCurrentEntityFixes(groupID);
                            int c           = 0;

                            foreach (var fix in entityFixes)
                            {
                                c++;
                            }
                        }
                        catch (Exception e)
                        {
                            threadError = true;
                            SysLog.LogException(e);
                        }
                    }
                }));

                add1Thread.Start();
                add2Thread.Start();
                query1Thread.Start();
                query2Thread.Start();

                // Let the threads pound on the cache for a while.

                Thread.Sleep(TimeSpan.FromMinutes(5));

                stopThreads = true;
                add1Thread.Join();
                add2Thread.Join();
                query1Thread.Join();
                query2Thread.Join();

                Assert.IsFalse(threadError);
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #11
0
        public void GeoFixCache_Basic()
        {
            // Verify that we can add an entity fix without a group and
            // on with a group.

            var settings = new GeoTrackerServerSettings();
            var cache    = new GeoFixCache(settings);

            try
            {
                DateTime time0 = DateTime.UtcNow + TimeSpan.FromSeconds(0);
                DateTime time1 = DateTime.UtcNow + TimeSpan.FromSeconds(1);
                GeoFix[] fixes;
                GeoFix   fix;

                Assert.AreEqual(0, cache.EntityCount);
                Assert.AreEqual(0, cache.GroupCount);

                cache.AddEntityFix("Jeff", null, new GeoFix()
                {
                    TimeUtc = time0, Latitude = 10, Longitude = 20
                });

                Assert.AreEqual(1, cache.EntityCount);
                Assert.AreEqual(0, cache.GroupCount);

                fixes = cache.GetEntityFixes("Jeff");
                Assert.IsNotNull(fixes);
                Assert.AreEqual(1, fixes.Length);
                Assert.AreEqual(time0, fixes[0].TimeUtc.Value);

                fixes = cache.GetEntityFixes("JEFF");
                Assert.IsNull(fixes);   // Entity IDs are case sensitive

                cache.AddEntityFix("Jeff", "Lill-Family", new GeoFix()
                {
                    TimeUtc = time1, Latitude = 20, Longitude = 30
                });

                Assert.AreEqual(1, cache.EntityCount);
                Assert.AreEqual(1, cache.GroupCount);

                fixes = cache.GetEntityFixes("Jeff");
                Assert.IsNotNull(fixes);
                Assert.AreEqual(2, fixes.Length);
                Assert.AreEqual(time1, fixes[0].TimeUtc.Value);
                Assert.AreEqual(time0, fixes[1].TimeUtc.Value);

                fix = cache.GetCurrentEntityFix("Jeff");
                Assert.IsNotNull(fix);
                Assert.AreEqual(time1, fix.TimeUtc.Value);

                // Verify that entityIDs are case sensitive.

                Assert.IsNotNull(cache.GetCurrentEntityFix("Jeff"));
                Assert.IsNull(cache.GetCurrentEntityFix("JEFF"));
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #12
0
        public void GeoFixCache_Purge_Groups()
        {
            var settings = new GeoTrackerServerSettings()
            {
                GeoFixRetentionInterval = TimeSpan.FromSeconds(1),
                GeoFixPurgeInterval     = TimeSpan.FromSeconds(0.25),
                BkInterval = TimeSpan.FromSeconds(1)
            };

            var cache = new GeoFixCache(settings);

            try
            {
                DateTime      timeOld    = DateTime.UtcNow;
                DateTime      timeNew    = timeOld + TimeSpan.FromSeconds(5); // Actually, 5 seconds in the future
                DateTime      timeFuture = timeOld + TimeSpan.FromSeconds(10);
                EntityState[] groupEntities;
                EntityState   entity;

                // Verify that purged fixes are reflected in a group's entities.

                cache.AddEntityFix("test1", "group", new GeoFix()
                {
                    TimeUtc = timeOld, Latitude = 10, Longitude = 10
                });
                cache.AddEntityFix("test1", "group", new GeoFix()
                {
                    TimeUtc = timeNew, Latitude = 10, Longitude = 10
                });
                cache.AddEntityFix("test2", "group", new GeoFix()
                {
                    TimeUtc = timeFuture, Latitude = 10, Longitude = 10
                });

                groupEntities = cache.GetGroupEntities("group");
                Assert.AreEqual(2, groupEntities.Length);
                Assert.IsTrue(groupEntities.Any(ef => ef.EntityID == "test1"));
                Assert.IsTrue(groupEntities.Any(ef => ef.EntityID == "test2"));

                entity = groupEntities.Where(ef => ef.EntityID == "test1").First();
                Assert.AreEqual(2, entity.GetFixes().Length);
                Assert.IsTrue(entity.GetFixes().Any(ef => ef.TimeUtc == timeOld));
                Assert.IsTrue(entity.GetFixes().Any(ef => ef.TimeUtc == timeNew));

                entity = groupEntities.Where(ef => ef.EntityID == "test2").First();
                Assert.AreEqual(1, entity.GetFixes().Length);
                Assert.IsTrue(entity.GetFixes().Any(ef => ef.TimeUtc == timeFuture));

                Thread.Sleep(TimeSpan.FromSeconds(3));  // Wait long enough for the purge thread to purge
                // the first fix for "test1".

                groupEntities = cache.GetGroupEntities("group");
                Assert.AreEqual(2, groupEntities.Length);
                Assert.IsTrue(groupEntities.Any(ef => ef.EntityID == "test1"));
                Assert.IsTrue(groupEntities.Any(ef => ef.EntityID == "test2"));

                entity = groupEntities.Where(ef => ef.EntityID == "test1").First();
                Assert.AreEqual(1, entity.GetFixes().Length);
                Assert.IsFalse(entity.GetFixes().Any(ef => ef.TimeUtc == timeOld));
                Assert.IsTrue(entity.GetFixes().Any(ef => ef.TimeUtc == timeNew));

                entity = groupEntities.Where(ef => ef.EntityID == "test2").First();
                Assert.AreEqual(1, entity.GetFixes().Length);
                Assert.IsTrue(entity.GetFixes().Any(ef => ef.TimeUtc == timeFuture));

                // Wait long enough for the "test2" fix to expire and verify that
                // group no longer exists.

                Thread.Sleep(TimeSpan.FromSeconds(9));

                groupEntities = cache.GetGroupEntities("group");
                Assert.AreEqual(0, groupEntities.Length);
                Assert.IsFalse(cache.GroupExists("group"));
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #13
0
        public void GeoFixCache_Group_Basic()
        {
            // Verify that we can query for groups.

            var settings = new GeoTrackerServerSettings();
            var cache    = new GeoFixCache(settings);

            try
            {
                Assert.AreEqual(0, cache.EntityCount);
                Assert.AreEqual(0, cache.GroupCount);

                cache.AddEntityFix("Jeff", null, new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Eddie", null, new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Jeff", "Group-1", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Bob", "Group-1", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Joe", "Group-1", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Mary", "Group-2", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Angie", "Group-2", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });
                cache.AddEntityFix("Jeff", "Group-2", new GeoFix()
                {
                    Latitude = 10, Longitude = 20
                });

                Assert.AreEqual(6, cache.EntityCount);
                Assert.AreEqual(2, cache.GroupCount);

                // Verify that NULL and non-existing groups return empty arrays.

                Assert.AreEqual(0, cache.GetGroupEntities(null).Length);
                Assert.AreEqual(0, cache.GetGroupEntities("DOES NOT EXIST").Length);

                // Verify the group membership.  Note that "Jeff" is a member of both groups.

                EntityState[] entities;

                entities = cache.GetGroupEntities("Group-1");
                Assert.AreEqual(3, entities.Length);
                Assert.IsTrue(entities.Any(e => e.EntityID == "Jeff"));
                Assert.IsTrue(entities.Any(e => e.EntityID == "Bob"));
                Assert.IsTrue(entities.Any(e => e.EntityID == "Joe"));

                entities = cache.GetGroupEntities("Group-2");
                Assert.AreEqual(3, entities.Length);
                Assert.IsTrue(entities.Any(e => e.EntityID == "Mary"));
                Assert.IsTrue(entities.Any(e => e.EntityID == "Angie"));
                Assert.IsTrue(entities.Any(e => e.EntityID == "Jeff"));

                // Verify the case sensitivity of group IDs.

                Assert.AreEqual(3, cache.GetGroupEntities("Group-1").Length);
                Assert.AreEqual(0, cache.GetGroupEntities("GROUP-1").Length);
            }
            finally
            {
                cache.Stop();
            }
        }
Пример #14
0
        public void GeoTrackerServerSettings_ConfigSettings()
        {
            string cfg = @"
&section Test

    ServerEP                    = logical://test/server
    ClusterEP                   = logical://test/cluster
    ClusterTopology             = LillTek.Messaging.Dynamic2DTopology:LillTek.Messaging.dll
    ClusterArgs                 = {{

        test1 = 1
        test2 = 2
    }}

    GeoFixArchiver              = LillTek.GeoTracker.Server.AppLogGeoFixArchiver:LillTek.GeoTracker.Server.dll
    GeoFixArchiverArgs          = {{

        Test  = Foo
        Hello = World
    }}

    GeoFixRetentionInterval     = 2h
    GeoFixPurgeInterval         = 7m
    MaxEntityGeoFixes           = 100
    LongitudeIndexResolution    = 0.25

    IndexHighWatermarkLimit     = 2000
    IndexLowWatermarkLimit      = 1500
    IndexMaxGroupTableLevel     = 3
    IndexBalancingInterval      = 1m

    IPGeocodeEnabled            = no
    IPGeocodeSourceUri          = http://www.google.com
    IPGeocodeSourceRsaKey       = <RSAKeyValue><Modulus>trZSBdVGPcfVlaQrKK7nVAmMqu65eKLKoQuAujN8fd3OCZlkayn1Cil6SInwLS9sHIHG1QXgHT+d/M3bQybaeE0kU5SMQQIXi2Z41EHaVcaXU3Pw81v2ybFkVf8eQPTmuxESyw85BymVkre5rSZiRlk7nlZQN812z36mv6ByNYE=</Modulus><Exponent>AQAB</Exponent><P>2KQogNyfS5KEVh93Fsp/b7lovUfZvxkfBH5cdOhX8S43eLVZV8hV1I54B8FWoiA7RIHq/52WWS8E5TzI5ntZ7Q==</P><Q>1+gk6cHptG/aWfmVsRd7ZvnoZiWHPTijnoRtaO3ynAgb1Vn8VehqQBbunN6EqKV2/Qnt5flE/+aY98MBJFNHZQ==</Q><DP>rgPeTPPqOGfuSMdpfzMU/gcuLKwkKa3iDlf5qCZhTWdUQ29X3n0bBGuT2pbgIcZGFRdOThilBeoQwpn6vbfjWQ==</DP><DQ>DLujGaoW9041aWL/wf7phywr2YJTFHg3pgyXSz3lNfCAe7ef2w0m3vq7PcMdvbhsaQXh4tMtj43w7YOxmIvUxQ==</DQ><InverseQ>V1tegYUSKG89LsK44zaGKWAYAyygNimBkgLgxs92asWb6LVzA/iP1R1WEELb4VOKj7h0KLk7kY0sZxC/gC2Ybg==</InverseQ><D>VpQ4c9knKrlZ5UngxatzpKfNx2XN73M8j2mS+yjQkhgbvQK5yeoc2k7jSiJK9C5njW6VmHXrSBDQPW4Su1Ra6x+zDiCqK6qY/BIDetO6MuU/5zTd0+uMmLZg1PUkU4e42MJZDjNET2KFmG0IrB/jp2099lI/E6d2Mv2FzxO0atE=</D></RSAKeyValue>
    IPGeocodeSourcePollInterval = 1h
    IPGeocodeSourceTimeout      = 10m
    SweepInterval               = 5m
    BkInterval                  = 30s

&endsection
";

            try
            {
                Config.SetConfig(cfg.Replace('&', '#'));

                var settings = GeoTrackerServerSettings.LoadConfig("Test");

                Assert.AreEqual("logical://test/server", settings.ServerEP);
                Assert.AreEqual("logical://test/cluster", settings.ClusterEP);
                Assert.AreEqual("LillTek.Messaging.Dynamic2DTopology", settings.ClusterTopology.FullName);
                Assert.AreEqual(2, settings.ClusterArgs.Count);
                Assert.AreEqual("1", settings.ClusterArgs["test1"]);
                Assert.AreEqual("2", settings.ClusterArgs["test2"]);
                Assert.AreEqual("LillTek.GeoTracker.Server.AppLogGeoFixArchiver", settings.GeoFixArchiver.FullName);
                Assert.AreEqual(2, settings.GeoFixArchiverArgs.Count);
                Assert.AreEqual("Foo", settings.GeoFixArchiverArgs["Test"]);
                Assert.AreEqual("World", settings.GeoFixArchiverArgs["Hello"]);
                Assert.AreEqual(TimeSpan.FromHours(2), settings.GeoFixRetentionInterval);
                Assert.AreEqual(TimeSpan.FromMinutes(7), settings.GeoFixPurgeInterval);
                Assert.AreEqual(100, settings.MaxEntityGeoFixes);
                Assert.AreEqual(2000, settings.IndexHighWatermarkLimit);
                Assert.AreEqual(1500, settings.IndexLowWatermarkLimit);
                Assert.AreEqual(3, settings.IndexMaxGroupTableLevel);
                Assert.AreEqual(TimeSpan.FromMinutes(1), settings.IndexBalancingInterval);
                Assert.AreEqual(false, settings.IPGeocodeEnabled);
                Assert.AreEqual(new Uri("http://www.google.com"), settings.IPGeocodeSourceUri);
                Assert.AreEqual("<RSAKeyValue><Modulus>trZSBdVGPcfVlaQrKK7nVAmMqu65eKLKoQuAujN8fd3OCZlkayn1Cil6SInwLS9sHIHG1QXgHT+d/M3bQybaeE0kU5SMQQIXi2Z41EHaVcaXU3Pw81v2ybFkVf8eQPTmuxESyw85BymVkre5rSZiRlk7nlZQN812z36mv6ByNYE=</Modulus><Exponent>AQAB</Exponent><P>2KQogNyfS5KEVh93Fsp/b7lovUfZvxkfBH5cdOhX8S43eLVZV8hV1I54B8FWoiA7RIHq/52WWS8E5TzI5ntZ7Q==</P><Q>1+gk6cHptG/aWfmVsRd7ZvnoZiWHPTijnoRtaO3ynAgb1Vn8VehqQBbunN6EqKV2/Qnt5flE/+aY98MBJFNHZQ==</Q><DP>rgPeTPPqOGfuSMdpfzMU/gcuLKwkKa3iDlf5qCZhTWdUQ29X3n0bBGuT2pbgIcZGFRdOThilBeoQwpn6vbfjWQ==</DP><DQ>DLujGaoW9041aWL/wf7phywr2YJTFHg3pgyXSz3lNfCAe7ef2w0m3vq7PcMdvbhsaQXh4tMtj43w7YOxmIvUxQ==</DQ><InverseQ>V1tegYUSKG89LsK44zaGKWAYAyygNimBkgLgxs92asWb6LVzA/iP1R1WEELb4VOKj7h0KLk7kY0sZxC/gC2Ybg==</InverseQ><D>VpQ4c9knKrlZ5UngxatzpKfNx2XN73M8j2mS+yjQkhgbvQK5yeoc2k7jSiJK9C5njW6VmHXrSBDQPW4Su1Ra6x+zDiCqK6qY/BIDetO6MuU/5zTd0+uMmLZg1PUkU4e42MJZDjNET2KFmG0IrB/jp2099lI/E6d2Mv2FzxO0atE=</D></RSAKeyValue>", settings.IPGeocodeSourceRsaKey);
                Assert.AreEqual(TimeSpan.FromHours(1), settings.IPGeocodeSourcePollInterval);
                Assert.AreEqual(TimeSpan.FromMinutes(10), settings.IPGeocodeSourceTimeout);
                Assert.AreEqual(TimeSpan.FromMinutes(5), settings.SweepInterval);
                Assert.AreEqual(TimeSpan.FromSeconds(30), settings.BkInterval);
            }
            finally
            {
                Config.SetConfig(null);
            }
        }