/// <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; }); }
/// <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; }
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)); }
/// <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; } }
public void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { Inner.SideBySideExecuteIndex(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc); }
/// <summary> /// Executes the index creation. /// </summary> /// <param name="indexCreationTask"></param> public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask) { return server.DocumentStore.ExecuteIndexAsync(indexCreationTask); }
/// <summary> /// Executes the index creation. /// </summary> public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask) { server.DocumentStore.ExecuteIndex(indexCreationTask); }
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; }); }
public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask) { this.ThrowIfNotInitialized(); this.innerStore.ExecuteIndex(indexCreationTask); }
public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask) { return Inner.ExecuteIndexAsync(indexCreationTask); }
/// <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; }); }
public virtual Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask) { return indexCreationTask.ExecuteAsync(AsyncDatabaseCommands, Conventions); }
/// <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); }
/// <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); }
public Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { return Inner.SideBySideExecuteIndexAsync(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc); }
/// <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; }); }
public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask) { Inner.ExecuteIndex(indexCreationTask); }
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; }); }
/// <summary> /// Executes the index creation. /// </summary> public virtual void ExecuteIndex(AbstractIndexCreationTask indexCreationTask) { indexCreationTask.Execute(DatabaseCommands, Conventions); }
public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask) { throw new NotImplementedException(); }