示例#1
0
        public void Execute(RavenDBOptions serverOptions)
        {
            if (IsValidLicense() == false)
            {
                return;
            }

            systemDatabase = serverOptions.SystemDatabase;
            clusterManager = serverOptions.ClusterManager.Value = ClusterManagerFactory.Create(systemDatabase, serverOptions.DatabaseLandlord);

            systemDatabase.Notifications.OnDocumentChange += (db, notification, metadata) =>
            {
                if (string.Equals(notification.Id, Constants.Cluster.ClusterConfigurationDocumentKey, StringComparison.OrdinalIgnoreCase))
                {
                    if (notification.Type != DocumentChangeTypes.Put)
                    {
                        return;
                    }

                    HandleClusterConfigurationChanges();
                }
            };

            clusterManager.Engine.TopologyChanged += HandleTopologyChanges;

            HandleClusterConfigurationChanges();
        }
示例#2
0
 public WebSocketsTrasport(RavenDBOptions options, IOwinContext context)
 {
     _options  = options;
     _context  = context;
     Connected = true;
     Id        = context.Request.Query["id"];
 }
示例#3
0
        private static HttpConfiguration CreateHttpCfg(RavenDBOptions options)
        {
            var cfg = new HttpConfiguration();

            cfg.Properties[typeof(DatabasesLandlord)]          = options.DatabaseLandlord;
            cfg.Properties[typeof(FileSystemsLandlord)]        = options.FileSystemLandlord;
            cfg.Properties[typeof(CountersLandlord)]           = options.CountersLandlord;
            cfg.Properties[typeof(MixedModeRequestAuthorizer)] = options.MixedModeRequestAuthorizer;
            cfg.Properties[typeof(RequestManager)]             = options.RequestManager;
            cfg.Properties[Constants.MaxConcurrentRequestsForDatabaseDuringLoad] = new SemaphoreSlim(options.SystemDatabase.Configuration.MaxConcurrentRequestsForDatabaseDuringLoad);
            cfg.Properties[Constants.MaxSecondsForTaskToWaitForDatabaseToLoad]   = options.SystemDatabase.Configuration.MaxSecondsForTaskToWaitForDatabaseToLoad;
            cfg.Formatters.Remove(cfg.Formatters.XmlFormatter);
            cfg.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new NaveValueCollectionJsonConverterOnlyForConfigFormatters());
            cfg.Services.Replace(typeof(IAssembliesResolver), new RavenAssemblyResolver());
            cfg.Filters.Add(new RavenExceptionFilterAttribute());

            cfg.MessageHandlers.Add(new ThrottlingHandler(options.SystemDatabase.Configuration.MaxConcurrentServerRequests));
            cfg.MessageHandlers.Add(new GZipToJsonAndCompressHandler());

            cfg.Services.Replace(typeof(IHostBufferPolicySelector), new SelectiveBufferPolicySelector());

            if (RouteCacher.TryAddRoutesFromCache(cfg) == false)
            {
                AddRoutes(cfg);
            }

            cfg.EnsureInitialized();

            RouteCacher.CacheRoutesIfNecessary(cfg);

            return(cfg);
        }
示例#4
0
 public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
 {
     try
     {
         if (RavenGC.GcCollectLock.TryEnterReadLock(5000) == false)
             throw new TimeoutException("Could not create a new web socket connection. Probably because GC is currently in progress, try again later.");
         var localPath = context.Request.Path.Value;
         if (localPath.EndsWith(ChangesApiWebsocketSuffix))
         {
             return new WebSocketsTransport(options, context, ravenGcCancellation.Token);
         }
         if (localPath.EndsWith(WatchTrafficWebsocketSuffix))
         {
             return new WatchTrafficWebsocketTransport(options, context, ravenGcCancellation.Token);
         }
         if (localPath.EndsWith(AdminLogsWebsocketSuffix))
         {
             return new AdminLogsWebsocketTransport(options, context, ravenGcCancellation.Token);
         }
         if (localPath.EndsWith(WebsocketValidateSuffix))
         {
             return new WebSocketsValidateTransport(options, context, ravenGcCancellation.Token);
         }
         return null;
     }
     finally
     {
         if (RavenGC.GcCollectLock.IsReadLockHeld)
             RavenGC.GcCollectLock.ExitReadLock();
     }
 }
