当前位置: 首页>>代码示例>>C#>>正文


C# DocumentStore.GetReplicationInformerForDatabase方法代码示例

本文整理汇总了C#中Raven.Client.Document.DocumentStore.GetReplicationInformerForDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentStore.GetReplicationInformerForDatabase方法的具体用法?C# DocumentStore.GetReplicationInformerForDatabase怎么用?C# DocumentStore.GetReplicationInformerForDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Client.Document.DocumentStore的用法示例。


在下文中一共展示了DocumentStore.GetReplicationInformerForDatabase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanFailoverReplicationBetweenTwoMultiTenantDatabases

		public void CanFailoverReplicationBetweenTwoMultiTenantDatabases()
		{
			using (var store = new DocumentStore
			                   	{
			                   		DefaultDatabase = "FailoverTest",
			                   		Url = store1.Url,
			                   		Conventions =
			                   			{
			                   				FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
			                   			}
			                   	})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands)
					.Wait();

				using (var session = store.OpenSession())
				{
					session.Store(new Item());
					session.SaveChanges();
				}

				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");

				servers[0].Dispose();

				using (var session = store.OpenSession())
				{
					var load = session.Load<Item>("items/1");
					Assert.NotNull(load);
				}
			}
		}
开发者ID:denno-secqtinstien,项目名称:ravendb,代码行数:34,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs

示例2: CanReplicateBetweenTwoMultiTenantDatabases

		public void CanReplicateBetweenTwoMultiTenantDatabases()
		{
			var store1 = CreateStore();
			var store2 = CreateStore();

			store1.DatabaseCommands.EnsureDatabaseExists("FailoverTest");
			store2.DatabaseCommands.EnsureDatabaseExists("FailoverTest");

			SetupReplication(store1.DatabaseCommands.ForDatabase("FailoverTest"),
			                 store2.Url + "/databases/FailoverTest");

			using (var store = new DocumentStore
			                   	{
			                   		DefaultDatabase = "FailoverTest",
			                   		Url = store1.Url,
			                   		Conventions =
			                   			{
			                   				FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
			                   			}
			                   	})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands)
					.Wait();

				using (var session = store.OpenSession())
				{
					session.Store(new Item {});
					session.SaveChanges();
				}

				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");
			}
		}
开发者ID:csainty,项目名称:ravendb,代码行数:35,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs

示例3: CanReplicateBetweenTwoMultiTenantDatabases

		public void CanReplicateBetweenTwoMultiTenantDatabases()
		{
			using (var store = new DocumentStore
			                   	{
			                   		DefaultDatabase = "FailoverTest",
			                   		Url = store1.Url,
			                   		Conventions =
			                   			{
			                   				FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
			                   			}
			                   	})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
				var databaseCommands = (ServerClient) store.DatabaseCommands;
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded(databaseCommands)
					.Wait();

				var replicationDestinations = replicationInformerForDatabase.ReplicationDestinationsUrls;
				
				Assert.NotEmpty(replicationDestinations);

				using (var session = store.OpenSession())
				{
					session.Store(new Item());
					session.SaveChanges();
				}

				var sanityCheck = store.DatabaseCommands.Head("items/1");
				Assert.NotNull(sanityCheck);

				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");
			}
		}
开发者ID:denno-secqtinstien,项目名称:ravendb,代码行数:34,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs

