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


C# SqlReplication.SqlReplicationConfig类代码示例

本文整理汇总了C#中Raven.Database.Bundles.SqlReplication.SqlReplicationConfig的典型用法代码示例。如果您正苦于以下问题:C# SqlReplicationConfig类的具体用法?C# SqlReplicationConfig怎么用?C# SqlReplicationConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlReplicationConfig类属于Raven.Database.Bundles.SqlReplication命名空间,在下文中一共展示了SqlReplicationConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlReplicationMetricsCountersManager

 public SqlReplicationMetricsCountersManager(Metrics dbMetrics, SqlReplicationConfig sqlReplicationConfig)
 {
     this.dbMetrics = dbMetrics;
     this.sqlReplicationConfig = sqlReplicationConfig;
     SqlReplicationBatchSizeMeter = dbMetrics.Meter("metrics", "SqlReplication Batch docs/min for " + sqlReplicationConfig.Name, "SQLReplication docs/min Counter", TimeUnit.Minutes);
     SqlReplicationBatchSizeHistogram = dbMetrics.Histogram("metrics", "SqlReplication Batch histogram for " + sqlReplicationConfig.Name);
     SqlReplicationDurationHistogram = dbMetrics.Histogram("metrics", "SQLReplication duration Histogram for " + sqlReplicationConfig.Name);
     TablesMetrics = new ConcurrentDictionary<string, SqlReplicationTableMetrics>();
 }
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:9,代码来源:SqlReplicationMetricsCountersManager.cs

示例2: SqlReplicationTableMetrics

            public SqlReplicationTableMetrics(string tableName, SqlReplicationConfig cfg, Metrics dbMetrics)
            {
                this.dbMetrics = dbMetrics;
                Config = cfg;
                TableName = tableName;

                deleteMeterName = "SqlReplication Deletes/min for table :" + TableName + " in replication: " + Config.Name;
                insertMeterName = "SqlReplication Inserts/min for table :" + TableName + " in replication: " + Config.Name;
            }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:9,代码来源:SqlReplicationMetricsCountersManager.cs

