Ejemplo n.º 1
0
		public HttpContextAdapter(HttpContext context, InMemroyRavenConfiguration configuration)
		{
			this.context = context;
			this.configuration = configuration;
			request = new HttpRequestAdapter(context.Request);
			response = new HttpResponseAdapter(context.Response);
		}
Ejemplo n.º 2
0
        protected override bool TryGetOrCreateResourceStore(string tenantId, out IResourceStore database)
        {
            if (ResourcesStoresCache.TryGetValue(tenantId, out database))
                return true;

            var jsonDocument = DefaultDatabase.Get("Raven/Databases/" + tenantId, null);

            if (jsonDocument == null)
                return false;

            var document = jsonDocument.DataAsJson.JsonDeserialization<DatabaseDocument>();

            database = ResourcesStoresCache.GetOrAdd(tenantId, s =>
            {
                var config = new InMemroyRavenConfiguration
                {
                    Settings = DefaultConfiguration.Settings,
                };
                config.Settings["Raven/VirtualDir"] = config.Settings["Raven/VirtualDir"] + "/" + tenantId;
                foreach (var setting in document.Settings)
                {
                    config.Settings[setting.Key] = setting.Value;
                }
                config.Initialize();
                return new DocumentDatabase(config);
            });
            return true;


        }
        public HttpListenerContextAdpater(HttpListenerContext ctx, InMemroyRavenConfiguration configuration)
		{
			this.ctx = ctx;
			this.configuration = configuration;
			Request = new HttpListenerRequestAdapter(ctx.Request);
			ResponseInternal = new HttpListenerResponseAdapter(ctx.Response);
		}
Ejemplo n.º 4
0
        public DocumentDatabase(InMemroyRavenConfiguration configuration)
        {
            Configuration = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext
            {
            	IndexUpdateTriggers = IndexUpdateTriggers,
				ReadTriggers = ReadTriggers
            };
            dynamicQueryRunner = new DynamicQueryRunner(this);

            TransactionalStorage = configuration.CreateTransactionalStorage(workContext.HandleWorkNotifications);
            configuration.Container.SatisfyImportsOnce(TransactionalStorage);

            bool newDb;
            try
            {
                newDb = TransactionalStorage.Initialize(this);
            }
            catch (Exception)
            {
                TransactionalStorage.Dispose();
                throw;
            }

            TransactionalStorage.Batch(actions => currentEtagBase = actions.General.GetNextIdentityValue("Raven/Etag"));

            IndexDefinitionStorage = new IndexDefinitionStorage(
                configuration,
                TransactionalStorage,
                configuration.DataDirectory,
                configuration.Container.GetExportedValues<AbstractViewGenerator>(),
                Extensions);
            IndexStorage = new IndexStorage(IndexDefinitionStorage, configuration);

            workContext.IndexStorage = IndexStorage;
            workContext.TransactionaStorage = TransactionalStorage;
            workContext.IndexDefinitionStorage = IndexDefinitionStorage;


            try
            {
                InitializeTriggers();
                ExecuteStartupTasks();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            if (!newDb)
                return;

            OnNewlyCreatedDatabase();
        }
Ejemplo n.º 5
0
        public DocumentDatabase(InMemroyRavenConfiguration configuration)
        {
            Configuration = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext
            {
            	IndexUpdateTriggers = IndexUpdateTriggers,
				ReadTriggers = ReadTriggers
            };
            dynamicQueryRunner = new DynamicQueryRunner(this);

            TransactionalStorage = configuration.CreateTransactionalStorage(workContext.NotifyAboutWork);
            configuration.Container.SatisfyImportsOnce(TransactionalStorage);

            bool newDb;
            try
            {
                newDb = TransactionalStorage.Initialize();
            }
            catch (Exception)
            {
                TransactionalStorage.Dispose();
                throw;
            }

            IndexDefinitionStorage = new IndexDefinitionStorage(
                configuration,
                TransactionalStorage,
                configuration.DataDirectory,
                configuration.Container.GetExportedValues<AbstractViewGenerator>(),
                Extensions);
            IndexStorage = new IndexStorage(IndexDefinitionStorage, configuration);

            workContext.PerformanceCounters = new PerformanceCounters("Instance @ " + configuration.Port);
            workContext.IndexStorage = IndexStorage;
            workContext.TransactionaStorage = TransactionalStorage;
            workContext.IndexDefinitionStorage = IndexDefinitionStorage;


            try
            {
                InitializeTriggers();
                ExecuteStartupTasks();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            if (!newDb)
                return;

            OnNewlyCreatedDatabase();
        }
Ejemplo n.º 6
0
        public TransactionalStorage(InMemroyRavenConfiguration configuration, Action onCommit)
		{
			database = configuration.DataDirectory;
			this.configuration = configuration;
			this.onCommit = onCommit;
			path = database;
			if (Path.IsPathRooted(database) == false)
				path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
			database = Path.Combine(path, "Data");

			new TransactionalStorageConfigurator(configuration).LimitSystemCache();

			Api.JetCreateInstance(out instance, database + Guid.NewGuid());
		}
Ejemplo n.º 7
0
        public IndexStorage(IndexDefinitionStorage indexDefinitionStorage, InMemroyRavenConfiguration configuration)
		{
		    this.configuration = configuration;
		    path = Path.Combine(configuration.DataDirectory, "Indexes");

            if (Directory.Exists(path) == false && configuration.RunInMemory == false)
		        Directory.CreateDirectory(path);

		    foreach (var indexDirectory in indexDefinitionStorage.IndexNames)
		    {
		        log.DebugFormat("Loading saved index {0}", indexDirectory);

		        var indexDefinition = indexDefinitionStorage.GetIndexDefinition(indexDirectory);
		        if (indexDefinition == null)
		            continue;
		        indexes.TryAdd(indexDirectory,
		                       CreateIndexImplementation(indexDirectory, indexDefinition,
		                                                 OpenOrCreateLuceneDirectory(indexDirectory)));
		    }
		}
Ejemplo n.º 8
0
		public IndexDefinitionStorage(
            InMemroyRavenConfiguration configuration,
			ITransactionalStorage  transactionalStorage,
			string path, 
			IEnumerable<AbstractViewGenerator> compiledGenerators, 
			AbstractDynamicCompilationExtension[] extensions)
		{
		    this.configuration = configuration;
		    this.extensions = extensions;// this is used later in the ctor, so it must appears first
			this.path = Path.Combine(path, IndexDefDir);

			if (Directory.Exists(this.path) == false && configuration.RunInMemory == false)
				Directory.CreateDirectory(this.path);

            this.extensions = extensions;

            if (configuration.RunInMemory == false)
                ReadIndexesFromDisk();

            //compiled view generators always overwrite dynamic views
		    ReadIndexesFromCatalog(compiledGenerators, transactionalStorage);
		}
Ejemplo n.º 9
0
 public TransactionalStorage(InMemroyRavenConfiguration configuration, Action onCommit)
 {
     this.configuration = configuration;
     this.onCommit = onCommit;
 }
        public TransactionalStorageConfigurator(InMemroyRavenConfiguration configuration)
		{
			this.configuration = configuration;
		}