示例4: When_replicating_can_do_read_striping

		public void When_replicating_can_do_read_striping()
		{
			var store1 = CreateStore();
			var store2 = CreateStore();
			var store3 = CreateStore();

			using (var session = store1.OpenSession())
			{
				session.Store(new Company());
				session.SaveChanges();
			}

            SetupReplication(store1.DatabaseCommands, store2, store3);

			WaitForDocument(store2.DatabaseCommands, "companies/1");
			WaitForDocument(store3.DatabaseCommands, "companies/1");

            PauseReplicationAsync(0, store1.DefaultDatabase).Wait();
            PauseReplicationAsync(1, store2.DefaultDatabase).Wait();
            PauseReplicationAsync(2, store3.DefaultDatabase).Wait();

			using(var store = new DocumentStore
			{
				Url = store1.Url,
				Conventions =
					{
						FailoverBehavior = FailoverBehavior.ReadFromAllServers
					},
                    DefaultDatabase = store1.DefaultDatabase
			})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase();
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((AsyncServerClient)store.AsyncDatabaseCommands)
					.Wait();
				Assert.Equal(2, replicationInformerForDatabase.ReplicationDestinationsUrls.Count);

				foreach (var ravenDbServer in servers)
				{
					ravenDbServer.Server.ResetNumberOfRequests();
				}

				for (int i = 0; i < 6; i++)
				{
					using(var session = store.OpenSession())
					{
						Assert.NotNull(session.Load<Company>("companies/1"));
					}
				}
			}
			foreach (var ravenDbServer in servers)
			{
				Assert.Equal(2, ravenDbServer.Server.NumberOfRequests);
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:55,代码来源:ReadStriping.cs

示例5: When_replicating_can_do_read_striping

		public async Task When_replicating_can_do_read_striping()
		{
			var store1 = CreateStore();
            var store2 = CreateStore();
            var store3 = CreateStore();

			using (var session = store1.OpenAsyncSession())
			{
				await session.StoreAsync(new Company());
				await session.SaveChangesAsync();
			}

			SetupReplication(store1.DatabaseCommands, store2, store3);

			WaitForDocument(store2.DatabaseCommands, "companies/1");
			WaitForDocument(store3.DatabaseCommands, "companies/1");

		    await PauseReplicationAsync(0, store1.DefaultDatabase);
            await PauseReplicationAsync(1, store2.DefaultDatabase);
            await PauseReplicationAsync(2, store3.DefaultDatabase);

		    using(var store = new DocumentStore
			{
				Url = store1.Url,
				Conventions =
					{
						FailoverBehavior = FailoverBehavior.ReadFromAllServers
					},
                    DefaultDatabase = store1.DefaultDatabase
			})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase();
				await replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((AsyncServerClient)store.AsyncDatabaseCommands);
				Assert.Equal(2, replicationInformerForDatabase.ReplicationDestinationsUrls.Count);

				foreach (var ravenDbServer in servers)
				{
					ravenDbServer.Server.ResetNumberOfRequests();
                    Assert.Equal(0, ravenDbServer.Server.NumberOfRequests);
				}

				for (int i = 0; i < 6; i++)
				{
					using(var session = store.OpenAsyncSession())
					{
						Assert.NotNull(await session.LoadAsync<Company>("companies/1"));
					}
				}
			}
			foreach (var ravenDbServer in servers)
			{
                Assert.True(2 == ravenDbServer.Server.NumberOfRequests, string.Format("Server at port: {0}. Requests: #{1}", ravenDbServer.SystemDatabase.Configuration.Port, ravenDbServer.Server.NumberOfRequests));
			}
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:55,代码来源:AsyncReadStriping.cs

示例6: Main

		public static void Main(string[] args)
		{
			var store1 = new DocumentStore
							 {
								 Url = Url1,
								 Conventions =
									 {
										 FailoverBehavior = FailoverBehavior.ReadFromAllServers
									 }
							 };

			var store2 = new DocumentStore
							 {
								 Url = Url2
							 };

			store1.Initialize();
			store2.Initialize();

			CreateDatabase(store1, DatabaseName);
			Console.WriteLine("Created {0} database on {1}.", DatabaseName, store1.Url);
			CreateDatabase(store2, DatabaseName);
			Console.WriteLine("Created {0} database on {1}.", DatabaseName, store2.Url);

			CreateReplication(store1, DatabaseName, Url2, DatabaseName);
			Console.WriteLine("Created Replication document on {0}.", store1.Url);

			var replicationInformerForDatabase = store1.GetReplicationInformerForDatabase(DatabaseName);
			replicationInformerForDatabase.RefreshReplicationInformation((ServerClient)store1.DatabaseCommands.ForDatabase(DatabaseName));

			using (var session = store1.OpenSession(DatabaseName))
			{
				session.Store(new User { Name = "Ayende" }, "users/ayende");
				session.SaveChanges();
			}

			WaitForDocument(store2.DatabaseCommands.ForDatabase(DatabaseName), "users/ayende");

			Console.WriteLine("Document users/ayende successfully replicated to {0}, ready for {1} server failure.", store2.Url, store1.Url);
			Console.WriteLine("Press any key to continue...");
			Console.ReadLine();

			for (int i = 0; i < 12; i++)
			{
				using (var session = store1.OpenSession(DatabaseName))
				{
					session.Load<User>("users/ayende");
				}
			}

			store1.Dispose();
			store2.Dispose();
		}
开发者ID:AleksanderGondek,项目名称:GUT_IronTester,代码行数:53,代码来源:Program.cs

示例7: CanFailoverReplicationBetweenTwoMultiTenantDatabases

		public async Task CanFailoverReplicationBetweenTwoMultiTenantDatabases()
		{
			var store1 = CreateStore();
			var store2 = CreateStore();

			store1.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("FailoverTest");
			store2.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("FailoverTest");

			SetupReplication(store1.DatabaseCommands.ForDatabase("FailoverTest"),
			                 store2.Url + "/databases/FailoverTest");

			using (var store = new DocumentStore
			                   	{
			                   		DefaultDatabase = "FailoverTest",
			                   		Url = store1.Url,
			                   		Conventions =
			                   			{
			                   				FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
			                   			}
			                   	})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
				await replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands);

				using (var session = store.OpenAsyncSession())
				{
					await session.StoreAsync(new Item {});
					await session.SaveChangesAsync();
				}


				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");

				servers[0].Dispose();

				using (var session = store.OpenAsyncSession())
				{
					var load = await session.LoadAsync<Item>("items/1");
					Assert.NotNull(load);
				}
			}
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:43,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs

