コード例 #1
0
ファイル: IndexBuilder.cs プロジェクト: rickj33/hircine
        /// <summary>
        /// Build a single index asynchronously
        /// </summary>
        /// <param name="indexInstance">An activated AbstractIndexCreationTask instance</param>
        /// <param name="progressCallBack">A callback we can use to report on the progress of a batch job; default is null</param>
        /// <returns>A task containing an IndexBuildResult report for this specific index</returns>
        public Task<IndexBuildResult> BuildIndexAsync(AbstractIndexCreationTask indexInstance, Action<IndexBuildResult> progressCallBack = null)
        {
            return Task.Factory.StartNew(() => indexInstance.Execute(_documentStore))
                .ContinueWith(result =>
                                  {
                                      var indexBuildResult = new IndexBuildResult()
                                                                 {IndexName = indexInstance.IndexName, ConnectionString = _documentStore.Identifier};

                                      if (result.IsCompleted && result.Exception == null)
                                      {
                                          indexBuildResult.Result = BuildResult.Created;
                                      }
                                      else if (result.IsCanceled)
                                      {
                                          indexBuildResult.Result = BuildResult.Cancelled;
                                      }
                                      else
                                      {
                                          indexBuildResult.Result = BuildResult.Failed;
                                          indexBuildResult.BuildException = result.Exception != null ? result.Exception.Flatten() : null;
                                      }

                                      if (progressCallBack != null)
                                      {
                                          progressCallBack.Invoke(indexBuildResult);
                                      }

                                      return indexBuildResult;
                                  });
        }
コード例 #2
0
ファイル: IndexBuilder.cs プロジェクト: rickj33/hircine
        /// <summary>
        /// Build a single index synchronously
        /// </summary>
        /// <param name="indexInstance">An activated AbstractIndexCreationTask instance</param>
        /// <returns>An IndexBuildResult report for this specific index</returns>
        public IndexBuildResult BuildIndex(AbstractIndexCreationTask indexInstance)
        {
            var buildIndexTask = BuildIndexAsync(indexInstance, null);

            buildIndexTask.Wait();

            return buildIndexTask.Result;
        }
コード例 #3
0
ファイル: ThinClient.cs プロジェクト: j2jensen/ravendb
        public void PutIndex(AbstractIndexCreationTask index)
        {
            var response = httpClient
                .PutAsync(databaseUrl + "/indexes/" + Uri.EscapeUriString(index.IndexName), new JsonContent(RavenJObject.FromObject(index.CreateIndexDefinition())))
                .ResultUnwrap();

            if (response.IsSuccessStatusCode == false)
                throw new InvalidOperationException(string.Format("PUT failed on '{0}'. Code: {1}.", index.IndexName, response.StatusCode));
        }
コード例 #4
0
ファイル: Helpers.cs プロジェクト: hanin/NServiceBus.RavenDB
 /// <summary>
 /// Safely add the index to the RavenDB database, protect against possible failures caused by documented
 /// and undocumented possibilities of failure.
 /// Will throw iff index registration failed and index doesn't exist or it exists but with a non-current definition.
 /// </summary>
 /// <param name="store"></param>
 /// <param name="index"></param>
 internal static void SafelyCreateIndex(IDocumentStore store, AbstractIndexCreationTask index)
 {
     try
     {
         index.Execute(store);
     }
     catch (Exception) // Apparently ArgumentException can be thrown as well as a WebException; not taking any chances
     {
         var existingIndex = store.DatabaseCommands.GetIndex(index.IndexName);
         if (existingIndex == null || !index.CreateIndexDefinition().Equals(existingIndex))
             throw;
     }
 }
コード例 #5
0
	    public void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
	    {
			Inner.SideBySideExecuteIndex(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc);
	    }
コード例 #6
0
	    /// <summary>
        ///     Executes the index creation.
        /// </summary>
        /// <param name="indexCreationTask"></param>
        public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
        {
            return server.DocumentStore.ExecuteIndexAsync(indexCreationTask);
        }
