public RavenDBOptions(InMemoryRavenConfiguration configuration, DocumentDatabase db = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } try { ThreadPool.SetMinThreads(configuration.MinThreadPoolWorkerThreads, configuration.MinThreadPoolCompletionThreads); HttpEndpointRegistration.RegisterHttpEndpointTarget(); HttpEndpointRegistration.RegisterAdminLogsTarget(); if (db == null) { configuration.UpdateDataDirForLegacySystemDb(); systemDatabase = new DocumentDatabase(configuration, null); systemDatabase.SpinBackgroundWorkers(false); } else { systemDatabase = db; } WebSocketBufferPool.Initialize(configuration.WebSockets.InitialBufferPoolSize); fileSystemLandlord = new FileSystemsLandlord(systemDatabase); databasesLandlord = new DatabasesLandlord(systemDatabase); countersLandlord = new CountersLandlord(systemDatabase); timeSeriesLandlord = new TimeSeriesLandlord(systemDatabase); requestManager = new RequestManager(databasesLandlord); systemDatabase.RequestManager = requestManager; ClusterManager = new Reference <ClusterManager>(); systemDatabase.ClusterManager = ClusterManager; mixedModeRequestAuthorizer = new MixedModeRequestAuthorizer(); mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration)); serverStartupTasks = configuration.Container.GetExportedValues <IServerStartupTask>(); foreach (var task in serverStartupTasks) { toDispose.Add(task); try { task.Execute(this); } catch (Exception e) { systemDatabase.LogErrorAndAddAlertOnStartupTaskException(task.GetType().FullName, e); } } } catch (Exception) { if (systemDatabase != null) { systemDatabase.Dispose(); } throw; } }
public WebSocketsRequestParser(DatabasesLandlord databasesLandlord, TimeSeriesLandlord timeSeriesLandlord, CountersLandlord countersLandlord, FileSystemsLandlord fileSystemsLandlord, MixedModeRequestAuthorizer authorizer, string expectedRequestSuffix) { DatabasesLandlord = databasesLandlord; this.timeSeriesLandlord = timeSeriesLandlord; this.countersLandlord = countersLandlord; this.fileSystemsLandlord = fileSystemsLandlord; this.authorizer = authorizer; this.expectedRequestSuffix = expectedRequestSuffix; }
public async Task <HttpResponseMessage> GetTimeSeriesMetrics(string timeSeriesName) { var timeSeries = await TimeSeriesLandlord.GetResourceInternal(timeSeriesName).ConfigureAwait(false); if (timeSeries == null) { return(GetMessageWithString(string.Format("Time series with name {0} not found.", timeSeriesName), HttpStatusCode.NotFound)); } return(GetMessageWithObject(timeSeries.CreateMetrics())); }
public RavenDBOptions(RavenConfiguration configuration, DocumentDatabase db = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } try { HttpEndpointRegistration.RegisterHttpEndpointTarget(); HttpEndpointRegistration.RegisterAdminLogsTarget(); if (db == null) { systemDatabase = new DocumentDatabase(configuration, null); systemDatabase.SpinBackgroundWorkers(false); } else { systemDatabase = db; } WebSocketBufferPool.Initialize((int)configuration.WebSockets.InitialBufferPoolSize.GetValue(SizeUnit.Bytes)); fileSystemLandlord = new FileSystemsLandlord(systemDatabase); databasesLandlord = new DatabasesLandlord(systemDatabase); countersLandlord = new CountersLandlord(systemDatabase); timeSeriesLandlord = new TimeSeriesLandlord(systemDatabase); requestManager = new RequestManager(databasesLandlord); systemDatabase.RequestManager = requestManager; ClusterManager = new Reference <ClusterManager>(); mixedModeRequestAuthorizer = new MixedModeRequestAuthorizer(); mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration)); serverStartupTasks = configuration.Container.GetExportedValues <IServerStartupTask>(); foreach (var task in serverStartupTasks) { toDispose.Add(task); task.Execute(this); } } catch (Exception) { if (systemDatabase != null) { systemDatabase.Dispose(); } throw; } }
public async Task <HttpResponseMessage> Put(string id) { MessageWithStatusCode nameFormatErrorMessage; if (IsValidName(id, SystemConfiguration.TimeSeries.DataDirectory, out nameFormatErrorMessage) == false) { return(GetMessageWithObject(new { Error = nameFormatErrorMessage.Message }, nameFormatErrorMessage.ErrorCode)); } if (Authentication.IsLicensedForTimeSeries == false) { return(GetMessageWithObject(new { Error = "Your license does not allow the use of Time Series!" }, HttpStatusCode.BadRequest)); } var docKey = Constants.TimeSeries.Prefix + id; var isTimeSeriesUpdate = ParseBoolQueryString("update"); var timeSeries = SystemDatabase.Documents.Get(docKey, null); if (timeSeries != null && isTimeSeriesUpdate == false) { return(GetMessageWithString(string.Format("Time series {0} already exists!", id), HttpStatusCode.Conflict)); } var dbDoc = await ReadJsonObjectAsync <TimeSeriesDocument>().ConfigureAwait(false); TimeSeriesLandlord.Protect(dbDoc); var json = RavenJObject.FromObject(dbDoc); json.Remove("Id"); SystemDatabase.Documents.Put(docKey, null, json, new RavenJObject(), null); return(GetEmptyMessage(HttpStatusCode.Created)); }
public HttpResponseMessage GetTimeSeriesInfo() { var infos = new List <TimeSeriesDebugInfo>(); TimeSeriesLandlord.ForAllTimeSeries(ts => { using (var reader = ts.CreateReader()) { infos.Add(new TimeSeriesDebugInfo { ReplicationActiveTasksCount = ts.ReplicationTask.GetActiveTasksCount(), ReplicationDestinationStats = ts.ReplicationTask.DestinationStats, LastWrite = ts.LastWrite, ServerId = ts.ServerId, Summary = ts.CreateStats(reader), ExtensionsState = ts.ExtensionsState }); } }); return(GetMessageWithObject(infos)); }
private MessageWithStatusCode DeleteTimeSeries(string id, bool isHardDeleteNeeded) { //get configuration even if the time series is disabled var configuration = TimeSeriesLandlord.CreateTenantConfiguration(id, true); if (configuration == null) { return new MessageWithStatusCode { ErrorCode = HttpStatusCode.NotFound, Message = "Time series wasn't found" } } ; var docKey = Constants.TimeSeries.Prefix + id; SystemDatabase.Documents.Delete(docKey, null, null); if (isHardDeleteNeeded && configuration.RunInMemory == false) { IOExtensions.DeleteDirectory(configuration.TimeSeries.DataDirectory); } return(new MessageWithStatusCode()); }
public HttpResponseMessage ResourceDrives(string name, string type) { ResourceType resourceType; if (Enum.TryParse(type, out resourceType) == false) { return(GetMessageWithString("Unknown resourceType:" + type, HttpStatusCode.BadRequest)); } string[] drives = null; InMemoryRavenConfiguration config; switch (resourceType) { case ResourceType.Database: config = DatabasesLandlord.CreateTenantConfiguration(name); if (config == null) { return(GetMessageWithString("Unable to find database named: " + name, HttpStatusCode.NotFound)); } drives = FindUniqueDrives(new[] { config.IndexStoragePath, config.Storage.Esent.JournalsStoragePath, config.Storage.Voron.JournalsStoragePath, config.DataDirectory }); break; case ResourceType.FileSystem: config = FileSystemsLandlord.CreateTenantConfiguration(name); if (config == null) { return(GetMessageWithString("Unable to find filesystem named: " + name, HttpStatusCode.NotFound)); } drives = FindUniqueDrives(new[] { config.FileSystem.DataDirectory, config.FileSystem.IndexStoragePath, config.Storage.Esent.JournalsStoragePath, config.Storage.Voron.JournalsStoragePath }); break; case ResourceType.Counter: config = CountersLandlord.CreateTenantConfiguration(name); if (config == null) { return(GetMessageWithString("Unable to find counter named: " + name, HttpStatusCode.NotFound)); } drives = FindUniqueDrives(new[] { config.Counter.DataDirectory, config.Storage.Esent.JournalsStoragePath, config.Storage.Voron.JournalsStoragePath, config.DataDirectory }); break; case ResourceType.TimeSeries: config = TimeSeriesLandlord.CreateTenantConfiguration(name); if (config == null) { return(GetMessageWithString("Unable to find time series named: " + name, HttpStatusCode.NotFound)); } drives = FindUniqueDrives(new[] { config.TimeSeries.DataDirectory, config.Storage.Esent.JournalsStoragePath, config.Storage.Voron.JournalsStoragePath, config.DataDirectory }); break; } return(GetMessageWithObject(drives)); }
public AdminLogsWebSocketsRequestParser(DatabasesLandlord databasesLandlord, TimeSeriesLandlord timeSeriesLandlord, CountersLandlord countersLandlord, FileSystemsLandlord fileSystemsLandlord, MixedModeRequestAuthorizer authorizer, string expectedRequestSuffix) : base(databasesLandlord, timeSeriesLandlord, countersLandlord, fileSystemsLandlord, authorizer, expectedRequestSuffix) { }