示例8: Can_avoid_read_striping

		public void Can_avoid_read_striping()
		{
			var store1 = CreateStore();
			var store2 = CreateStore();
			var store3 = CreateStore();

			using (var session = store1.OpenAsyncSession())
			{
				session.Store(new Company());
				session.SaveChangesAsync().Wait();
			}

			SetupReplication(store1.DatabaseCommands, store2.Url, store3.Url);

			WaitForDocument(store2.DatabaseCommands, "companies/1");
			WaitForDocument(store3.DatabaseCommands, "companies/1");

			using (var store = new DocumentStore
			{
				Url = store1.Url,
				Conventions =
				{
					FailoverBehavior = FailoverBehavior.ReadFromAllServers
				}
			})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase();
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient)store.DatabaseCommands)
					.Wait();
				Assert.Equal(2, replicationInformerForDatabase.ReplicationDestinations.Count);

				foreach (var ravenDbServer in servers)
				{
					ravenDbServer.Server.ResetNumberOfRequests();
				}

				for (int i = 0; i < 6; i++)
				{
					using (var session = store.OpenAsyncSession(new OpenSessionOptions
					{
						ForceReadFromMaster = true
					}))
					{
						Assert.NotNull(session.LoadAsync<Company>("companies/1").Result);
					}
				}
			}
			Assert.Equal(6, servers[0].Server.NumberOfRequests);
			Assert.Equal(0, servers[1].Server.NumberOfRequests);
			Assert.Equal(0, servers[2].Server.NumberOfRequests);
		}
开发者ID:royra,项目名称:ravendb,代码行数:52,代码来源:ReadStriping.cs

示例9: ClientShouldGetInformationFromSecondaryServerThatItsPrimaryServerMightBeUp

		public async Task ClientShouldGetInformationFromSecondaryServerThatItsPrimaryServerMightBeUp()
		{
			var db1Url = store1.Url + "/databases/Northwind";
			var db2Url = store2.Url + "/databases/Northwind";

			SetupReplication(store1.DatabaseCommands, db2Url);

			using (var store = new DocumentStore
			{
				DefaultDatabase = "Northwind",
				Url = store1.Url,
				Conventions =
				{
					FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
				}
			})
			{

				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase("Northwind");
			    replicationInformerForDatabase.DelayTimeInMiliSec = 0;
				await replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands);

				Assert.NotEmpty(replicationInformerForDatabase.ReplicationDestinations);

				using (var session = store.OpenSession())
				{
					session.Store(new Item());
					session.SaveChanges();
				}

				WaitForDocument(store2.DatabaseCommands, "items/1");

				Assert.Equal(0, replicationInformerForDatabase.GetFailureCount(db1Url));

				StopServer(server1);

				// Fail few times so we will be sure that client does not try its primary url
				for (int i = 0; i < 2; i++)
				{
					Assert.NotNull(store.DatabaseCommands.Get("items/1"));
				}

				Assert.True(replicationInformerForDatabase.GetFailureCount(db1Url) > 0);

				var replicationTask = (await server2.Server.GetDatabaseInternal("Northwind")).StartupTasks.OfType<ReplicationTask>().First();
				replicationTask.Heartbeats.Clear();

				server1 = CreateServer(8001, server1DataDir);

				Assert.NotNull(store1.DatabaseCommands.Get("items/1"));

				while (true)
				{
					var name = db1Url.Replace("localhost", Environment.MachineName.ToLowerInvariant())
					                 .Replace(".fiddler", "");
					DateTime time;
					if (replicationTask.Heartbeats.TryGetValue(name, out time))
					{
						break;
					}
					Thread.Sleep(100);
				}

				Assert.True(replicationInformerForDatabase.GetFailureCount(db1Url) > 0);
				
				Assert.NotNull(store.DatabaseCommands.Get("items/1"));

				Assert.True(replicationInformerForDatabase.GetFailureCount(db1Url) > 0);

				Assert.NotNull(store.DatabaseCommands.Get("items/1"));

				Assert.Equal(0, replicationInformerForDatabase.GetFailureCount(db1Url));
			}
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:75,代码来源:RavenDB_560.cs