示例#5
0
        private static HttpConfiguration CreateHttpCfg(RavenDBOptions options)
        {
            var cfg = new HttpConfiguration();

            cfg.Properties[typeof(DatabasesLandlord)]          = options.DatabaseLandlord;
            cfg.Properties[typeof(FileSystemsLandlord)]        = options.FileSystemLandlord;
            cfg.Properties[typeof(CountersLandlord)]           = options.CountersLandlord;
            cfg.Properties[typeof(MixedModeRequestAuthorizer)] = options.MixedModeRequestAuthorizer;
            cfg.Properties[typeof(RequestManager)]             = options.RequestManager;
            cfg.Formatters.Remove(cfg.Formatters.XmlFormatter);
            cfg.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new NaveValueCollectionJsonConverterOnlyForConfigFormatters());

            cfg.Services.Replace(typeof(IAssembliesResolver), new MyAssemblyResolver());
            cfg.Filters.Add(new RavenExceptionFilterAttribute());
            cfg.MapHttpAttributeRoutes();

            cfg.Routes.MapHttpRoute(
                "RavenFs", "fs/{controller}/{action}",
                new { id = RouteParameter.Optional });

            cfg.Routes.MapHttpRoute(
                "API Default", "{controller}/{action}",
                new { id = RouteParameter.Optional });

            cfg.Routes.MapHttpRoute(
                "Database Route", "databases/{databaseName}/{controller}/{action}",
                new { id = RouteParameter.Optional });

            cfg.MessageHandlers.Add(new ThrottlingHandler(options.SystemDatabase.Configuration.MaxConcurrentServerRequests));
            cfg.MessageHandlers.Add(new GZipToJsonAndCompressHandler());

            cfg.Services.Replace(typeof(IHostBufferPolicySelector), new SelectiveBufferPolicySelector());
            cfg.EnsureInitialized();
            return(cfg);
        }
示例#6
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            WebSocketsTransport webSocketsTrasport = WebSocketTransportFactory.CreateWebSocketTransport(options, context);

            if (webSocketsTrasport != null)
            {
                if (await webSocketsTrasport.TrySetupRequest())
                {
                    accept(new Dictionary <string, object>()
                    {
                        { "websocket.ReceiveBufferSize", 256 },
                        { "websocket.Buffer", webSocketsTrasport.PreAllocatedBuffer },
                        { "websocket.KeepAliveInterval", WebSocket.DefaultKeepAliveInterval }
                    }, webSocketsTrasport.Run);
                }
            }
        }
