Ejemplo n.º 1
0
        public DocumentDatabase(string name, RavenConfiguration configuration, ServerStore serverStore)
        {
            Scripts       = new ScriptRunnerCache(this);
            _logger       = LoggingSource.Instance.GetLogger <DocumentDatabase>(Name);
            _serverStore  = serverStore;
            StartTime     = SystemTime.UtcNow;
            Name          = name;
            Configuration = configuration;

            try
            {
                using (_serverStore.ContextPool.AllocateOperationContext(out TransactionOperationContext ctx))
                    using (ctx.OpenReadTransaction())
                    {
                        MasterKey = serverStore.GetSecretKey(ctx, Name);

                        var databaseRecord = _serverStore.Cluster.ReadDatabase(ctx, Name);
                        if (databaseRecord != null)
                        {
                            // can happen when we are in the process of restoring a database
                            if (databaseRecord.Encrypted && MasterKey == null)
                            {
                                throw new InvalidOperationException($"Attempt to create encrypted db {Name} without supplying the secret key");
                            }
                            if (databaseRecord.Encrypted == false && MasterKey != null)
                            {
                                throw new InvalidOperationException($"Attempt to create a non-encrypted db {Name}, but a secret key exists for this db.");
                            }
                        }
                    }

                QueryMetadataCache       = new QueryMetadataCache();
                IoChanges                = new IoChangesNotifications();
                Changes                  = new DocumentsChanges();
                DocumentTombstoneCleaner = new DocumentTombstoneCleaner(this);
                DocumentsStorage         = new DocumentsStorage(this);
                IndexStore               = new IndexStore(this, serverStore, _indexAndTransformerLocker);
                EtlLoader                = new EtlLoader(this, serverStore);
                ReplicationLoader        = new ReplicationLoader(this, serverStore);
                SubscriptionStorage      = new SubscriptionStorage(this, serverStore);
                Metrics                  = new MetricsCountersManager();
                TxMerger                 = new TransactionOperationsMerger(this, DatabaseShutdown);
                HugeDocuments            = new HugeDocuments(configuration.PerformanceHints.HugeDocumentsCollectionSize,
                                                             configuration.PerformanceHints.HugeDocumentSize.GetValue(SizeUnit.Bytes));
                ConfigurationStorage            = new ConfigurationStorage(this);
                NotificationCenter              = new NotificationCenter.NotificationCenter(ConfigurationStorage.NotificationsStorage, Name, _databaseShutdown.Token);
                Operations                      = new Operations.Operations(Name, ConfigurationStorage.OperationsStorage, NotificationCenter, Changes);
                DatabaseInfoCache               = serverStore.DatabaseInfoCache;
                RachisLogIndexNotifications     = new RachisLogIndexNotifications(DatabaseShutdown);
                CatastrophicFailureNotification = new CatastrophicFailureNotification(e =>
                {
                    serverStore.DatabasesLandlord.UnloadResourceOnCatastrophicFailure(name, e);
                });
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
Ejemplo n.º 2
0
 public EtlProcessStatistics(string processType, string name, NotificationCenter.NotificationCenter notificationCenter, string databaseName)
 {
     _processType        = processType;
     _name               = name;
     _notificationCenter = notificationCenter;
     _databaseName       = databaseName;
 }
Ejemplo n.º 3
0
 public HugeDocuments(NotificationCenter.NotificationCenter notificationCenter, NotificationsStorage notificationsStorage, string database, int maxCollectionSize, long maxWarnSize)
 {
     _notificationCenter   = notificationCenter;
     _notificationsStorage = notificationsStorage;
     _database             = database;
     _maxWarnSize          = maxWarnSize;
     _hugeDocs             = new SizeLimitedConcurrentDictionary <Tuple <string, DateTime>, long>(maxCollectionSize);
 }
Ejemplo n.º 4
0
 public HugeDocuments(NotificationCenter.NotificationCenter notificationCenter, NotificationsStorage notificationsStorage, string database, int maxCollectionSize, long maxWarnSize)
 {
     _notificationCenter   = notificationCenter;
     _notificationsStorage = notificationsStorage;
     _database             = database;
     _maxWarnSize          = maxWarnSize;
     _hugeDocs             = new SizeLimitedConcurrentDictionary <Tuple <string, DateTime>, long>(maxCollectionSize);
     _logger = LoggingSource.Instance.GetLogger(database, GetType().FullName);
 }
Ejemplo n.º 5
0
 public EtlProcessStatistics(string processTag, string processName, NotificationCenter.NotificationCenter notificationCenter)
 {
     _processTag         = processTag;
     _processName        = processName;
     _notificationCenter = notificationCenter;
     TransformationErrorsInCurrentBatch = new EtlErrorsDetails();
     LastLoadErrorsInCurrentBatch       = new EtlErrorsDetails();
     LastSlowSqlWarningsInCurrentBatch  = new SlowSqlDetails();
     _alertsGuard = new EnsureAlerts(this);
 }
Ejemplo n.º 6
0
        public Operations(string name,
                          OperationsStorage operationsStorage,
                          NotificationCenter.NotificationCenter notificationCenter,
                          DocumentsChanges changes)
        {
            _operationsStorage  = operationsStorage;
            _notificationCenter = notificationCenter;
            _changes            = changes;

            _logger = LoggingSource.Instance.GetLogger <Operations>(name);
        }
Ejemplo n.º 7
0
 public Operations(string name,
                   OperationsStorage operationsStorage,
                   NotificationCenter.NotificationCenter notificationCenter,
                   DocumentsChanges changes,
                   TimeSpan maxCompletedTaskLifeTime)
 {
     _name = name;
     _operationsStorage        = operationsStorage;
     _notificationCenter       = notificationCenter;
     _changes                  = changes;
     _maxCompletedTaskLifeTime = maxCompletedTaskLifeTime;
     LowMemoryNotification.Instance.RegisterLowMemoryHandler(this);
 }
Ejemplo n.º 8
0
        internal static ExtensionPointCpuUsageCalculator GetExtensionPointCpuUsageCalculator(
            JsonContextPool contextPool,
            MonitoringConfiguration configuration,
            NotificationCenter.NotificationCenter notificationCenter)
        {
            var extensionPoint = new ExtensionPointCpuUsageCalculator(
                contextPool,
                configuration.CpuUsageMonitorExec,
                configuration.CpuUsageMonitorExecArguments,
                notificationCenter);



            return(extensionPoint);
        }
Ejemplo n.º 9
0
 public CpuUsageExtensionPoint(
     JsonContextPool contextPool,
     string exec,
     string args,
     NotificationCenter.NotificationCenter notificationCenter)
 {
     _contextPool        = contextPool;
     _notificationCenter = notificationCenter;
     _startInfo          = new ProcessStartInfo
     {
         FileName               = exec,
         Arguments              = args,
         UseShellExecute        = false,
         RedirectStandardOutput = true,
         RedirectStandardError  = true,
         CreateNoWindow         = true
     };
 }
Ejemplo n.º 10
0
 public EtlProcessStatistics(string processType, string name, NotificationCenter.NotificationCenter notificationCenter)
 {
     _processType        = processType;
     _name               = name;
     _notificationCenter = notificationCenter;
 }
Ejemplo n.º 11
0
        public StorageSpaceMonitor(NotificationCenter.NotificationCenter notificationCenter)
        {
            _notificationCenter = notificationCenter;

            _timer = new Timer(Run, null, CheckFrequency, CheckFrequency);
        }