public void SetUp() { _store = NewDocumentStore(); _store.Initialize(); // We first have to create the static indexes IndexCreation.CreateIndexes(typeof(Player_Index_R03).Assembly, _store); _teams = DataGenerator.CreateTeamList(); // Store some players and teams in the database using (var session = _store.OpenSession()) { foreach (var team in _teams) { session.Store(team); } _players = DataGenerator.CreatePlayerListWithTeamIds(); foreach (var player in _players) { session.Store(player); } session.SaveChanges(); } // Let's wait for indexing to happen // this method is part of RavenTestBase and thus should only be used in tests WaitForIndexing(_store); }
public static void CreateSeedData(IDocumentStore documentStore) { Condition.Requires(documentStore).IsNotNull(); using (IDocumentSession documentSession = documentStore.OpenSession()) { // First, check to make sure we don't have any data. var user = documentSession.Load<User>(1); if (user != null) { // ooOooo! we have a user, so it's assumed we actually have some seeded data. return; } // We have no users, so it's assumed we therefore have no data at all. // So lets fake some up :) // Users. ICollection<User> users = FakeUsers.CreateFakeUsers(50); StoreFakeEntities(users, documentSession); // Questions. ICollection<Question> questions = FakeQuestions.CreateFakeQuestions(users.Select(x => x.Id).ToList()); StoreFakeEntities(questions, documentSession); documentSession.SaveChanges(); // Make sure all our indexes are not stale. documentStore.WaitForStaleIndexesToComplete(); } }
public RavenDbServiceOptions(string conStringName) { _store = new DocumentStore {ConnectionStringName = conStringName}; _store.Initialize(); IndexCreation.CreateIndexes(GetType().Assembly, _store); }
private static void SetupFacets( String id, IDocumentStore store ) { var facet = new FacetSetup() { Id = id, Facets = { new Facet<Orders.Product>() { Name = p=>p.Supplier }, new Facet<Orders.Product>() { Name = p=>p.PricePerUser, Ranges = { p=>p.PricePerUser <= 50, p=>p.PricePerUser > 50 && p.PricePerUser <= 100, p=>p.PricePerUser > 100 && p.PricePerUser <= 200, p=>p.PricePerUser > 200, } }, } }; using ( var session = store.OpenSession() ) { session.Store( facet ); session.SaveChanges(); } }
/// <summary> /// Registers the document store. /// </summary> /// <param name="documentStore">The document store.</param> public static void RegisterDocumentStore(IDocumentStore documentStore) { SessionFactory.DocumentStoreInstance = documentStore; documentStore.Conventions.CustomizeJsonSerializer += json => json.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; // register custom contract resolver to handle relations documentStore.Conventions.JsonContractResolver = new RelationContractResolver( (DefaultRavenContractResolver)documentStore.Conventions.JsonContractResolver, documentStore.Conventions, ListOfModelTypes()); var componentInstances = IoC.ResolveAllInstances<IComponentDbInit>().ToArray(); // customize document store foreach (var componentDbInit in componentInstances) { componentDbInit.CustomizeDocumentStore(documentStore); } // register indexes foreach (var componentDbInit in componentInstances) { componentDbInit.RegisterIndexes(documentStore); } }
private UserWithGuid[] GetUsers(IDocumentStore documentStore) { using (var session = documentStore.QuerySession()) { return session.Query<UserWithGuid>().ToArray(); } }
public IdentityMapThinksIdsAreGlobal() { documentStore = Using(DocumentStore.ForTesting(TableMode.UseTempTables, connectionString)); documentStore.Configuration.Document<Doc1>().Key(x => x.Id); documentStore.Configuration.Document<Doc2>().Key(x => x.Id); documentStore.Initialize(); }
public RavenDbSessionStore(CryptographyConfiguration cryptographyConfiguration, IDocumentStore documentStore) : base(cryptographyConfiguration) { Guard.NotNull(() => documentStore, documentStore); this.documentStore = documentStore; }
private void ExecuteTest(IDocumentStore store) { CreateIndexAndSampleData(store); // there are 10K documents, each combination of "Lorem" and "Nullam" has 100 matching documents. // Suspect that this may be failing because each individual slice (Lorem: L and Nullam: N) // has 1000 documents, which is greater than default page size of 128. foreach (string L in Lorem) { foreach (string N in Nullam) { using (var session = store.OpenSession()) { var result = session.Query<TestAttributes>("TestAttributesByAttributes") .Where(o => o.Attributes.Any(t => t.Key == "Lorem" && t.Value == L)) .OrderBy(o => o.Id) .Intersect() .Where(o => o.Attributes.Any(t => t.Key == "Nullam" && t.Value == N)) .ToList(); Assert.Equal(100, result.Count); } } } }
public RavenDocStore() { _documentStore = new DocumentStore { Url = "http://localhost:8080", ResourceManagerId = Guid.NewGuid() }; _documentStore.Initialize(); _documentStore.DatabaseCommands.EnsureDatabaseExists("Configuration"); IndexCreation.CreateIndexes(typeof(ScheduleMessagesInCoordinatorIndex).Assembly, _documentStore); }
/// <summary> /// Initializes the RavenProfiler for MVC. /// IMPORTANT! This method may only be called from the Application_Start method, otherwise /// it might lead to problems, since it modify the Routes table. /// </summary> public static void InitializeFor(IDocumentStore store, params string[] fieldsToFilter) { var existing = RouteTable.Routes .Select(x => { var route = x as Route; if (route == null) return null; return route.RouteHandler; }) .OfType<RavenProfilingHandler>() .FirstOrDefault(); if (existing != null) { existing.AddStore(store); return; } store.Conventions.DisableProfiling = false; ((DocumentStore)store).InitializeProfiling(); ProfilingInformation.OnContextCreated += ProfilingInformationOnOnContextCreated; var ravenProfilingHandler = new RavenProfilingHandler(new HashSet<string>(fieldsToFilter ?? Enumerable.Empty<string>())); ravenProfilingHandler.AddStore(store); RouteTable.Routes.Insert(0, new Route("ravendb/profiling", new RouteValueDictionary(new { controller = "RavenProfilingHandler", action = "ProcessRequest" }), ravenProfilingHandler)); GlobalFilters.Filters.Add(new RecordCurrentControllerContextFilter(), -100); }
//Change to allow for Multi- Tenancy cases //User has to call this method every time he creates a new tenant DB public static void CreateOrUpdateUserAuthIndex(IDocumentStore store,string databaseName) { // put this index into the ravendb database var catalog = new CompositionContainer(new AssemblyCatalog(typeof(ServiceStack_UserAuth_ByUserNameOrEmail).Assembly)); IndexCreation.CreateIndexes(catalog, store.DatabaseCommands.ForDatabase(databaseName), store.Conventions); _isInitialized = true; }
public RavenMembershipRebootDatabase(string connectionStringName) { DocumentStore = new DocumentStore { ConnectionStringName = connectionStringName }.Initialize(); }
public static void ExecuteIndexes(IDocumentStore store) { new OrdersByCompany().Execute(store); new OrdersTotals().Execute(store); new ProductSales().Execute(store); new OrderLines_ByProduct().Execute(store); }
public static void CreateOrUpdateUserAuthIndex(IDocumentStore store) { // put this index into the ravendb database new ServiceStack_UserAuth_ByUserNameOrEmail().Execute(store); new ServiceStack_UserAuth_ByOAuthProvider().Execute(store); _isInitialized = true; }
private void DoTest(IDocumentStore store1, IDocumentStore store2) { using (var session = store1.OpenSession()) { session.Store(new Company()); session.SaveChanges(); } using (var session = store2.OpenSession()) { session.Store(new Company()); session.SaveChanges(); } store1.DatabaseCommands.Put("marker", null, new RavenJObject(), new RavenJObject()); TellFirstInstanceToReplicateToSecondInstance(); WaitForReplication(store2, "marker"); var conflictException = Assert.Throws<ConflictException>(() => { using (var session = store2.OpenSession()) { var loadStartingWith = session.Advanced.LoadStartingWith<Company>("companies/"); } }); Assert.Equal("Conflict detected on companies/1, conflict must be resolved before the document will be accessible", conflictException.Message); }
public static void CreateInitialData(IDocumentStore store, string databaseName) { store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(databaseName); using (var bulkInsert = store.BulkInsert()) { foreach (var category in DataFactory.Categories.GenerateMany(Constants.NumOfCategories)) bulkInsert.Store(category); foreach (var company in DataFactory.Companies.GenerateMany(Constants.NumOfCompanies)) bulkInsert.Store(company); foreach (var employee in DataFactory.Employees.GenerateMany(Constants.NumOfEmployees)) bulkInsert.Store(employee); foreach (var order in DataFactory.Orders.GenerateMany(Constants.NumOfOrders)) bulkInsert.Store(order); foreach (var product in DataFactory.Products.GenerateMany(Constants.NumOfProducts)) bulkInsert.Store(product); foreach (var region in DataFactory.Regions.GenerateMany(Constants.NumOfRegions)) bulkInsert.Store(region); foreach (var shipper in DataFactory.Shippers.GenerateMany(Constants.NumOfShippers)) bulkInsert.Store(shipper); foreach (var supplier in DataFactory.Suppliers.GenerateMany(Constants.NumOfSuppliers)) bulkInsert.Store(supplier); } new OrdersByCompany().Execute(store); new OrdersTotals().Execute(store); new ProductSales().Execute(store); new OrderLines_ByProduct().Execute(store); }
private void LoadDocs(IDocumentStore store) { using (var session = store.OpenSession()) { session.Load<Order>(orderIDs); } }
private static void CreateSections(IDocumentStore store) { Console.WriteLine("Creating sections"); using (IDocumentSession s = store.OpenSession()) { var sections = new[] { new Section {Title = "Future Posts", ControllerName = "Section", ActionName = "FuturePosts"}, new Section {Title = "Statistics", ControllerName = "Section", ActionName = "PostsStatistics"}, new Section {Title = "Tags", ControllerName = "Section", ActionName = "TagsList"}, new Section {Title = "Archive", ControllerName = "Section", ActionName = "ArchivesList"}, }; var i = 0; foreach (var section in sections) { section.Position = i; section.IsActive = true; s.Store(section); i++; } s.SaveChanges(); } Console.WriteLine("Finish creating sections"); }
public static IDocumentStore Initialize() { instance = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" }; instance.Conventions.IdentityPartsSeparator = "-"; instance.Initialize(); return instance; }
public QuestionsController(IDocumentStore documentStore, IQuestionService questionService) : base(documentStore) { Condition.Requires(questionService).IsNotNull(); _questionService = questionService; }
public HomeControllerTests() { _documentStore = new EmbeddableDocumentStore { RunInMemory = true } .Initialize(); _documentSession = _documentStore.OpenSession(); }
public override void Initialize(string name, NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); _providerName = name; base.Initialize(name, config); SetConfigurationProperties(config); if (_documentStore == null) { if (string.IsNullOrEmpty(config["connectionStringName"])) throw new ConfigurationErrorsException("Must supply a connectionStringName."); _documentStore = new DocumentStore { ConnectionStringName = config["connectionStringName"], }; _documentStore.Initialize(); } // create indexes _documentStore.ExecuteIndex(new Users_ByApplicationNameAndRoleName()); }
public void SetUp() { store = NewDocumentStore(); using(var session = store.OpenSession()) { session.Store(new Account { Transactions = { new Transaction(1), new Transaction(3), } }); session.Store(new Account { Transactions = { new Transaction(2), new Transaction(4), } }); session.SaveChanges(); } }
private static ServerSettings GetServerSettings(IDocumentStore documentStore) { using (var session = documentStore.OpenSession()) { return session.Load<ServerSettings>("ServerSettings/1"); } }
/// <summary> /// Initializes a new instance of the <see cref="HiLoKeyGenerator"/> class. /// </summary> /// <param name="documentStore">The document store.</param> /// <param name="tag">The tag.</param> /// <param name="capacity">The capacity.</param> public HiLoKeyGenerator(IDocumentStore documentStore, string tag, long capacity) { this.documentStore = documentStore; this.tag = tag; this.capacity = capacity; current = 0; }
public RavenDB_1033() { store = NewDocumentStore(settings: new Dictionary<string, string> { { "Raven/HttpCompression", "true" } // HttpCompression is enabled by default, just in case of changing it in the future }); }
public static IEnumerable<Func<CancellationToken, Task>> Tasks(ICommandSender service, IDocumentStore docs, bool isTest) { var flow = new DomainSender(service); // more tasks go here yield break; }
public static void WaitForIndexing(IDocumentStore store) { while (store.DatabaseCommands.GetStatistics().StaleIndexes.Length > 0) { Thread.Sleep(100); } }
public RavenDbErrorLog(IDictionary config) { if (string.IsNullOrWhiteSpace(_version)) { _version = RetrieveVersion(); } if (_externalProvidedDocumentStore != null) { _documentStore = _externalProvidedDocumentStore; } else { if (config == null) { throw new ArgumentNullException("config"); } _connectionStringName = GetConnectionStringName(config); LoadApplicationName(config); InitDocumentStore(); } ConfigureDocumentStore(_documentStore); }
private static async Task <ServerSupportedFeatures> DetectServerSupportedFeatures(IDocumentStore store) { var buildNumber = await store.AsyncDatabaseCommands.GlobalAdmin.GetBuildNumberAsync(); if (buildNumber == null || string.IsNullOrEmpty(buildNumber.ProductVersion)) { ShowProgress("Server version is not available. Running in legacy mode which does not support transformers, documents streaming and identities smuggling."); return(new ServerSupportedFeatures { IsTransformersSupported = false, IsDocsStreamingSupported = false, IsIdentitiesSmugglingSupported = false, }); } var smugglerVersion = FileVersionInfo.GetVersionInfo(AssemblyHelper.GetAssemblyLocationFor <SmugglerDatabaseApiBase>()).ProductVersion; var subSmugglerVersion = smugglerVersion.Substring(0, 3); var subServerVersion = buildNumber.ProductVersion.Substring(0, 3); var intServerVersion = int.Parse(subServerVersion.Replace(".", string.Empty)); if (intServerVersion < 25) { ShowProgress("Running in legacy mode, importing/exporting transformers and identities is not supported. Server version: {0}. Smuggler version: {1}.", subServerVersion, subSmugglerVersion); return(new ServerSupportedFeatures { IsTransformersSupported = false, IsDocsStreamingSupported = false, IsIdentitiesSmugglingSupported = false, }); } if (intServerVersion == 25) { ShowProgress("Running in legacy mode, importing/exporting identities is not supported. Server version: {0}. Smuggler version: {1}.", subServerVersion, subSmugglerVersion); return(new ServerSupportedFeatures { IsTransformersSupported = true, IsDocsStreamingSupported = true, IsIdentitiesSmugglingSupported = false, }); } return(new ServerSupportedFeatures { IsTransformersSupported = true, IsDocsStreamingSupported = true, IsIdentitiesSmugglingSupported = true, }); }
public ModelModelBinder(IDocumentStore documentStore) { _documentStore = documentStore; }
public NotificationController(IDocumentStore documentStore) { _documentStore = documentStore; }
private static void DoTest(IDocumentStore store) { new FooBarTransformer().Execute(store); using (var session = store.OpenSession()) { var bar1 = new Bar { Id = "bars/1", Name = "1" }; var bar2 = new Bar { Id = "bars/2", Name = "2" }; var foo1 = new Foo() { Id = "foos/1", Bars = new[] { bar1.Id, bar2.Id } }; var foo2 = new Foo() { Id = "foos/2", Name = "Foo_Two" }; session.Store(bar1); session.Store(bar2); session.Store(foo1); session.Store(foo2); session.SaveChanges(); var fooBars = session.Advanced.LoadStartingWith <FooBarTransformer, FooBarDto>("foos/", configure: x => x.AddQueryParam("input", "testParam")) .OrderBy(x => x.Name) .ToArray(); Assert.Equal(2, fooBars.Length); Assert.Null(fooBars[0].Name); Assert.Equal(2, fooBars[0].Bars.Length); Assert.Equal("1", fooBars[0].Bars[0]); Assert.Equal("2", fooBars[0].Bars[1]); Assert.Equal("testParam", fooBars[0].Input); Assert.Equal("Foo_Two", fooBars[1].Name); Assert.Equal(0, fooBars[1].Bars.Length); Assert.Equal("testParam", fooBars[1].Input); } using (var session = store.OpenAsyncSession()) { var fooBars = session.Advanced.LoadStartingWithAsync <FooBarTransformer, FooBarDto>("foos/", configure: x => x.AddQueryParam("input", "testParam")).Result .OrderBy(x => x.Name).ToArray(); Assert.Equal(2, fooBars.Length); Assert.Null(fooBars[0].Name); Assert.Equal(2, fooBars[0].Bars.Length); Assert.Equal("1", fooBars[0].Bars[0]); Assert.Equal("2", fooBars[0].Bars[1]); Assert.Equal("testParam", fooBars[0].Input); Assert.Equal("Foo_Two", fooBars[1].Name); Assert.Equal(0, fooBars[1].Bars.Length); Assert.Equal("testParam", fooBars[1].Input); } }
public MartenProvider(IDocumentStore store) { _store = store; }
// Take in IDocumentStore as a constructor argument public UsingDocumentSessionHandler(IDocumentStore store) { }
/// <summary> /// Configures the given document store to be used when storing subscriptions /// </summary> /// <param name="cfg"></param> /// <param name="documentStore">The document store to use</param> public static PersistenceExtensions <RavenDBPersistence> UseDocumentStoreForSubscriptions(this PersistenceExtensions <RavenDBPersistence> cfg, IDocumentStore documentStore) { DocumentStoreManager.SetDocumentStore <StorageType.Subscriptions>(cfg.GetSettings(), documentStore); return(cfg); }
public MessageFailureResolvedHandler(IDocumentStore store, IDomainEvents domainEvents) { this.store = store; this.domainEvents = domainEvents; }
public WireUpFailedMessageNotifications(FailedMessageViewIndexNotifications notifications, IDocumentStore store) { this.notifications = notifications; this.store = store; }
public static string CreateEntities(IDocumentStore documentStore) { const string questionId = @"question/259"; const string answerId = @"answer/540"; using (IDocumentSession session = documentStore.OpenSession()) { var user = new User { Id = @"user/222", DisplayName = "John Doe" }; session.Store(user); var question = new Question { Id = questionId, Title = "How to do this in RavenDb?", Content = "I'm trying to find how to model documents for better DDD support.", UserId = @"user/222" }; session.Store(question); var answer = new AnswerEntity { Id = answerId, Question = question, Content = "This is doable", UserId = user.Id }; session.Store(new Answer { Id = answer.Id, UserId = answer.UserId, QuestionId = answer.Question.Id, Content = answer.Content }); var vote1 = new AnswerVoteEntity { Id = "votes\\1", Answer = answer, QuestionId = questionId, Delta = 2 }; session.Store(new AnswerVote { QuestionId = vote1.QuestionId, AnswerId = vote1.Answer.Id, Delta = vote1.Delta }); var vote2 = new AnswerVoteEntity { Id = "votes\\2", Answer = answer, QuestionId = questionId, Delta = 3 }; session.Store(new AnswerVote { QuestionId = vote2.QuestionId, AnswerId = vote2.Answer.Id, Delta = vote2.Delta }); session.SaveChanges(); } return(answerId); }
public RavenUserAccountRepository(IDocumentStore documentStore) { this.documentStore = documentStore; documentSession = documentStore.OpenSession(); items = documentSession.Query <HierarchicalUserAccount>(); }
public TitleEpisodeRepository(IDocumentStore store) => _store = store;
protected override void SetupDatabase(IDocumentStore store) { using var session = store.OpenSession(); session.Store(TenantData.GetFirst()); session.SaveChanges(); }
private static IndexDefinition[] GetAutoIndexes(IDocumentStore store) { return(store.Maintenance.Send(new GetIndexesOperation(0, 1024)).Where(x => x.Name.StartsWith("Auto/")).ToArray()); }
private static void AssertIndexHasNoErrors(IDocumentStore store, string indexName) { Assert.Equal(0, store.Maintenance.Send(new GetIndexErrorsOperation(new[] { indexName }))[0].Errors.Length); }
public DocumentSubscriptions(IDocumentStore store) { _store = store; }
private AuthorizedSession(IDocumentStore store, IDocumentSession session, AuthorizedUser authorizedUser) { _store = store; _session = session; _authorizedUser = authorizedUser; }
public MultiTenantDocumentStore(IDocumentStore store) { _store = store; }
protected bool WaitForDocument(IDocumentStore store, string docId, int timeout = 10000) { return(WaitForDocument <dynamic>(store, docId, predicate: null, timeout: timeout)); }
/// <summary> /// Initializes a new instance of the <see cref="RavenMessageStore"/> class. /// </summary> /// <param name="documentStore">The document store.</param> /// <param name="logger">The logger.</param> public RavenMessageStore(IDocumentStore documentStore, ILog logger) { this.documentStore = documentStore; this.logger = logger; }
public AllProcessedMessagesRoutedMessageSource(IDocumentStore store) { _store = store; }
protected static DatabasePutResult CreateClusterDatabase(string databaseName, IDocumentStore store, int replicationFactor = 2) { return(store.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(databaseName), replicationFactor))); }
public TeamService(IDocumentStore documentStore, ILogger <TeamService> logger, PickemEventer pickemEventer) { _documentStore = documentStore; _logger = logger; _pickemEventer = pickemEventer; }
public void TestCleanup() { _documentStore = null; DocumentStoreHelper.KillRaven(); }
public MartenNodeDiscovery(MartenSubscriptionSettings settings) { _documentStore = settings.Store; }
protected override void SetupDatabase(IDocumentStore store) { store.ExecuteIndex(new FavIndex()); WaitForIndexing(store); }
public RavenFileStorageService(IDocumentStore documentStore) { this.documentStore = documentStore; }
public static IDocumentStore ApplyGeoConventions(this IDocumentStore store) { store.Conventions.JsonContractResolver = new GeoContractResolver(); store.Conventions.CustomizeJsonSerializer = x => x.Converters.Add(new CoordinateConverter()); return(store); }
public ReturnToSenderDequeuer(IBodyStorage bodyStorage, ISendMessages sender, IDocumentStore store, IDomainEvents domainEvents, Configure configure) { this.sender = sender; this.bodyStorage = bodyStorage; Action executeOnFailure = () => { if (IsCounting) { CountMessageAndStopIfReachedTarget(); } else { timer.Change(TimeSpan.FromSeconds(45), Timeout.InfiniteTimeSpan); } }; faultManager = new CaptureIfMessageSendingFails(store, domainEvents, executeOnFailure); timer = new Timer(state => StopInternal()); InputAddress = Address.Parse(configure.Settings.EndpointName()).SubScope("staging"); }
protected abstract Task <bool> execute(IDocumentStore store, T input);