コード例 #1
0
ファイル: IndexingExecuter.cs プロジェクト: urbanfly/ravendb
		public IndexingExecuter(WorkContext context, DatabaseEtagSynchronizer synchronizer, Prefetcher prefetcher)
			: base(context)
		{
			autoTuner = new IndexBatchSizeAutoTuner(context);
			etagSynchronizer = synchronizer.GetSynchronizer(EtagSynchronizerType.Indexer);
			prefetchingBehavior = prefetcher.GetPrefetchingBehavior(PrefetchingUser.Indexer, autoTuner);
		}
コード例 #2
0
ファイル: SqlReplicationTask.cs プロジェクト: kpantos/ravendb
		public void Execute(DocumentDatabase database)
		{
			etagSynchronizer = database.EtagSynchronizer.GetSynchronizer(EtagSynchronizerType.SqlReplicator);
			prefetchingBehavior = database.Prefetcher.GetPrefetchingBehavior(PrefetchingUser.SqlReplicator, null);

			Database = database;
			Database.OnDocumentChange += (sender, notification, metadata) =>
			{
				if (notification.Id == null)
					return;

				if (metadata == null)
					return; // this is a delete being made on an already deleted document

				if (notification.Type == DocumentChangeTypes.Delete)
				{
					RecordDelete(notification.Id, metadata);
				}

				if (!notification.Id.StartsWith("Raven/SqlReplication/Configuration/", StringComparison.InvariantCultureIgnoreCase))
					return;

				replicationConfigs = null;
				statistics.Clear();
				log.Debug(() => "Sql Replication configuration was changed.");
			};

			GetReplicationStatus();

			var task = Task.Factory.StartNew(() =>
			{
				using (LogContext.WithDatabase(database.Name))
				{
					try
					{
						BackgroundSqlReplication();
					}
					catch (Exception e)
					{
						log.ErrorException("Fatal failure when replicating to SQL. All SQL Replication activity STOPPED", e);
					}
				}
			}, TaskCreationOptions.LongRunning);
			database.ExtensionsState.GetOrAdd(typeof(SqlReplicationTask).FullName, k => new DisposableAction(task.Wait));
		}
コード例 #3
0
		public EtagSynchronizer GetSynchronizer(EtagSynchronizerType type)
		{
			EtagSynchronizer value;
			if (etagSynchronizers.TryGetValue(type, out value))
				return value;
			lock (this)
			{
				if (etagSynchronizers.TryGetValue(type, out value))
					return value;
		
				value = new EtagSynchronizer(type, transactionalStorage);
				etagSynchronizers = new Dictionary<EtagSynchronizerType, EtagSynchronizer>(etagSynchronizers)
				{
					{type, value}
				};
				return value;
			}
		}
コード例 #4
0
ファイル: ReplicationTask.cs プロジェクト: robashton/ravendb
		public void Execute(DocumentDatabase database)
		{
			etagSynchronizer = database.EtagSynchronizer.GetSynchronizer(EtagSynchronizerType.Replicator);
			prefetchingBehavior = database.Prefetcher.GetPrefetchingBehavior(PrefetchingUser.Replicator);

			docDb = database;
			var replicationRequestTimeoutInMs =
				docDb.Configuration.GetConfigurationValue<int>("Raven/Replication/ReplicationRequestTimeout") ??
				60 * 1000;

			httpRavenRequestFactory = new HttpRavenRequestFactory { RequestTimeoutInMs = replicationRequestTimeoutInMs };

            var task = new Task(Execute, TaskCreationOptions.LongRunning);
			var disposableAction = new DisposableAction(task.Wait);
			// make sure that the doc db waits for the replication task shutdown
			docDb.ExtensionsState.GetOrAdd(Guid.NewGuid().ToString(), s => disposableAction);
			task.Start();
            

		}
コード例 #5
0
        public EtagSynchronizer GetSynchronizer(EtagSynchronizerType type)
        {
            EtagSynchronizer value;

            if (etagSynchronizers.TryGetValue(type, out value))
            {
                return(value);
            }
            lock (this)
            {
                if (etagSynchronizers.TryGetValue(type, out value))
                {
                    return(value);
                }

                value             = new EtagSynchronizer(type, transactionalStorage);
                etagSynchronizers = new Dictionary <EtagSynchronizerType, EtagSynchronizer>(etagSynchronizers)
                {
                    { type, value }
                };
                return(value);
            }
        }