Exemple #1
0
 public BaseShardedDocumentSession(ShardedDocumentStore documentStore, DocumentSessionListeners listeners, Guid id,
                                   ShardStrategy shardStrategy, IDictionary <string, TDatabaseCommands> shardDbCommands)
     : base(documentStore, listeners, id)
 {
     this.shardStrategy   = shardStrategy;
     this.shardDbCommands = shardDbCommands;
 }
 public EmbeddableDocumentStore()
 {
     Conventions   = new DocumentConvention();
     Listeners     = new DocumentSessionListeners();
     Configuration = new RavenConfiguration();
     EnlistInDistributedTransactions = true;
 }
Exemple #3
0
 public AsyncShardedDocumentSession(ShardedDocumentStore documentStore, DocumentSessionListeners listeners, Guid id,
                                    ShardStrategy shardStrategy, IDictionary <string, IAsyncDatabaseCommands> shardDbCommands)
     : base(documentStore, listeners, id, shardStrategy, shardDbCommands)
 {
     GenerateDocumentKeysOnStore = false;
     asyncDocumentKeyGeneration  = new AsyncDocumentKeyGeneration(this, entitiesAndMetadata.TryGetValue, ModifyObjectId);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncDocumentSession"/> class.
 /// </summary>
 public AsyncDocumentSession(DocumentStore documentStore,
                             IAsyncDatabaseCommands asyncDatabaseCommands,
                             DocumentSessionListeners listeners,
                             Guid id)
     : base(documentStore, listeners, id)
 {
     AsyncDatabaseCommands = asyncDatabaseCommands;
 }
Exemple #5
0
        public EmbeddableDocumentStore()
        {
            Conventions   = new DocumentConvention();
            Listeners     = new DocumentSessionListeners();
            Configuration = new AppSettingsBasedConfiguration();
            LegacyDataDirSupport(Configuration);

            EnlistInDistributedTransactions = true;
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncDocumentSession"/> class.
 /// </summary>
 public AsyncDocumentSession(string dbName, DocumentStore documentStore,
                             IAsyncDatabaseCommands asyncDatabaseCommands,
                             DocumentSessionListeners listeners,
                             Guid id)
     : base(dbName, documentStore, listeners, id)
 {
     AsyncDatabaseCommands       = asyncDatabaseCommands;
     GenerateDocumentKeysOnStore = false;
     asyncDocumentKeyGeneration  = new AsyncDocumentKeyGeneration(this, entitiesAndMetadata.TryGetValue, (key, entity, metadata) => key);
 }
Exemple #7
0
 public void SetListeners(DocumentSessionListeners listeners)
 {
     server.DocumentStore.SetListeners(listeners);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShardedDocumentSession"/> class.
 /// </summary>
 /// <param name="shardStrategy">The shard strategy.</param>
 /// <param name="shardDbCommands">The shard IDatabaseCommands.</param>
 /// <param name="id"></param>
 /// <param name="documentStore"></param>
 /// <param name="listeners"></param>
 public ShardedDocumentSession(string dbName, ShardedDocumentStore documentStore, DocumentSessionListeners listeners, Guid id,
                               ShardStrategy shardStrategy, IDictionary <string, IDatabaseCommands> shardDbCommands)
     : base(dbName, documentStore, listeners, id, shardStrategy, shardDbCommands)
 {
 }
Exemple #9
0
 public void SetListeners(DocumentSessionListeners listeners)
 {
     _docStore.SetListeners(listeners);
 }
Exemple #10
0
 public void SetListeners(DocumentSessionListeners newListeners)
 {
     listeners = newListeners;
 }
Exemple #11
0
 public void SetListeners(DocumentSessionListeners listeners)
 {
     this.Listeners = listeners;
 }
Exemple #12
0
        public IDocumentStore Create()
        {
            var store = new EmbeddableDocumentStore
            {
                RunInMemory     = true,
                DefaultDatabase = "topcat"
            };

            var dsl = new DocumentSessionListeners
            {
                QueryListeners = new IDocumentQueryListener[] { new NoStaleQueriesListener() }
            };

            store.SetListeners(dsl);

            // activate versioning bundle
            store.Configuration.Settings.Add("Raven/ActiveBundles", "Versioning");

            if (PreInitializationAction != null)
            {
                PreInitializationAction(store);
            }

            store.Initialize();

            // configure versioning bundle
            using (var db = store.OpenSession())
            {
                db.Store(new VersioningConfiguration
                {
                    Exclude      = false,
                    Id           = "Raven/Versioning/DefaultConfiguration",
                    MaxRevisions = 50
                });

                // apparently we need to configure versioning explicity per document type when running in-memory
                db.Store(new VersioningConfiguration
                {
                    Exclude      = false,
                    Id           = "Raven/Versioning/Records",
                    MaxRevisions = int.MaxValue
                });

                db.SaveChanges();
            }

            // guid keys are problematic for raven's document versioning bundle
            // because the key string now contains the normal key plus the version so
            // we have to sneak a hack during the hydration of a Record object
            // https://groups.google.com/d/msg/ravendb/iawGaXdzwZA/ty8n2-ylHFsJ
            store.Conventions.FindIdValuePartForValueTypeConversion = (entity, id) =>
            {
                var parts = id.Split('/');
                var guid  = parts[1];

                if (entity is Record && parts.Length == 4)
                {
                    ((Record)entity).Revision = int.Parse(parts[3]);
                }

                return(guid);
            };

            if (PostInitializationAction != null)
            {
                PostInitializationAction(store);
            }

            IndexCreation.CreateIndexes(typeof(Record).Assembly, store);
            RavenUtility.WaitForIndexing(store);

            // todo: is it possible to make the database read-only to prevent accidental mutation of test data?
            return(store);
        }
Exemple #13
0
 public ChunkedBulkInsertOperation(string database, IDocumentStore documentStore, DocumentSessionListeners listeners, BulkInsertOptions options, IDatabaseChanges changes, int chunkSize, long?documentSizeInChunkLimit = null)
     : base(database, documentStore, listeners, options, changes)
 {
     Operation = new ChunkedRemoteBulkInsertOperation(options, (AsyncServerClient)DatabaseCommands, changes, chunkSize, documentSizeInChunkLimit);
 }