示例10: ClientShouldGetInformationFromSecondaryServerThatItsPrimaryServerMightBeUp

		public void ClientShouldGetInformationFromSecondaryServerThatItsPrimaryServerMightBeUp()
		{
			server1 = CreateServer(8111, "D1");
			server2 = CreateServer(8112, "D2");

			store1 = new DocumentStore
			{
				DefaultDatabase = "Northwind1",
				Url = server1.Database.ServerUrl
			};

			store1.Initialize();

			store2 = new DocumentStore
			{
				DefaultDatabase = "Northwind2",
				Url = server2.Database.ServerUrl
			};
			store2.Initialize();

			store1.DatabaseCommands.CreateDatabase(
				new DatabaseDocument
				{
					Id = "Northwind1",
					Settings = {{"Raven/ActiveBundles", "replication"}, {"Raven/DataDir", @"~\D1\N"}}
				});

			store2.DatabaseCommands.CreateDatabase(
				new DatabaseDocument
				{
					Id = "Northwind2",
					Settings = {{"Raven/ActiveBundles", "replication"}, {"Raven/DataDir", @"~\D2\N"}}
				});

			var db1Url = store1.Url + "/databases/Northwind1";
			var db2Url = store2.Url + "/databases/Northwind2";

			SetupReplication(store1.DatabaseCommands, db2Url);

			using (var store = new DocumentStore
			{
				DefaultDatabase = "Northwind1",
				Url = store1.Url,
				Conventions =
				{
					FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
				}
			})
			{

				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase("Northwind1");
				replicationInformerForDatabase
					.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands)
					.Wait();

				Assert.NotEmpty(replicationInformerForDatabase.ReplicationDestinations);

				using (var session = store.OpenSession())
				{
					session.Store(new Item());
					session.SaveChanges();
				}

				WaitForDocument(store2.DatabaseCommands, "items/1");

				Assert.Equal(0, replicationInformerForDatabase.GetFailureCount(db1Url));

				StopServer(server1);

				// Fail few times so we will be sure that client does not try its primary url
				for (int i = 0; i < 2; i++)
				{
					Assert.NotNull(store.DatabaseCommands.Get("items/1"));
				}

				Assert.True(replicationInformerForDatabase.GetFailureCount(db1Url) > 0);

				var replicationTask =
					server2.Server.GetDatabaseInternal("Northwind2").Result.StartupTasks.OfType<ReplicationTask>().First();
				replicationTask.Heartbeats.Clear();

				server1 = StartServer(server1);

				Assert.NotNull(store1.DatabaseCommands.Get("items/1"));


				while (true)
				{
					DateTime time;
					if (replicationTask.Heartbeats.TryGetValue(db1Url.Replace("localhost", Environment.MachineName.ToLowerInvariant()), out time))
					{
						break;
					}
					Thread.Sleep(100);
				}

				Assert.True(replicationInformerForDatabase.GetFailureCount(db1Url) > 0);
				
				Assert.NotNull(store.DatabaseCommands.Get("items/1"));
//.........这里部分代码省略.........
开发者ID:jon-adams,项目名称:ravendb,代码行数:101,代码来源:RavenDB_560.cs

示例11: CanFailoverReplicationBetweenTwoMultiTenantDatabases_WithExplicitUrl

		public void CanFailoverReplicationBetweenTwoMultiTenantDatabases_WithExplicitUrl()
		{
			var store1 = CreateStore();
			var store2 = CreateStore();

			store1.DatabaseCommands.EnsureDatabaseExists("FailoverTest");
			store2.DatabaseCommands.EnsureDatabaseExists("FailoverTest");

			SetupReplication(store1.DatabaseCommands.ForDatabase("FailoverTest"),
			                 store2.Url + "databases/FailoverTest");

			using (var store = new DocumentStore
								{
									DefaultDatabase = "FailoverTest",
									Url = store1.Url + "databases/FailoverTest",
									Conventions =
										{
											FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
										}
								})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase("FailoverTest");
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands)
					.Wait();

				using (var session = store.OpenSession())
				{
					session.Store(new Item {});
					session.SaveChanges();
				}

				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");

				servers[0].Dispose();

				while (true)
				{
					try
					{
						using (var session = store.OpenSession())
						{
							var load = session.Load<Item>("items/1");
							Assert.NotNull(load);
						}
						return;
					}
					catch (Exception)
					{
						Debugger.Launch();
					}
				}
			}
		}
开发者ID:DBCooper2012,项目名称:ravendb,代码行数:54,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs


注:本文中的Raven.Client.Document.DocumentStore.GetReplicationInformerForDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。