コード例 #7
0
 /// <summary>
 ///     Executes the index creation.
 /// </summary>
 public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
 {
     server.DocumentStore.ExecuteIndex(indexCreationTask);
 }
コード例 #8
0
		public override Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
		{
			var list = ShardStrategy.Shards.Values.Select(x => x.AsyncDatabaseCommands).ToList();
			return ShardStrategy.ShardAccessStrategy.ApplyAsync(list, new ShardRequestData(), (commands, i) =>
			{
				var tcs = new TaskCompletionSource<bool>();

				try
				{
					indexCreationTask.SideBySideExecuteAsync(commands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc)
									 .ContinueWith(t => tcs.SetResult(true));
				}
				catch (Exception e)
				{
					tcs.SetException(e);
				}

				return tcs.Task;
			});
		}
コード例 #9
0
 public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
 {
     this.ThrowIfNotInitialized();
     this.innerStore.ExecuteIndex(indexCreationTask);
 }
コード例 #10
0
 public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
 {
     return Inner.ExecuteIndexAsync(indexCreationTask);
 }
コード例 #11
0
		/// <summary>
		/// Executes the index creation against each of the shards.
		/// </summary>
		public override void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
		{
			var list = ShardStrategy.Shards.Values.Select(x => x.DatabaseCommands).ToList();
			ShardStrategy.ShardAccessStrategy.Apply(list,
															new ShardRequestData()
															, (commands, i) =>
															{
																indexCreationTask.Execute(commands, Conventions);
																return (object)null;
															});
		}
コード例 #12
0
	    public virtual Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
	    {
	        return indexCreationTask.ExecuteAsync(AsyncDatabaseCommands, Conventions);
	    }
コード例 #13
0
ファイル: DocumentStoreBase.cs プロジェクト: GorelH/ravendb
		/// <summary>
		/// Executes the index creation in side-by-side mode.
		/// </summary>
		public virtual Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
		{
			return indexCreationTask.SideBySideExecuteAsync(AsyncDatabaseCommands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc);
		}
コード例 #14
0
ファイル: DocumentStoreBase.cs プロジェクト: GorelH/ravendb
		/// <summary>
		/// Executes the index creation in side-by-side mode.
		/// </summary>
		public virtual void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
		{
			indexCreationTask.SideBySideExecute(DatabaseCommands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc);
		}
コード例 #15
0
	    public Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
	    {
		    return Inner.SideBySideExecuteIndexAsync(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc);
	    }
コード例 #16
0
        /// <summary>
        /// Executes the index creation against each of the shards Async.
        /// </summary>
        public override Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
        {
            var list = ShardStrategy.Shards.Values.Select(x => x.AsyncDatabaseCommands).ToList();
            return ShardStrategy.ShardAccessStrategy.ApplyAsync(list,new ShardRequestData(), (commands, i) =>
            {
                var tcs = new TaskCompletionSource<bool>();

                try
                {
                    indexCreationTask.ExecuteAsync(commands, Conventions)
                                     .ContinueWith(t => tcs.SetResult(true));
                }
                catch (Exception e)
                {
                    tcs.SetException(e);
                }

                return tcs.Task;
            });
        }
コード例 #17
0
 public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
 {
     Inner.ExecuteIndex(indexCreationTask);
 }
コード例 #18
0
		public override void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
		{
			var list = ShardStrategy.Shards.Values.Select(x => x.DatabaseCommands).ToList();
			ShardStrategy.ShardAccessStrategy.Apply(list,
															new ShardRequestData()
															, (commands, i) =>
															{
																indexCreationTask.SideBySideExecute(commands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc);
																return (object)null;
															});
		}
コード例 #19
0
		/// <summary>
		/// Executes the index creation.
		/// </summary>
		public virtual void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
		{
			indexCreationTask.Execute(DatabaseCommands, Conventions);
		}
コード例 #20
0
 public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
 {
     throw new NotImplementedException();
 }