Exemplo n.º 1
0
        public ConfigurationProvider()
        {
            // Transaction Flushing
            TransactionFlushTripleCount = DefaultTransactionFlushTripleCount;

            // ResourceCacheLimit
            ResourceCacheLimit = DefaultResourceCacheLimit;

            // Connection String
            ConnectionString = null;

            // Query Caching
            QueryCache = GetQueryCache(true, DefaultQueryCacheMemory);

            // Persistence Type
            PersistenceType = DefaultPersistenceType;

            // Page Cache Size
            PageCacheSize = DefaultPageCacheSize;

            // StatsUpdate properties
            StatsUpdateTransactionCount = DefaultStatsUpdateTransactionCount;
            StatsUpdateTimespan = DefaultStatsUpdateTimespan;

            // Cache Preload Configuration
            var preloadConfig = new PageCachePreloadConfiguration
            {
                DefaultCacheRatio = DefaultPreloadCacheRatio,
                Enabled = DefaultPreloadCacheEnabled
            };
            EmbeddedServiceConfiguration = new EmbeddedServiceConfiguration(preloadConfig, false);

        }
Exemplo n.º 2
0
 ///<summary>
 /// Gets a client based on the connection string specified in the configuration.
 ///</summary>
 /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options that apply only when creating an embedded service instance.</param>
 ///<returns>A new Brightstar service client</returns>
 public static IBrightstarService GetClient(EmbeddedServiceConfiguration serviceConfigurationOptions = null)
 {
     var configuration = Configuration.ConnectionString;
     if(String.IsNullOrEmpty(configuration))
     {
         throw new BrightstarClientException(Strings.BrightstarServiceClient_NoConnectionStringConfiguration);
     }
     // use connection string in config
     return GetClient(new ConnectionString(Configuration.ConnectionString), serviceConfigurationOptions);
 }
        /// <summary>
        /// Create a new instance of the context that attaches to the specified directory location
        /// </summary>
        /// <param name="connectionString">The Brightstar service connection string</param>
        /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options specific to an embedded store. If a
        /// value is provided, it overrides any configuration read from the brightstar section of the application's app.config or web.config file.</param>
        /// <remarks>The data context is thread-safe but doesn't support concurrent access to the same base location by multiple
        /// instances. You should ensure in your code that only one EmbeddedDataObjectContext instance is connected to any given base location
        /// at a given time.</remarks>
        public EmbeddedDataObjectContext(ConnectionString connectionString, EmbeddedServiceConfiguration serviceConfigurationOptions = null)
        {
            if (connectionString == null) throw new ArgumentNullException("connectionString");
            if (connectionString.Type != ConnectionType.Embedded) throw new ArgumentException("Invalid connection type", "connectionString");

            if (serviceConfigurationOptions == null) serviceConfigurationOptions = Configuration.EmbeddedServiceConfiguration;
            _serverCore = ServerCoreManager.GetServerCore(
                connectionString.StoresDirectory,
                serviceConfigurationOptions);
            _optimisticLockingEnabled = connectionString.OptimisticLocking;
        }
Exemplo n.º 4
0
 public ConfigurationProvider()
 {
     PageCacheSize = DefaultPageCacheSize;
     ResourceCacheLimit = DefaultResourceCacheLimit;
     PersistenceType = PersistenceType.AppendOnly;
     QueryCache = new NullCache();
     StatsUpdateTimespan = 0;
     StatsUpdateTransactionCount = 0;
     TransactionFlushTripleCount = 1000;
     EmbeddedServiceConfiguration =
         new EmbeddedServiceConfiguration(new PageCachePreloadConfiguration {Enabled = false}, false);
 }
