Esempio n. 1
0
 protected override void InternalStop(ServerProcess process)
 {
     base.InternalStop(process);
     if (_store != null)
     {
         _store.Dispose();
         _store = null;
     }
 }
Esempio n. 2
0
 protected override void InternalStart(ServerProcess process)
 {
     base.InternalStart(process);
     if (!process.ServerSession.Server.IsEngine)
     {
         _store = new CatalogStore();
         _store.StoreClassName        = ((Server.Server)process.ServerSession.Server).GetCatalogStoreClassName();
         _store.StoreConnectionString = ((Server.Server)process.ServerSession.Server).GetCatalogStoreConnectionString();
         _store.Initialize(process.ServerSession.Server);
     }
 }
Esempio n. 3
0
 public void RunCatalogStoreTest(string connectionString, CatalogStore catalogStore = CatalogStore.InMemory)
 {
     try
     {
         DatabaseCatalogContext databaseCatalog = new DatabaseCatalogContext();
         Stopwatch stopwatch = Stopwatch.StartNew();
         databaseCatalog.LoadCatalog(connectionString, catalogStore);
         stopwatch.Stop();
         Console.WriteLine("Loading: {0}", stopwatch.Elapsed.TotalSeconds);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Esempio n. 4
0
 public IActionResult Find(int id) => Ok(CatalogStore.Find(id));
Esempio n. 5
0
        public void LoadCatalog(string connectionString, CatalogStore catalogStore)
        {
            if (catalogStore == CatalogStore.File)
            {
                _connectionString = string.Format("DataSource=file:{0}.dacmodel;Cache=Shared", _connectionId);
            }
            else
            {
                _connectionString = string.Format("DataSource=file:{0}.dacmodel;Mode=Memory;Cache=Shared", _connectionId);
            }

            _sqliteConnection = new SqliteConnection(_connectionString);
            _sqliteConnection.Open();

            using (SqliteCommand command = _sqliteConnection.CreateCommand())
            {
                // Enable write-ahead logging to increase write performance by reducing amount of disk writes,
                // by combining writes at checkpoints, along with using sequential-only writes to populate the log.
                // Also, WAL allows for relaxed ("normal") "synchronous" mode, see below.
                command.CommandText = "pragma journal_mode=wal";
                command.ExecuteNonQuery();

                // Set "synchronous" mode to "normal" instead of default "full" to reduce the amount of buffer flushing syscalls,
                // significantly reducing both the blocked time and the amount of context switches.
                // When coupled with WAL, this (according to https://sqlite.org/pragma.html#pragma_synchronous and
                // https://www.sqlite.org/wal.html#performance_considerations) is unlikely to significantly affect durability,
                // while significantly increasing performance, because buffer flushing is done for each checkpoint, instead of each
                // transaction. While some writes can be lost, they are never reordered, and higher layers will recover from that.
                command.CommandText = "pragma synchronous=normal";
                command.ExecuteNonQuery();
            }

            this.InitializeSQLite();        // Takes about .15 seconds.  We could pre-create the file.

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                _serverInfo = GetServerInfo(connection);

                if (_serverInfo.IsManagedInstance)
                {
                    throw new NotSupportedException("Managed Instance is not supported.");
                }

                if (_serverInfo.IsAzure)
                {
                    this.LoadAzure(connection);
                }
                else if (_serverInfo.Version.Major == 15)
                {
                    this.LoadvNext(connection);
                }
                else if (_serverInfo.Version.Major == 14)
                {
                    this.Load2017(connection);
                }
                else if (_serverInfo.Version.Major == 13)
                {
                    this.Load2016(connection);
                }
                else if (_serverInfo.Version.Major == 12)
                {
                    this.Load2014(connection);
                }
                else if (_serverInfo.Version.Major == 11)
                {
                    this.Load2012(connection);
                }
                else if (_serverInfo.Version.Major == 10)
                {
                    this.Load2008(connection);
                }
                else if (_serverInfo.Version.Major == 9)
                {
                    this.Load2005(connection);
                }
                else
                {
                    throw new NotSupportedException(string.Format("Server version {0} is not supported.", _serverInfo.Version));
                }
            }
        }