示例#7
0
 public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
 {
     RavenGC.GcCollectLock.EnterReadLock();
     try
     {
         var localPath = context.Request.Path.Value;
         if (localPath.EndsWith(ChangesApiWebsocketSuffix))
         {
             return(new WebSocketsTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(WatchTrafficWebsocketSuffix))
         {
             return(new WatchTrafficWebsocketTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(AdminLogsWebsocketSuffix))
         {
             return(new AdminLogsWebsocketTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(WebsocketValidateSuffix))
         {
             return(new WebSocketsValidateTransport(options, context, ravenGcCancellation.Token));
         }
         return(null);
     }
     finally
     {
         RavenGC.GcCollectLock.ExitReadLock();
     }
 }
示例#8
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            if (context.Request.Uri.LocalPath.EndsWith("changes/websocket") == false)
            {
                // Not a websocket request
                await next();

                return;
            }

            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            var webSocketsTrasport = new WebSocketsTrasport(options, context);

            if (await webSocketsTrasport.TrySetupRequest())
            {
                accept(null, webSocketsTrasport.Run);
            }
        }
示例#9
0
        public RavenDbServer Initialize(Action <RavenDBOptions> configure = null)
        {
            if (configuration.IgnoreSslCertificateErros == IgnoreSslCertificateErrorsMode.All)
            {
                // we ignore either all or none at the moment
                ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
            }

            owinHttpServer                   = new OwinHttpServer(configuration, useHttpServer: UseEmbeddedHttpServer, configure: configure);
            options                          = owinHttpServer.Options;
            serverThingsForTests             = new ServerThingsForTests(options);
            documentStore.HttpMessageHandler = new OwinClientHandler(owinHttpServer.Invoke, options.SystemDatabase.Configuration.EnableResponseLoggingForEmbeddedDatabases);
            documentStore.Url                = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            documentStore.Initialize();

            filesStore.HttpMessageHandler = new OwinClientHandler(owinHttpServer.Invoke, options.SystemDatabase.Configuration.EnableResponseLoggingForEmbeddedDatabases);
            filesStore.Url = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            filesStore.Initialize();

            serverStartupTasks = configuration.Container.GetExportedValues <IServerStartupTask>();

            foreach (var task in serverStartupTasks)
            {
                toDispose.Add(task);
                task.Execute(this);
            }

            return(this);
        }
示例#10
0
        public static IAppBuilder UseRavenDB(this IAppBuilder app, RavenDBOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (app.Properties.ContainsKey(HostOnAppDisposing))
            {
                // This is a katana specific key (i.e. not a standard OWIN key) to be notified
                // when the host in being shut down. Works both in HttpListener and SystemWeb hosting
                // Until owin spec is officially updated, there is no other way to know the host
                // is shutting down / disposing
                var appDisposing = app.Properties[HostOnAppDisposing] as CancellationToken?;
                if (appDisposing.HasValue)
                {
                    appDisposing.Value.Register(options.Dispose);
                }
            }

            AssemblyExtractor.ExtractEmbeddedAssemblies();

#if DEBUG
            app.UseInterceptor();
#endif

            app.Use((context, func) => UpgradeToWebSockets(options, context, func));

            app.UseWebApi(CreateHttpCfg(options));


            return(app);
        }
示例#11
0
 public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
 {
     try
     {
         if (RavenGC.GcCollectLock.TryEnterReadLock(5000) == false)
         {
             throw new TimeoutException("Could not create a new web socket connection. Probably because GC is currently in progress, try again later.");
         }
         var localPath = context.Request.Path.Value;
         if (localPath.EndsWith(ChangesApiWebsocketSuffix))
         {
             return(new WebSocketsTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(WatchTrafficWebsocketSuffix))
         {
             return(new WatchTrafficWebsocketTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(AdminLogsWebsocketSuffix))
         {
             return(new AdminLogsWebsocketTransport(options, context, ravenGcCancellation.Token));
         }
         if (localPath.EndsWith(WebsocketValidateSuffix))
         {
             return(new WebSocketsValidateTransport(options, context, ravenGcCancellation.Token));
         }
         return(null);
     }
     finally
     {
         if (RavenGC.GcCollectLock.IsReadLockHeld)
         {
             RavenGC.GcCollectLock.ExitReadLock();
         }
     }
 }
示例#12
0
        public RavenDbServer Initialize(Action <RavenDBOptions> configure = null)
        {
            if (configuration.IgnoreSslCertificateErrors == IgnoreSslCertificateErrorsMode.All)
            {
                // we ignore either all or none at the moment
                ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
            }
            BooleanQuery.MaxClauseCount = configuration.MaxClauseCount;

            BooleanQuery.MaxClauseCount = configuration.MaxClauseCount;

            owinHttpServer = new OwinHttpServer(configuration, useHttpServer: UseEmbeddedHttpServer, configure: configure);
            options        = owinHttpServer.Options;

            serverThingsForTests = new ServerThingsForTests(options);
            Func <HttpMessageHandler> httpMessageHandlerFactory = () => new OwinClientHandler(owinHttpServer.Invoke, options.SystemDatabase.Configuration.EnableResponseLoggingForEmbeddedDatabases);

            documentStore.HttpMessageHandlerFactory = httpMessageHandlerFactory;
            documentStore.Url = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            documentStore.Initialize();

            filesStore.HttpMessageHandlerFactory = httpMessageHandlerFactory;
            filesStore.Url = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            filesStore.Initialize();

            return(this);
        }
示例#13
0
        private SnmpEngine CreateSnmpEngine(RavenDBOptions serverOptions, ObjectStore store)
        {
            var configuration = serverOptions.SystemDatabase.Configuration;

            var v2MembershipProvider = new Version2MembershipProvider(new OctetString(configuration.Monitoring.Snmp.Community), new OctetString(configuration.Monitoring.Snmp.Community));
            var v3MembershipProvider = new Version3MembershipProvider();
            var membershipProvider   = new ComposedMembershipProvider(new IMembershipProvider[] { v2MembershipProvider, v3MembershipProvider });

            var handlers = new[]
            {
                new HandlerMapping("V2,V3", "GET", new GetMessageHandler()),
                new HandlerMapping("V2,V3", "GETNEXT", new GetNextMessageHandler()),
                new HandlerMapping("V2,V3", "GETBULK", new GetBulkMessageHandler())
            };

            var messageHandlerFactory = new MessageHandlerFactory(handlers);

            var factory = new SnmpApplicationFactory(new Logger(log), store, membershipProvider, messageHandlerFactory);

            var listener    = new Listener();
            var engineGroup = new EngineGroup();

            var engine = new SnmpEngine(factory, listener, engineGroup);

            engine.Listener.AddBinding(new IPEndPoint(IPAddress.Any, configuration.Monitoring.Snmp.Port));
            engine.Listener.ExceptionRaised += (sender, e) => log.ErrorException("SNMP error: " + e.Exception.Message, e.Exception);

            return(engine);
        }
示例#14
0
 public void Execute(RavenDBOptions serverOptions)
 {
     landlord        = serverOptions.DatabaseLandlord;
     licensingStatus = GetLicensingStatus();
     ValidateLicense.CurrentLicenseChanged += OnCurrentLicenseChanged;
     CheckSupportCoverage();
     supportTimer = landlord.SystemDatabase.TimerManager.NewTimer(_ => CheckSupportCoverage(), OneDay, OneDay);
 }
示例#15
0
 protected override void ConfigureServer(RavenDBOptions dbOptions)
 {
     dbOptions.DatabaseLandlord.SetupTenantConfiguration += configuration =>
     {
         configuration.Catalog.Catalogs.Add(new TypeCatalog(typeof(DeleteOnConflict)));
         configuration.Catalog.Catalogs.Add(new TypeCatalog(typeof(PutOnConflict)));
     };
 }
 public void Execute(RavenDBOptions serverOptions)
 {
     requestManger = serverOptions.RequestManager;
     landlord      = serverOptions.DatabaseLandlord;
     requestManger.HotSpareValidator = this;
     licensingStatus = GetLicensingStatus();
     ValidateLicense.CurrentLicenseChanged += OnCurrentLicenseChanged;
     CheckHotSpareLicenseStats();
 }
示例#17
0
 public RavenDbServer Initialize(Action <RavenDBOptions> configure = null)
 {
     owinHttpServer                   = new OwinHttpServer(configuration, useHttpServer: UseEmbeddedHttpServer, configure: configure);
     options                          = owinHttpServer.Options;
     serverThingsForTests             = new ServerThingsForTests(options);
     documentStore.HttpMessageHandler = new OwinClientHandler(owinHttpServer.Invoke);
     documentStore.Url                = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
     documentStore.Initialize();
     return(this);
 }
示例#18
0
        public WebSocketsTransport(RavenDBOptions options, IOwinContext context)
        {
            _options  = options;
            _context  = context;
            Connected = true;
            Id        = context.Request.Query["id"];
            long waitTimeBetweenMessages = 0;

            long.TryParse(context.Request.Query["coolDownWithDataLoss"], out waitTimeBetweenMessages);
            CoolDownWithDataLossInMiliseconds = waitTimeBetweenMessages;
        }
示例#19
0
        public WebSocketsTransport(RavenDBOptions options, IOwinContext context, CancellationToken disconnectBecauseOfGcToken)
        {
            _options = options;
            _context = context;
            this.disconnectBecauseOfGcToken = disconnectBecauseOfGcToken;
            Connected = true;
            Id        = context.Request.Query["id"];
            long waitTimeBetweenMessages = 0;

            long.TryParse(context.Request.Query["coolDownWithDataLoss"], out waitTimeBetweenMessages);
            CoolDownWithDataLossInMiliseconds = waitTimeBetweenMessages;
            PreAllocatedBuffer = WebSocketBufferPool.Instance.TakeBuffer();
        }
示例#20
0
 public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
 {
     if (context.Request.Uri.LocalPath.EndsWith(ChangesApiWebsocketSuffix))
     {
         return(new WebSocketsTransport(options, context));
     }
     if (context.Request.Uri.LocalPath.EndsWith(WatchTrafficWebsocketSuffix))
     {
         return(new WatchTrafficWebsocketTransport(options, context));
     }
     if (context.Request.Uri.LocalPath.EndsWith(AdminLogsWebsocketSuffix))
     {
         return(new AdminLogsWebsocketTransport(options, context));
     }
     return(null);
 }
示例#21
0
 public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
 {
     if (context.Request.Uri.LocalPath.EndsWith(ChangesApiWebsocketSuffix))
     {
         return new WebSocketsTransport(options, context);
     }
     if (context.Request.Uri.LocalPath.EndsWith(WatchTrafficWebsocketSuffix))
     {
         return new WatchTrafficWebsocketTransport(options, context);
     }
     if (context.Request.Uri.LocalPath.EndsWith(AdminLogsWebsocketSuffix))
     {
         return new AdminLogsWebsocketTransport(options, context);
     }
     return null;
 }
        /// <summary>
        /// Add a health check for RavenDB.
        /// </summary>
        /// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
        /// <param name="setup">The action to configure the RavenDB setup.</param>
        /// <param name="name">
        /// The health check name. Optional. If <see langword="null"/> the type name 'ravendb' will be used for the name.
        /// </param>
        /// <param name="failureStatus">
        /// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <see langword="null"/> then
        /// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
        /// </param>
        /// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
        /// <returns>The <see cref="IHealthChecksBuilder"/>.</returns>
        public static IHealthChecksBuilder AddRavenDB(
            this IHealthChecksBuilder builder,
            Action <RavenDBOptions> setup,
            string name = default,
            HealthStatus?failureStatus = default,
            IEnumerable <string> tags  = default)
        {
            var options = new RavenDBOptions();

            setup?.Invoke(options);

            return(builder.Add(new HealthCheckRegistration(
                                   name ?? NAME,
                                   sp => new RavenDBHealthCheck(options),
                                   failureStatus,
                                   tags)));
        }
        public void Execute(RavenDBOptions serverOptions)
        {
            options = serverOptions;

            int val;

            if (int.TryParse(ConfigurationManager.AppSettings["Raven/Bundles/LiveTest/Tenants/MaxIdleTimeForTenantResource"], out val) == false)
            {
                val = 900;
            }

            maxTimeResourceCanBeIdle = TimeSpan.FromSeconds(val);

            log.Info("LiveTestResourceCleanerStartupTask started. MaxTimeResourceCanBeIdle: " + maxTimeResourceCanBeIdle.TotalSeconds + " seconds.");

            options.SystemDatabase.TimerManager.NewTimer(ExecuteCleanup, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(10));
        }
示例#24
0
        static void MainAttempt3(string[] args)
        {
            var ravenConfiguration = new RavenConfiguration
            {
                DataDirectory          = ConfigurationManager.AppSettings["DataDirectory"],
                CacheDocumentsInMemory = false,
                RunInMemory            = false,
                Storage =
                {
                    PreventSchemaUpdate  = true,
                    SkipConsistencyCheck = true
                }
            };

            Console.WriteLine("Configuration initialized.");

            var ravendDbOptions = new RavenDBOptions(ravenConfiguration);
        }
示例#25
0
        public void When_HostOnAppDisposing_key_not_exist_then_should_not_throw()
        {
            string path          = NewDataPath();
            var    configuration = new InMemoryRavenConfiguration {
                Settings =
                {
                    { "Raven/DataDir",                    path          },
                    { Constants.FileSystem.DataDirectory, Path.Combine(path, "FileSystem")}
                }
            };

            configuration.Initialize();

            using (var options = new RavenDBOptions(configuration))
            {
                Assert.DoesNotThrow(() => new AppBuilder().UseRavenDB(options));
            }
        }
示例#26
0
        public void Configuration(IAppBuilder app)
        {
            if (_server == null)
            {
                lock (locker)
                {
                    if (_server == null)
                    {
                        var  p             = Process.GetCurrentProcess();
                        var  aid           = AppDomain.CurrentDomain.Id;
                        bool explicitError = false;
                        try
                        {
                            Log.Info("Startup Configuration Called {0} times, process: {1}, app  domain: {2}", counter, p.Id, aid);
                            counter++;
                            var sp = Stopwatch.StartNew();
                            _server = new RavenDBOptions(new AppSettingsBasedConfiguration());
                            Log.Info("Startup Configuration completed in {0} , process: {1}, app  domain: {2}", sp.ElapsedMilliseconds, p.Id, aid);
                        }
                        catch (Exception ex)
                        {
                            Log.ErrorException(string.Format("Startup Configuration Failed, process: {0}, app  domain: {1}", p.Id, aid), ex);
                            explicitError = true;
                            if (_server != null)
                            {
                                _server.Dispose();
                                _server = null;
                            }

                            throw new HttpException(503, "Startup Configuration Failed", ex);
                        }
                        finally
                        {
                            if (_server == null && explicitError == false)
                            {
                                Log.Error("Statrup configuration completed without creating RavenDBOptions, probably aborted, process: {0}, app  domain: {1}", p.Id, aid);
                            }
                        }
                    }
                }
            }
            app.UseRavenDB(_server);
        }
示例#27
0
        public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
        {
            var localPath = context.Request.Path.Value;
            if (localPath.EndsWith(ChangesApiWebsocketSuffix))
            {
                return new WebSocketsTransport(options, context);
            }
            if (localPath.EndsWith(WatchTrafficWebsocketSuffix))
            {
                return new WatchTrafficWebsocketTransport(options, context);
            }
            if (localPath.EndsWith(AdminLogsWebsocketSuffix))
            {
                return new AdminLogsWebsocketTransport(options, context);
            }
			if (localPath.EndsWith(WebsocketValidateSuffix))
			{
				return new WebSocketsValidateTransport(options, context);
			}
            return null;
        }
示例#28
0
        public RavenDbServer Initialize(Action <RavenDBOptions> configure = null)
        {
            owinHttpServer                   = new OwinHttpServer(configuration, useHttpServer: UseEmbeddedHttpServer, configure: configure);
            options                          = owinHttpServer.Options;
            serverThingsForTests             = new ServerThingsForTests(options);
            documentStore.HttpMessageHandler = new OwinClientHandler(owinHttpServer.Invoke);
            documentStore.Url                = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            documentStore.Initialize();


            filesStore.HttpMessageHandler = new OwinClientHandler(owinHttpServer.Invoke);
            filesStore.Url = string.IsNullOrWhiteSpace(Url) ? "http://localhost" : Url;
            filesStore.Initialize();

            foreach (var task in configuration.Container.GetExportedValues <IServerStartupTask>())
            {
                task.Execute(this);
            }

            return(this);
        }
示例#29
0
        public static WebSocketsTransport CreateWebSocketTransport(RavenDBOptions options, IOwinContext context)
        {
            var localPath = context.Request.Path.Value;

            if (localPath.EndsWith(ChangesApiWebsocketSuffix))
            {
                return(new WebSocketsTransport(options, context));
            }
            if (localPath.EndsWith(WatchTrafficWebsocketSuffix))
            {
                return(new WatchTrafficWebsocketTransport(options, context));
            }
            if (localPath.EndsWith(AdminLogsWebsocketSuffix))
            {
                return(new AdminLogsWebsocketTransport(options, context));
            }
            if (localPath.EndsWith(WebsocketValidateSuffix))
            {
                return(new WebSocketsValidateTransport(options, context));
            }
            return(null);
        }
示例#30
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            WebSocketsTransport webSocketsTrasport = WebSocketTransportFactory.CreateWebSocketTransport(options, context);

            if (webSocketsTrasport != null)
            {
                if (await webSocketsTrasport.TrySetupRequest())
                {
                    accept(null, webSocketsTrasport.Run);
                }
            }
        }
示例#31
0
        public void Execute(RavenDBOptions serverOptions)
        {
            if (serverOptions.SystemDatabase.Configuration.Monitoring.Snmp.Enabled == false)
            {
                return;
            }

            if (IsLicenseValid() == false)
            {
                throw new InvalidOperationException("Your license does not allow you to use SNMP monitoring.");
            }

            systemDatabase   = serverOptions.SystemDatabase;
            databaseLandlord = serverOptions.DatabaseLandlord;

            objectStore = CreateStore(serverOptions);

            snmpEngine = CreateSnmpEngine(serverOptions, objectStore);
            snmpEngine.Start();

            databaseLandlord.OnDatabaseLoaded += AddDatabaseIfNecessary;
            AddDatabases();
        }
示例#32
0
        private ObjectStore CreateStore(RavenDBOptions serverOptions)
        {
            var store = new ObjectStore();

            store.Add(new ServerUpTime(serverOptions.RequestManager));
            store.Add(new ServerUpTimeGlobal(serverOptions.RequestManager));
            store.Add(new ServerName(serverOptions.SystemDatabase.Configuration));
            store.Add(new ServerBuildVersion());
            store.Add(new ServerProductVersion());
            store.Add(new ServerPid());
            store.Add(new ServerTotalRequests(serverOptions.RequestManager));
            store.Add(new ServerConcurrentRequests(serverOptions.RequestManager));
            store.Add(new ServerCpu());
            store.Add(new ServerTotalMemory());
            store.Add(new ServerUrl(serverOptions.SystemDatabase.Configuration));
            store.Add(new ServerIndexingErrors(serverOptions.DatabaseLandlord));
            store.Add(new ServerLastRequestTime(serverOptions.RequestManager));

            store.Add(new DatabaseLoadedCount(serverOptions.DatabaseLandlord));
            store.Add(new DatabaseTotalCount(serverOptions.SystemDatabase));

            return(store);
        }
示例#33
0
 public WebSocketsValidateTransport(RavenDBOptions options, IOwinContext context, CancellationToken disconnectBecauseOfGcToken)
     : base(options, context, disconnectBecauseOfGcToken)
 {
 }
示例#34
0
		public WebSocketsValidateTransport(RavenDBOptions options, IOwinContext context)
			: base(options, context)
		{
		}
示例#35
0
 public WebSocketsTransport(RavenDBOptions options, IOwinContext context)
 {
     _options = options;
     _context = context;
     Connected = true;
     Id = context.Request.Query["id"];
     long waitTimeBetweenMessages = 0;
     long.TryParse(context.Request.Query["coolDownWithDataLoss"], out waitTimeBetweenMessages);
     CoolDownWithDataLossInMiliseconds = waitTimeBetweenMessages;
     
 }
示例#36
0
        public WatchTrafficWebsocketTransport(RavenDBOptions options, IOwinContext context)
            : base(options, context)
        {

        }
示例#37
0
        public AdminLogsWebsocketTransport(RavenDBOptions options, IOwinContext context)
            : base(options, context)
        {

        }
示例#38
0
 protected virtual void ConfigureServer(RavenDBOptions options)
 {
 }
示例#39
0
 public WebSocketsTransport(RavenDBOptions options, IOwinContext context, CancellationToken disconnectBecauseOfGcToken)
 {
     _options = options;
     _context = context;
     this.disconnectBecauseOfGcToken = disconnectBecauseOfGcToken;
     Connected = true;
     Id = context.Request.Query["id"];
     long waitTimeBetweenMessages = 0;
     long.TryParse(context.Request.Query["coolDownWithDataLoss"], out waitTimeBetweenMessages);
     CoolDownWithDataLossInMiliseconds = waitTimeBetweenMessages;
     PreAllocatedBuffer = WebSocketBufferPool.Instance.TakeBuffer();
 }
示例#40
0
 public AdminLogsWebsocketTransport(RavenDBOptions options, IOwinContext context, CancellationToken disconnectBecauseOfGcToken)
     : base(options, context, disconnectBecauseOfGcToken)
 {
 }