示例3: SqlReplicationScriptedJsonPatcher

		public SqlReplicationScriptedJsonPatcher(DocumentDatabase database,
		                                         ConversionScriptResult scriptResult,
												 SqlReplicationConfig config,
		                                         string docId)
			: base(database)
		{
			this.scriptResult = scriptResult;
			this.config = config;
			this.docId = docId;
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:10,代码来源:SqlReplicationScriptedJsonPatcher.cs

示例4: ElasticsearchReplicationConfig

 public ElasticsearchReplicationConfig(SqlReplicationConfig other)
 {
     this.ConnectionString = other.ConnectionString;
     this.FactoryName = other.FactoryName;
     this.Script = other.Script;
     this.Disabled = other.Disabled;
     this.Id = other.Id;
     this.Name = other.Name;
     this.RavenEntityName = other.RavenEntityName;
     this.SqlReplicationTables = other.SqlReplicationTables;
 }
开发者ID:synhershko,项目名称:RavenDB.ElasticsearchReplication,代码行数:11,代码来源:ElasticsearchReplicationConfig.cs

示例5: RelationalDatabaseWriterSimulator

        public RelationalDatabaseWriterSimulator( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
        {
            this.database = database;
            this.cfg = cfg;
            this.replicationStatistics = replicationStatistics;
            providerFactory = DbProviderFactories.GetFactory(cfg.FactoryName);
            commandBuilder = providerFactory.CreateCommandBuilder();
            if (SqlServerFactoryNames.Contains(cfg.FactoryName))
		    {
		        IsSqlServerFactoryType = true;
        }
        }
开发者ID:cocytus,项目名称:ravendb,代码行数:12,代码来源:RelationalDatabaseWriterSimulator.cs

示例6: SqlReplicationMetricsCountersManager

        public SqlReplicationMetricsCountersManager(Metrics dbMetrics, SqlReplicationConfig sqlReplicationConfig)
        {
            this.dbMetrics = dbMetrics;
            this.sqlReplicationConfig = sqlReplicationConfig;

            meterName = "SqlReplication Batch docs/min for " + sqlReplicationConfig.Name;
            SqlReplicationBatchSizeMeter = dbMetrics.Meter(MeterContext, meterName, "SQLReplication docs/min Counter", TimeUnit.Minutes);
            MetricsTicker.Instance.AddMeterMetric(SqlReplicationBatchSizeMeter);

            SqlReplicationBatchSizeHistogram = dbMetrics.Histogram("metrics", "SqlReplication Batch histogram for " + sqlReplicationConfig.Name);
            SqlReplicationDurationHistogram = dbMetrics.Histogram("metrics", "SQLReplication duration Histogram for " + sqlReplicationConfig.Name);
            TablesMetrics = new ConcurrentDictionary<string, SqlReplicationTableMetrics>();
            ReplicationPerformanceStats = new ConcurrentQueue<SqlReplicationPerformanceStats>();
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:14,代码来源:SqlReplicationMetricsCountersManager.cs

示例7: RelationalDatabaseWriter

		public RelationalDatabaseWriter( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
		{
			this.database = database;
			this.cfg = cfg;
			this.replicationStatistics = replicationStatistics;

			providerFactory = GetDbProviderFactory(cfg);

			commandBuilder = providerFactory.CreateCommandBuilder();
			connection = providerFactory.CreateConnection();

			Debug.Assert(connection != null);
			Debug.Assert(commandBuilder != null);

			connection.ConnectionString = cfg.ConnectionString;
            
		    if (SqlServerFactoryNames.Contains(cfg.FactoryName))
		    {
                IsSqlServerFactoryType = true;
		    }

			try
			{
				connection.Open();
			}
			catch (Exception e)
			{
				database.AddAlert(new Alert
				{
					AlertLevel = AlertLevel.Error,
					CreatedAt = SystemTime.UtcNow,
					Exception = e.ToString(),
					Title = "Sql Replication could not open connection",
					Message = "Sql Replication could not open connection to " + connection.ConnectionString,
					UniqueKey = "Sql Replication Connection Error: " + connection.ConnectionString
				});
				throw;
			}

			tx = connection.BeginTransaction();

            stringParserList = GenerateStringParsers();
            sqlReplicationMetrics = database.StartupTasks.OfType<SqlReplicationTask>().FirstOrDefault().GetSqlReplicationMetricsManager(cfg);
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:44,代码来源:RelationalDatabaseWriter.cs

示例8: SqlReplicationConfigWithLastReplicatedEtag

        public SqlReplicationConfigWithLastReplicatedEtag(SqlReplicationConfig config, Etag lastReplicatedEtag)
        {
            LastReplicatedEtag = lastReplicatedEtag;

            ConnectionString = config.ConnectionString;
            ConnectionStringName = config.ConnectionStringName;
            ConnectionStringSettingName = config.ConnectionStringSettingName;
            Disabled = config.Disabled;
            FactoryName = config.FactoryName;
            ForceSqlServerQueryRecompile = config.ForceSqlServerQueryRecompile;
            Id = config.Id;
            Name = config.Name;
            ParameterizeDeletesDisabled = config.ParameterizeDeletesDisabled;
            PredefinedConnectionStringSettingName = config.PredefinedConnectionStringSettingName;
            QuoteTables = config.QuoteTables;
            RavenEntityName = config.RavenEntityName;
            Script = config.Script;
            SqlReplicationTables = config.SqlReplicationTables;
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:19,代码来源:SqlReplicationConfig.cs

示例9: ElasticsearchDestinationWriter

        public ElasticsearchDestinationWriter(DocumentDatabase database, SqlReplicationConfig _cfg, SqlReplicationStatistics replicationStatistics)
		{
            var cfg = new ElasticsearchReplicationConfig(_cfg);

			this.database = database;
			this.cfg = cfg;
            this.targetIndexName = cfg.FactoryName.ToLowerInvariant(); // Elasticsearch requires all index names to be lowercased
			this.replicationStatistics = replicationStatistics;
            
            try
            {
                elasticsearchClient = cfg.GetElasticClient();
            }
            catch (UriFormatException e)
            {
                if (database != null)
                    database.AddAlert(new Alert
                    {
                        AlertLevel = AlertLevel.Error,
                        CreatedAt = SystemTime.UtcNow,
                        Exception = e.ToString(),
                        Title = "Invalid Elasticsearch URL provided",
                        Message = "Elasticsearch Replication could not parse one of the provided node URLs",
                        UniqueKey = "Elasticsearch Replication Connection Error: " + cfg.ConnectionString
                    });
            }
			catch (Exception e)
			{
			    if (database != null)
			        database.AddAlert(new Alert
			        {
			            AlertLevel = AlertLevel.Error,
			            CreatedAt = SystemTime.UtcNow,
			            Exception = e.ToString(),
			            Title = "Elasticsearch Replication could not open connection",
			            Message = "Elasticsearch Replication could not open connection to " + cfg.ConnectionString,
			            UniqueKey = "Elasticsearch Replication Connection Error: " + cfg.ConnectionString
			        });
				throw;
			}
		}
开发者ID:synhershko,项目名称:RavenDB.ElasticsearchReplication,代码行数:41,代码来源:ElasticsearchDestinationWriter.cs

示例10: RelationalDatabaseWriter

		public RelationalDatabaseWriter( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
		{
			this.database = database;
			this.cfg = cfg;
			this.replicationStatistics = replicationStatistics;

			providerFactory = GetDbProviderFactory(cfg);

			commandBuilder = providerFactory.CreateCommandBuilder();
			connection = providerFactory.CreateConnection();

			Debug.Assert(connection != null);
			Debug.Assert(commandBuilder != null);

			connection.ConnectionString = cfg.ConnectionString;

			try
			{
				connection.Open();
			}
			catch (Exception e)
			{
				database.AddAlert(new Alert
				{
					AlertLevel = AlertLevel.Error,
					CreatedAt = SystemTime.UtcNow,
					Exception = e.ToString(),
					Title = "Sql Replication could not open connection",
					Message = "Sql Replication could not open connection to " + connection.ConnectionString,
					UniqueKey = "Sql Replication Connection Error: " + connection.ConnectionString
				});
				throw;
			}

			tx = connection.BeginTransaction();
		}
开发者ID:robashton,项目名称:ravendb,代码行数:36,代码来源:RelationalDatabaseWriter.cs

示例11: ReplicateDeletionsToDestination

		private bool ReplicateDeletionsToDestination(SqlReplicationConfig cfg, IEnumerable<ListItem> deletedDocs)
		{
			var identifiers = deletedDocs.Select(x => x.Key).ToList();
			if (identifiers.Count == 0)
				return true;

			var replicationStats = statistics.GetOrAdd(cfg.Name, name => new SqlReplicationStatistics(name));
			using (var writer = new RelationalDatabaseWriter(Database, cfg, replicationStats))
			{
				foreach (var sqlReplicationTable in cfg.SqlReplicationTables)
				{
					writer.DeleteItems(sqlReplicationTable.TableName, sqlReplicationTable.DocumentKeyColumn, identifiers);
				}
				writer.Commit();
			}

			return true;
		}
开发者ID:joshball,项目名称:ravendb,代码行数:18,代码来源:SqlReplicationTask.cs

示例12: ReplicateToDesintation

		private bool ReplicateToDesintation(SqlReplicationConfig cfg, IEnumerable<JsonDocument> docs)
		{
			var providerFactory = TryGetDbProviderFactory(cfg);
			if (providerFactory == null) 
				return false;

			var dictionary = ApplyConversionScript(cfg, docs);
			if (dictionary.Count == 0)
				return true;
			try
			{
				WriteToRelationalDatabase(cfg, providerFactory, dictionary);
				return true;
			}
			catch (Exception e)
			{
				log.WarnException("Failure to replicate changes to relational database for " + cfg.Name +", updates", e);
				DateTime time, newTime;
				if (lastError.TryGetValue(cfg.Name, out time) == false)
				{
					newTime = SystemTime.UtcNow.AddMinutes(1);
				}
				else
				{
					var totalMinutes = (SystemTime.UtcNow - time).TotalMinutes;
					newTime = SystemTime.UtcNow.AddMinutes(Math.Max(10, Math.Min(1, totalMinutes + 1)));
				}
				lastError[cfg.Name] = newTime;
				return false;
			}
		}
开发者ID:SHSE,项目名称:ravendb,代码行数:31,代码来源:SqlReplicationTask.cs

示例13: ApplyConversionScript

		private ConversionScriptResult ApplyConversionScript(SqlReplicationConfig cfg, IEnumerable<JsonDocument> docs)
		{
			var replicationStats = statistics.GetOrAdd(cfg.Name, name => new SqlReplicationStatistics(name));
			var result = new ConversionScriptResult();
			foreach (var jsonDocument in docs)
			{
				Database.WorkContext.CancellationToken.ThrowIfCancellationRequested();
				if (string.IsNullOrEmpty(cfg.RavenEntityName) == false)
				{
					var entityName = jsonDocument.Metadata.Value<string>(Constants.RavenEntityName);
					if (string.Equals(cfg.RavenEntityName, entityName, StringComparison.InvariantCultureIgnoreCase) == false)
						continue;
				}
				var patcher = new SqlReplicationScriptedJsonPatcher(Database, result, cfg, jsonDocument.Key);
				try
				{
					DocumentRetriever.EnsureIdInMetadata(jsonDocument);
					var document = jsonDocument.ToJson();
					document[Constants.DocumentIdFieldName] = jsonDocument.Key;
					patcher.Apply(document, new ScriptedPatchRequest
					{
						Script = cfg.Script
					}, jsonDocument.SerializedSizeOnDisk);

					if (log.IsDebugEnabled && patcher.Debug.Count > 0)
					{
						log.Debug("Debug output for doc: {0} for script {1}:\r\n.{2}", jsonDocument.Key, cfg.Name, string.Join("\r\n", patcher.Debug));

						patcher.Debug.Clear();
					}

					replicationStats.ScriptSuccess();
				}
				catch (ParseException e)
				{
					replicationStats.MarkScriptAsInvalid(Database, cfg.Script);

					log.WarnException("Could not parse SQL Replication script for " + cfg.Name, e);

					return result;
				}
				catch (Exception e)
				{
					replicationStats.RecordScriptError(Database);
					log.WarnException("Could not process SQL Replication script for " + cfg.Name + ", skipping document: " + jsonDocument.Key, e);
				}
			}
			return result;
		}
开发者ID:kpantos,项目名称:ravendb,代码行数:49,代码来源:SqlReplicationTask.cs

示例14: PrepareSqlReplicationConfig

		private bool PrepareSqlReplicationConfig(SqlReplicationConfig cfg, string sqlReplicationConfigDocumentKey, SqlReplicationStatistics replicationStats, SqlReplicationConnections sqlReplicationConnections, bool writeToLog = true, bool validateSqlReplicationName = true)
		{
			if (validateSqlReplicationName && string.IsNullOrWhiteSpace(cfg.Name))
			{
				if (writeToLog)
					Log.Warn("Could not find name for sql replication document {0}, ignoring", sqlReplicationConfigDocumentKey);
				replicationStats.LastAlert = new Alert
				{
					AlertLevel = AlertLevel.Error,
					CreatedAt = DateTime.UtcNow,
					Title = "Could not start replication",
					Message = string.Format("Could not find name for sql replication document {0}, ignoring", sqlReplicationConfigDocumentKey)
				};
				return false;
			}
			if (string.IsNullOrWhiteSpace(cfg.PredefinedConnectionStringSettingName) == false)
			{
				var matchingConnection = sqlReplicationConnections.PredefinedConnections.FirstOrDefault(x => string.Compare(x.Name, cfg.PredefinedConnectionStringSettingName, StringComparison.InvariantCultureIgnoreCase) == 0);
				if (matchingConnection != null)
				{
					cfg.ConnectionString = matchingConnection.ConnectionString;
					cfg.FactoryName = matchingConnection.FactoryName;
				}
				else
				{
					if (writeToLog)
						Log.Warn("Could not find predefined connection string named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
							cfg.PredefinedConnectionStringSettingName,
							sqlReplicationConfigDocumentKey);
					replicationStats.LastAlert = new Alert
					{
						AlertLevel = AlertLevel.Error,
						CreatedAt = DateTime.UtcNow,
						Title = "Could not start replication",
						Message = string.Format("Could not find predefined connection string named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
							cfg.PredefinedConnectionStringSettingName,
							sqlReplicationConfigDocumentKey)
					};
					return false;
				}
			}
			else if (string.IsNullOrWhiteSpace(cfg.ConnectionStringName) == false)
			{
				var connectionString = ConfigurationManager.ConnectionStrings[cfg.ConnectionStringName];
				if (connectionString == null)
				{
					if (writeToLog)
						Log.Warn("Could not find connection string named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
							cfg.ConnectionStringName, sqlReplicationConfigDocumentKey);

					replicationStats.LastAlert = new Alert
					{
						AlertLevel = AlertLevel.Error,
						CreatedAt = DateTime.UtcNow,
						Title = "Could not start replication",
						Message = string.Format("Could not find connection string named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
							cfg.ConnectionStringName,
							sqlReplicationConfigDocumentKey)
					};
					return false;
				}
				cfg.ConnectionString = connectionString.ConnectionString;
			}
			else if (string.IsNullOrWhiteSpace(cfg.ConnectionStringSettingName) == false)
			{
				var setting = Database.Configuration.Settings[cfg.ConnectionStringSettingName];
				if (string.IsNullOrWhiteSpace(setting))
				{
					if (writeToLog)
						Log.Warn("Could not find setting named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
			cfg.ConnectionStringSettingName,
			sqlReplicationConfigDocumentKey);
					replicationStats.LastAlert = new Alert
					{
						AlertLevel = AlertLevel.Error,
						CreatedAt = DateTime.UtcNow,
						Title = "Could not start replication",
						Message = string.Format("Could not find setting named '{0}' for sql replication config: {1}, ignoring sql replication setting.",
							cfg.ConnectionStringSettingName,
							sqlReplicationConfigDocumentKey)
					};
					return false;
				}
			}
			return true;
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:86,代码来源:SqlReplicationTask.cs

示例15: GetDbProviderFactory

		private DbProviderFactory GetDbProviderFactory(SqlReplicationConfig cfg)
		{
			DbProviderFactory providerFactory;
			try
			{
				providerFactory = DbProviderFactories.GetFactory(cfg.FactoryName);
			}
			catch (Exception e)
			{
				log.WarnException(
					string.Format("Could not find provider factory {0} to replicate to sql for {1}, ignoring", cfg.FactoryName,
									cfg.Name), e);

				database.AddAlert(new Alert
				{
					AlertLevel = AlertLevel.Error,
					CreatedAt = SystemTime.UtcNow,
					Exception = e.ToString(),
					Title = "Sql Replication could not find factory provider",
					Message = string.Format("Could not find factory provider {0} to replicate to sql for {1}, ignoring", cfg.FactoryName,
									cfg.Name),
					UniqueKey = string.Format("Sql Replication Provider Not Found: {0}, {1}", cfg.Name, cfg.FactoryName)
				});

				throw;
			}
			return providerFactory;
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:28,代码来源:RelationalDatabaseWriter.cs


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