RavenDB导入/导出在服务器上失败但在Embedded上工作

时间:2014-01-17 08:55:16

标签: ravendb ravendb-http

我正在考虑为RavenDB编写一个导入/导出例程,以便我可以在本地完整的服务器实例上进行开发,但由于资源限制,可以在网站上运行。我希望能够在站点的锁定部分中管理功能,以允许从文件进行备份和还原。但我还希望能够将生产数据集还原到本地服务器实例中以进行调试和开发。

作为其中的一部分,我一直在研究使用v2.5.2750 ISmugglerApi接口,特别是Raven.Database.Smuggler.DataDumper和Raven.Smuggler.SmugglerApi实现。

我可以使用嵌入式实例进行备份和恢复。我可以正常备份服务器实例并将此文件导入嵌入式实例。但是,恢复到服务器数据库是问题发生的地方。

我使用的代码如下:

恢复代码:

        SmugglerOptions smugglerOptions = new SmugglerOptions { BackupPath = Server.MapPath(ServerMapPath) };
        switch (Context)
        {
            case Context.Embedded:
                DataDumper dumper = new DataDumper(((EmbeddableDocumentStore)MvcApplication.Store).DocumentDatabase, smugglerOptions);
                var embeddedImport = dumper.ImportData(smugglerOptions);
                await embeddedImport;
                break;

            case Context.Server:
                var connectionStringOptions = new RavenConnectionStringOptions
                {
                    ApiKey = Configuration.ApiKey,
                    DefaultDatabase = Configuration.DefaultDatabase,
                    Url = Configuration.DefaultUrl
                };

                var smugglerApi = new SmugglerApi(smugglerOptions, connectionStringOptions);
                var serverImport = smugglerApi.ImportData(smugglerOptions);
                await serverImport;
                break;
        }

备份代码:

        SmugglerOptions smugglerOptions = new SmugglerOptions { BackupPath = Server.MapPath(ServerMapPath) };
        switch (Context)
        {
            case Context.Embedded:
                DataDumper dumper = new DataDumper(((EmbeddableDocumentStore)MvcApplication.Store).DocumentDatabase, smugglerOptions);
                var embeddedExport = dumper.ExportData(null, smugglerOptions, false);
                await embeddedExport;
                break;

            case Context.Server:
                var connectionStringOptions = new RavenConnectionStringOptions
                {
                    ApiKey = Configuration.ApiKey,
                    DefaultDatabase = Configuration.DefaultDatabase,
                    Url = Configuration.DefaultUrl
                };

                var smugglerApi = new SmugglerApi(smugglerOptions, connectionStringOptions);
                var serverExport = smugglerApi.ExportData(null, smugglerOptions, false);
                await serverExport;
                break;
        }

ServerMapPath当前是App_Data文件夹中文件名的常量字符串。

Configuration。*是一个简单的静态类,用于从web.config中读取所需设置的值。

Context是一个配置选项,用于指定运行它的环境类型。

当我将恢复运行到服务器数据库配置时,我得到以下内容:

  

远程服务器返回错误:(400)错误请求。

     

[WebException:远程服务器返回错误:(400)错误   请求。] System.Net.HttpWebRequest.GetResponse()+ 6592536
  Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1   getResponse)in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \连接\ HttpJsonRequest.cs:349

     

[InvalidOperationException:

无法理解   怎么做

您的请求与Raven的任何内容都不匹配   知道要做,对不起......

]
  Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e)   在   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \连接\ HttpJsonRequest.cs:513   Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1   getResponse)in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \连接\ HttpJsonRequest.cs:355   Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \连接\ HttpJsonRequest.cs:239   Raven.Client.Document.RemoteBulkInsertOperation.GetAuthToken()in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \文献\ RemoteBulkInsertOperation.cs:151   Raven.Client.Document.d_ b.MoveNext()in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \文献\ RemoteBulkInsertOperation.cs:0   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52
  Raven.Client.Document.d
_3.MoveNext()in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \文献\ RemoteBulkInsertOperation.cs:100   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52 Raven.Client.Document.d__18.MoveNext()in   C:\构建\ RavenDB稳\ Raven.Client.Lightweight \文献\ RemoteBulkInsertOperation.cs:281

     

[AggregateException:发生了一个或多个错误。]
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+83
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(任务   任务)+71 Raven.Smuggler.d_ 6.MoveNext()in   C:\构建\ RavenDB稳\ Raven.Smuggler \ SmugglerApi.cs:87
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52 Raven.Abstractions.Smuggler.d
_26.MoveNext()   在   C:\构建\ RavenDB稳\ Raven.Abstractions \走私\ SmugglerApiBase.cs:322   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52 System.Runtime.CompilerServices.TaskAwaiter.GetResult()   +21 SampleApplication.Controllers.d__15.MoveNext()在c:\ Src \ Random \ RavenImportExport \ SampleApplication \ Controllers \ HomeController.cs:105   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52 lambda_method(关闭,任务)+23
  System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(任务任务)   +33 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult)   asyncResult)+68
  System.Web.Mvc.Async<> C_ DisplayClass34.b _33(IAsyncResult的   asyncResult)+16
  System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult的   asyncResult)+32
  System.Web.Mvc.Async.AsyncInvocationWithFilters.b_ 3c中()   +50 System.Web.Mvc.Async。<> c _DisplayClass45.b_ 3e()   +225 System.Web.Mvc.Async。<> c _DisplayClass30.b_ 2f(IAsyncResult asyncResult)+10
  System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult的   asyncResult)+34
  System.Web.Mvc.Async<。&以及c
_DisplayClass28.b_ 19()   +26 System.Web.Mvc.Async。<> c _DisplayClass1e.b_ 1b(IAsyncResult   asyncResult)+100
  System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult的   asyncResult)+27
  System.Web.Mvc.Controller.b
_1d(IAsyncResult的   asyncResult,ExecuteCoreState innerState)+13
  System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54
  System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+39   System.Web.Mvc.Controller.b_ 15(IAsyncResult的   asyncResult,控制器控制器)+12
  System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54
  System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+29
  System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult的   asyncResult)+10
  System.Web.Mvc.MvcHandler.b
_4(IAsyncResult的   asyncResult,ProcessRequestState innerState)+21
  System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54
  System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)   +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult)   结果)+9
  System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult的   ar)+129

我做错了什么?

0 个答案:

没有答案