Ejemplo n.º 1
0
        public void BasePathWithPlaceHolder()
        {
            var customBasePath = "{appdir}\\BasePathConfigTest";
            var expectedBasePath = AppDomain.CurrentDomain.BaseDirectory + "\\BasePathConfigTest";

            var config = new Config(customBasePath);
            Assert.AreEqual(expectedBasePath, config.BaseDataPath);

            config = new Config(customBasePath, true, 1000, 10000, string.Empty, string.Empty, 10, false, 0, 10);
            Assert.AreEqual(expectedBasePath, config.BaseDataPath);
        }
Ejemplo n.º 2
0
 public void NonAppConfigFileConfig()
 {
     var config = new Config("TestPath", true, 20, 1100, "SchemaConn", "DataConn", 100, true, 10000, 20);
     Assert.AreEqual("TestPath", config.BaseDataPath);
     Assert.IsTrue(config.IndexCacheEnabled);
     Assert.AreEqual(20, config.IndexCacheMaxQueries);
     Assert.AreEqual(1100, config.IndexCacheMaxValues);
     Assert.AreEqual("SchemaConn", config.ObjectIndexSchemaConnection);
     Assert.AreEqual("DataConn", config.ObjectIndexDataConnection);
     Assert.AreEqual(100, config.MaxObjectDependencies);
     Assert.AreEqual(true, config.ObjectStoreAutoClose);
     Assert.AreEqual(10000, config.ObjectStoreAutoCloseTimeout);
     Assert.AreEqual(20, config.ObjectStoreCacheSize);
 }
Ejemplo n.º 3
0
        private void _InitializeObjectService()
        {
            var dataPath = Server.MapPath("/App_Data/ObjectService");
            var config = new Config(dataPath);
            ObjectService = new ObjectService(config);

            // ensure that Object Store namespace exists
            if (!ObjectService.NameSpaceExists(Globals.ObjectNameSpace))
            {
                ObjectService.CreateNameSpace(
                    new ObjectNameSpaceConfig(Globals.ObjectNameSpace, "Demo Owner", "Demo Location", DateTime.Now));
            }

            // provision ActivityFeed Object Store
            var metadata = ActivityFeed.GetMetadata();
            if (!ObjectService.ObjectNameExists(metadata.NameSpace, metadata.ObjectName))
            {
                ObjectService.ProvisionObjectStore(metadata);

                // create some test records to query
                var actService = new ActivityFeed(ObjectService);

                DateTime dt = DateTime.UtcNow - new TimeSpan(5, 0, 0);

                for (int i = 0; i < 1000; i++)
                {
                    var actType = ActivityType.News;

                    // put a few different types of activity types in
                    if (0 != i && (0 == i % 5))
                    {
                        actType = ActivityType.Article;
                    }

                    actService.Add(new Activity()
                    {
                        ActivityType = actType,
                        Title = "Demo article #" + i,
                        Text = "Demo article text #" + i,
                        Link = "http://www.website" + i + ".com",
                        Image = "image" + i + ".png",
                        CreatedUTC = DateTime.UtcNow,
                        ExpiresUTC = dt.AddSeconds(i)
                    });
                }
            }
        }
Ejemplo n.º 4
0
 public MySQLObjectIndexProvider(Config config)
     : base(config)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructs a new ObjectService configured via the supplied Config instance.
        /// Also, allows a delegate action to be run when the ObjectVersionChanged event 
        /// fires. This is useful, for example, for notifying caches kept external to 
        /// the ObjectService itself.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="onObjectVersionChanged"></param>
        public ObjectService(Config config, Action<string, uint> onObjectVersionChanged)
        {
            _assignments = new List<IDisposable>();

            _objectMetadata = new ObjectMetadataStore(config);
            _objectNaming = new ObjectNaming(_objectMetadata);
            _objectIDStore = new ObjectIDStore(config);
            _objectVersions = new ObjectVersionStore(config, _objectMetadata);

            if (config.IndexCacheEnabled)
            {
                _indexerCache = new ObjectIndexerCache(_objectMetadata, _objectVersions);
                _indexerCacheCleaner = new HardPruneCacheCleaner(_indexerCache,
                    (int)config.IndexCacheMaxQueries,
                    (int)config.IndexCacheMaxValues,
                    HardPruneCacheCleaner.DefaultReductionFactor,
                    HardPruneCacheCleaner.DefaultCleanFrequency);

                _assignments.Add(_indexerCache);
                _assignments.Add(_indexerCacheCleaner);
            }

            _objectStore = new ObjectStore(config, _objectMetadata);
            _objectIndexer = new ObjectIndexer(_indexerCache);

            _assignments.Add(_objectMetadata);
            _assignments.Add(_objectIDStore);
            _assignments.Add(_objectVersions);
            _assignments.Add(_objectStore);
            _assignments.Add(_objectIndexer);

            if (onObjectVersionChanged != null)
            {
                _objectVersions.VersionChanged += (objectFullName, newVersion) =>
                {
                    onObjectVersionChanged(objectFullName, newVersion);
                };
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructs a new ObjectService configured via the supplied Config instance.
 /// </summary>
 /// <param name="config"></param>
 public ObjectService(Config config)
     : this(config, null)
 {
 }
Ejemplo n.º 7
0
 public SQLiteObjectIndexProvider(Config config)
     : base(config)
 {
 }
Ejemplo n.º 8
0
 public void BasePathConfig()
 {
     var customBasePath = "C:\\Test\\BasePathConfigTest";
     var config = new Config(customBasePath);
     Assert.AreEqual(customBasePath, config.BaseDataPath);
 }