Exemplo n.º 5
0
 public static ServerCore GetServerCore(string baseLocation, EmbeddedServiceConfiguration serviceConfiguration)
 {
     lock (UpdateLock)
     {
         if (!ServerCores.ContainsKey(baseLocation))
         {
             var serverCore = new ServerCore(baseLocation, QueryCache, PersistenceType, serviceConfiguration.EnableTransactionLoggingOnNewStores);
             if (serviceConfiguration != null && serviceConfiguration.PreloadConfiguration != null)
             {
                 serverCore.Warmup(serviceConfiguration.PreloadConfiguration);
             }
             ServerCores.Add(baseLocation, serverCore);
         }
         return ServerCores[baseLocation];
     }
 }
 /// <summary>
 /// Creates a configuration section handler.
 /// </summary>
 /// <returns>
 /// The created section handler object.
 /// </returns>
 /// <param name="parent">Parent object.</param><param name="configContext">Configuration context object.</param><param name="section">Section XML node.</param><filterpriority>2</filterpriority>
 public object Create(object parent, object configContext, XmlNode section)
 {
     if (!(section is XmlElement)) return null;
     var ret = new EmbeddedServiceConfiguration();
     var sectionEl = section as XmlElement;
     var preloadPages = sectionEl.GetElementsByTagName("preloadPages").Item(0) as XmlElement;
     if (preloadPages != null)
     {
         ret.PreloadConfiguration = ProcessPreloadConfiguration(preloadPages);
     }
     var txnLogging =
         sectionEl.GetElementsByTagName("transactionLogging").OfType<XmlElement>().FirstOrDefault();
     if (txnLogging != null)
     {
         ret.EnableTransactionLoggingOnNewStores = IsEnabled(txnLogging);
     }
     return ret;
 }
Exemplo n.º 7
0
        ///<summary>
        /// Gets a client based on the connection string parameter
        ///</summary>
        ///<param name="connectionString">The connection string</param>
        /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options that apply only when creating an embedded service instance.</param>
        ///<returns>A new Brightstar service client</returns>
        public static IBrightstarService GetClient(ConnectionString connectionString, EmbeddedServiceConfiguration serviceConfigurationOptions = null)
        {
            if (serviceConfigurationOptions == null)
            {
                serviceConfigurationOptions = new EmbeddedServiceConfiguration();
            }
            switch (connectionString.Type)
            {
                case ConnectionType.Embedded:
                    return new EmbeddedBrightstarService(connectionString.StoresDirectory, serviceConfigurationOptions);
#if !WINDOWS_PHONE
                case ConnectionType.Rest:
                    return GetRestClient(connectionString);
#endif
                default:
                    throw new BrightstarClientException("Unable to create valid context with connection string " +
                                                        connectionString.Value);
            }
        }
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <returns>
        /// The created section handler object.
        /// </returns>
        /// <param name="parent">Parent object.</param><param name="configContext">Configuration context object.</param><param name="section">Section XML node.</param><filterpriority>2</filterpriority>
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (!(section is XmlElement))
            {
                return(null);
            }
            var ret          = new EmbeddedServiceConfiguration();
            var sectionEl    = section as XmlElement;
            var preloadPages = sectionEl.GetElementsByTagName("preloadPages").Item(0) as XmlElement;

            if (preloadPages != null)
            {
                ret.PreloadConfiguration = ProcessPreloadConfiguration(preloadPages);
            }
            var txnLogging =
                sectionEl.GetElementsByTagName("transactionLogging").OfType <XmlElement>().FirstOrDefault();

            if (txnLogging != null)
            {
                ret.EnableTransactionLoggingOnNewStores = IsEnabled(txnLogging);
            }
            return(ret);
        }
 /// <summary>
 /// Create a new instance of the service that attaches to the specified directory location
 /// </summary>
 /// <param name="baseLocation">The full path to the location of the directory that contains one or more Brightstar stores</param>
 /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options that apply only when creating an embedded service instance.</param>
 /// <remarks>The embedded server is thread-safe but doesn't support concurrent access to the same base location by multiple
 /// instances. You should ensure in your code that only one EmbeddedBrightstarService instance is connected to any given base location
 /// at a given time.</remarks>
 public EmbeddedBrightstarService(string baseLocation, EmbeddedServiceConfiguration serviceConfigurationOptions)
 {
     _serverCore = ServerCoreManager.GetServerCore(
         baseLocation,
         serviceConfigurationOptions ?? Configuration.EmbeddedServiceConfiguration);
 }
Exemplo n.º 10
0
        public ConfigurationProvider()
        {
            // Transaction Flushing
            TransactionFlushTripleCount = GetApplicationSetting(TxnFlushTriggerPropertyName, 10000);

            // ResourceCacheLimit
            ResourceCacheLimit = GetApplicationSetting(ResourceCacheLimitName, DefaultResourceCacheLimit);

            // Connection String
            ConnectionString = GetApplicationSetting(ConnectionStringPropertyName);

            // Query Caching
            var enableQueryCacheString = GetApplicationSetting(EnableQueryCacheName);
            var enableQueryCache = true;
            if (!string.IsNullOrEmpty(enableQueryCacheString))
            {
                enableQueryCache = bool.Parse(enableQueryCacheString);
            }
            var queryCacheMemory = GetApplicationSetting(QueryCacheMemoryName, DefaultQueryCacheMemory);
            QueryCache = GetQueryCache(enableQueryCache, queryCacheMemory);

            // Persistence Type
            var persistenceTypeSetting = GetApplicationSetting(PersistenceTypeName);
            if (!String.IsNullOrEmpty(persistenceTypeSetting))
            {
                switch (persistenceTypeSetting.ToLowerInvariant())
                {
                    case PersistenceTypeAppendOnly:
                        PersistenceType = PersistenceType.AppendOnly;
                        break;
                    case PersistenceTypeRewrite:
                        PersistenceType = PersistenceType.Rewrite;
                        break;
                    default:
                        PersistenceType = DefaultPersistenceType;
                        break;
                }
            }
            else
            {
                PersistenceType = DefaultPersistenceType;
            }
            // Page Cache Size
            PageCacheSize = GetApplicationSetting(PageCacheSizeName, DefaultPageCacheSize);

            // StatsUpdate properties
            StatsUpdateTransactionCount = GetApplicationSetting(StatsUpdateTransactionCountName, 0);
            StatsUpdateTimespan = GetApplicationSetting(StatsUpdateTimeSpanName, 0);

            // Cache Preload Configuration
            var preloadConfig = new PageCachePreloadConfiguration
            {
                DefaultCacheRatio = GetApplicationSetting(CachePreloadRatioName, 0.5m),
                Enabled = GetApplicationSetting(CachePreloadEnabledName, false)
            };

            EmbeddedServiceConfiguration = new EmbeddedServiceConfiguration(preloadConfig, false);
        }
Exemplo n.º 11
0
 ///<summary>
 /// Gets a client based on the connection string parameter
 ///</summary>
 ///<param name="connectionString">The connection string</param>
 /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options that apply only when creating an embedded service instance.</param>
 ///<returns>A new Brightstar service client</returns>
 public static IBrightstarService GetClient(string connectionString, EmbeddedServiceConfiguration serviceConfigurationOptions = null)
 {
     return GetClient(new ConnectionString(connectionString), serviceConfigurationOptions);
 }
Exemplo n.º 12
0
 ///<summary>
 /// Returns a client for the embededd stores in the specified location
 ///</summary>
 ///<param name="baseLocation">The base directory for stores accessed by this client</param>
 /// <param name="serviceConfigurationOptions">OPTIONAL: Additional configuration options that apply only when creating an embedded service instance.</param>
 ///<returns>A new Brightstar service client</returns>
 internal static IBrightstarService GetEmbeddedClient(string baseLocation, EmbeddedServiceConfiguration serviceConfigurationOptions = null)
 {
     return new EmbeddedBrightstarService(baseLocation, serviceConfigurationOptions);
 }