Permalink
Browse files

Merge branch 'master' of git://github.com/fitzchak/ravendb into FineG…

…rainedNuget

Conflicts:
	default.ps1
Some work on the Bundles packages.
  • Loading branch information...
2 parents edea4e7 + 7fd5021 commit b9b826aca60f6f1fa540570ac616ea1c4e26d2eb @damianh damianh committed Apr 1, 2012
Showing with 22,354 additions and 5,271 deletions.
  1. +6 −4 Bundles/Raven.Bundles.Replication/Tasks/ReplicationTask.cs
  2. +9 −1 Bundles/Raven.Bundles.Tests/Replication/FailoverBetweenTwoMultiTenantDatabases.cs
  3. +6 −1 Bundles/Raven.Bundles.Tests/Replication/ReplicationBase.cs
  4. +12 −0 Bundles/Raven.Bundles.sln
  5. +2 −37 Bundles/Raven.Tryouts/Program.cs
  6. +4 −0 Bundles/Raven.Tryouts/Raven.Tryouts.csproj
  7. +0 −25 ETL/Raven.Etl.sln
  8. +0 −12 ETL/Raven.StackOverflow.Etl/Constants.cs
  9. +0 −135 ETL/Raven.StackOverflow.Etl/FileToRavenCommand.cs
  10. +0 −40 ETL/Raven.StackOverflow.Etl/Generic/BatchFileWritingProcess.cs
  11. +0 −26 ETL/Raven.StackOverflow.Etl/Generic/EnumerablExtensions.cs
  12. +0 −70 ETL/Raven.StackOverflow.Etl/Generic/RowToDatabase.cs
  13. +0 −19 ETL/Raven.StackOverflow.Etl/Generic/SimplePipelineExecutor.cs
  14. +0 −61 ETL/Raven.StackOverflow.Etl/Generic/XmlRowOperationFile.cs
  15. +0 −14 ETL/Raven.StackOverflow.Etl/ICommand.cs
  16. +0 −73 ETL/Raven.StackOverflow.Etl/Posts/AddCommentsToPost.cs
  17. +0 −83 ETL/Raven.StackOverflow.Etl/Posts/AddVotesToPost.cs
  18. +0 −33 ETL/Raven.StackOverflow.Etl/Posts/CommentsProcess.cs
  19. +0 −32 ETL/Raven.StackOverflow.Etl/Posts/PostsProcess.cs
  20. +0 −32 ETL/Raven.StackOverflow.Etl/Posts/VotesProcess.cs
  21. +0 −117 ETL/Raven.StackOverflow.Etl/Program.cs
  22. BIN ETL/Raven.StackOverflow.Etl/Properties/AssemblyInfo.cs
  23. +0 −110 ETL/Raven.StackOverflow.Etl/Raven.StackOverflow.Etl.csproj
  24. +0 −78 ETL/Raven.StackOverflow.Etl/Users/AddBadgesToUser.cs
  25. +0 −32 ETL/Raven.StackOverflow.Etl/Users/BadgesProcess.cs
  26. +0 −32 ETL/Raven.StackOverflow.Etl/Users/UsersProcess.cs
  27. +0 −86 ETL/Raven.StackOverflow.Etl/XMLToFileCommand.cs
  28. +0 −3 ETL/Raven.StackOverflow.Etl/app.config
  29. BIN ETL/SharedLibs/Boo.Lang.dll
  30. BIN ETL/SharedLibs/FileHelpers.dll
  31. BIN ETL/SharedLibs/Newtonsoft.Json.dll
  32. BIN ETL/SharedLibs/Rhino.Etl.Core.dll
  33. BIN ETL/SharedLibs/log4net.dll
  34. +0 −73 ETL/Uploader/Program.cs
  35. BIN ETL/Uploader/Properties/AssemblyInfo.cs
  36. +0 −57 ETL/Uploader/Uploader.csproj
  37. 0 NuGet/{RavenDB.Bundes.MoreLikeThis.nuspec → RavenDB.Bundles.MoreLikeThis.nuspec}
  38. +3 −1 NuGet/RavenDB.Bundles.nuspec
  39. +2 −0 NuGet/RavenDB.Client.Debug.nuspec
  40. +3 −1 NuGet/RavenDB.Client.FSharp.nuspec
  41. +1 −0 NuGet/RavenDB.Client.MoreLikeThis.nuspec
  42. +3 −1 NuGet/RavenDB.Client.MvcIntegration.nuspec
  43. +1 −0 NuGet/RavenDB.Client.UniqueConstraints.nuspec
  44. +1 −0 NuGet/RavenDB.Client.Versioning.nuspec
  45. +23 −18 NuGet/RavenDB.Client.nuspec
  46. +24 −0 NuGet/RavenDB.Database.nuspec
  47. +3 −1 NuGet/RavenDB.Embedded.nuspec
  48. +27 −16 Raven.Client.Lightweight/Connection/ReplicationInformer.cs
  49. +1 −17 Raven.Client.Lightweight/Document/AbstractDocumentQuery.cs
  50. +24 −28 Raven.Client.Lightweight/Document/AsyncDocumentQuery.cs
  51. +6 −0 Raven.Client.Lightweight/Document/AsyncSpatialDocumentQuery.cs
  52. +2 −9 Raven.Client.Lightweight/Document/DocumentQuery.cs
  53. +34 −13 Raven.Client.Lightweight/Document/DocumentStore.cs
  54. +1 −7 Raven.Client.Lightweight/IDocumentQueryCustomization.cs
  55. +0 −2 Raven.Client.Lightweight/Linq/LinqExtensions.cs
  56. +13 −2 Raven.Client.Lightweight/Linq/RavenQueryProviderProcessor.cs
  57. +16 −1 Raven.Client.Lightweight/Util/ConcurrentDictionary.cs
  58. +12 −1 Raven.Database/DocumentDatabase.cs
  59. +4 −0 Raven.Database/Extensions/HttpExtensions.cs
  60. +790 −790 Raven.Database/Indexing/Index.cs
  61. +3 −1 Raven.Database/Indexing/IndexSearcherHolder.cs
  62. +9 −3 Raven.StressTests/Races/BundelsRaceConditions.cs
  63. +14 −1 Raven.StressTests/Races/RaceConditions.cs
  64. +5 −3 Raven.Studio/Models/ApplicationModel.cs
  65. +17 −18 Raven.Tests.Silverlight.UnitTestProvider/AsynchronousTaskTest.cs
  66. +6 −4 Raven.Tests.Silverlight.UnitTestProvider/Raven.Tests.Silverlight.UnitTestProvider.csproj
  67. +5 −0 Raven.Tests.Silverlight.UnitTestProvider/TestClass.cs
  68. +110 −105 Raven.Tests.Silverlight/AsyncDatabaseCommandsTests.cs
  69. +140 −137 Raven.Tests.Silverlight/AsyncDocumentStoreServerTests.cs
  70. +278 −266 Raven.Tests.Silverlight/AsyncLinqQueryTests.cs
  71. +85 −83 Raven.Tests.Silverlight/AsyncLuceneQueryTests.cs
  72. +48 −49 Raven.Tests.Silverlight/Attachments.cs
  73. +103 −99 Raven.Tests.Silverlight/Indexes.cs
  74. +6 −4 Raven.Tests.Silverlight/Raven.Tests.Silverlight.csproj
  75. +48 −47 Raven.Tests.Silverlight/Statistics.cs
  76. +11 −8 Raven.Tests/Bugs/AttachmentEndoding.cs
  77. +18 −17 Raven.Tests/Bugs/DocumentUrl.cs
  78. +22 −18 Raven.Tests/Bugs/Embedded/CanUseForUrlOnly.cs
  79. +6 −4 Raven.Tests/Bugs/Indexing/CreateIndexesOnRemoteServer.cs
  80. +8 −6 Raven.Tests/Bugs/LinqOnUrls.cs
  81. +4 −3 Raven.Tests/Bugs/MassivelyMultiTenant.cs
  82. +30 −33 Raven.Tests/Bugs/OverwriteIndexRemotely.cs
  83. +21 −23 Raven.Tests/Bugs/QueryWithPercentageSignp.cs
  84. +19 −17 Raven.Tests/Bugs/QueryingWithDynamicRavenQueryInspector.cs
  85. +15 −13 Raven.Tests/Bugs/SerializingAndDeserializingWithRaven.cs
  86. +56 −58 Raven.Tests/Bugs/SortingWithWildcardQuery.cs
  87. +52 −50 Raven.Tests/Bugs/SpatialQueries.cs
  88. +243 −217 Raven.Tests/Bugs/Stacey/Aspects.cs
  89. +36 −31 Raven.Tests/Bugs/Stacey/InServerDatabase.cs
  90. +85 −102 Raven.Tests/Document/AsyncDocumentStoreServerTests.cs
  91. +21 −0 Raven.Tests/Document/DocumentStoreServerGranularTests.cs
  92. +543 −763 Raven.Tests/Document/DocumentStoreServerTests.cs
  93. +30 −31 Raven.Tests/Document/DocumentStoreServerTests_DifferentProcess.cs
  94. +87 −0 Raven.Tests/MailingList/Nick.cs
  95. +49 −0 Raven.Tests/MailingList/RyanD.cs
  96. +129 −137 Raven.Tests/MailingList/Thor/LinqTest.cs
  97. +199 −254 Raven.Tests/Querying/UsingDynamicQueryWithRemoteServer.cs
  98. +4 −0 Raven.Tests/Raven.Tests.csproj
  99. +9 −7 Raven.Tests/Shard/BlogModel/ShardedDocumentStoreTest.cs
  100. +118 −0 Raven.Tests/Track/AsyncProjectionShouldWork.cs
  101. +1 −1 Raven.Tryouts/Program.cs
  102. +256 −232 RavenDB.sln
  103. BIN SharedLibs/Silverlight/Microsoft.Silverlight.Testing.dll
  104. BIN SharedLibs/Silverlight/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
  105. BIN SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.dll
  106. +12 −0 SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.extmap.xml
  107. BIN SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.pdb
  108. +14,823 −0 SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.xml
  109. BIN .../Silverlight/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
  110. +12 −0 ...light/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml
  111. BIN .../Silverlight/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.pdb
  112. +3,429 −0 .../Silverlight/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
  113. BIN Tools/StatLight/Ionic.Zip.Reduced.dll
  114. BIN Tools/StatLight/StatLight.Client.For.April2010.xap
  115. BIN Tools/StatLight/StatLight.Client.For.July2009.xap
  116. BIN Tools/StatLight/StatLight.Client.For.MSTest2009July.xap
  117. BIN Tools/StatLight/StatLight.Client.For.MSTest2009November.xap
  118. BIN Tools/StatLight/StatLight.Client.For.MSTest2009October.xap
  119. BIN Tools/StatLight/StatLight.Client.For.MSTest2010April.xap
  120. BIN Tools/StatLight/StatLight.Client.For.MSTest2010March.xap
  121. BIN Tools/StatLight/StatLight.Client.For.MSTest2010May.xap
  122. BIN Tools/StatLight/StatLight.Client.For.MSTest2011December.xap
  123. BIN Tools/StatLight/StatLight.Client.For.MSTest2011Feb.xap
  124. BIN Tools/StatLight/StatLight.Client.For.MSTest2011June.xap
  125. BIN Tools/StatLight/StatLight.Client.For.MSTest2011October.xap
  126. BIN Tools/StatLight/StatLight.Client.For.March2010.xap
  127. BIN Tools/StatLight/StatLight.Client.For.May2010.xap
  128. BIN Tools/StatLight/StatLight.Client.For.November2009.xap
  129. BIN Tools/StatLight/StatLight.Client.For.October2009.xap
  130. BIN Tools/StatLight/StatLight.Client.For.UnitDriven2009December.xap
  131. BIN Tools/StatLight/StatLight.Client.For.UnitDrivenDecember2009.xap
  132. BIN Tools/StatLight/StatLight.Client.For.XUnitContrib2011April.xap
  133. BIN Tools/StatLight/StatLight.Core.dll
  134. BIN Tools/StatLight/StatLight.exe
  135. +41 −0 Tools/StatLight/StatLight.exe.config
  136. +0 −3 Tools/StatLight/version.txt
  137. +55 −229 default.ps1
@@ -47,12 +47,14 @@ public void Execute(DocumentDatabase database)
httpRavenRequestFactory = new HttpRavenRequestFactory {RequestTimeoutInMs = replicationRequestTimeoutInMs};
- new Thread(Execute)
+ var thread = new Thread(Execute)
{
IsBackground = true,
Name = "Replication Thread"
- }.Start();
-
+ };
+ // make sure that the doc db waits for the replication thread shutdown
+ docDb.ExtensionsState.TryAdd(thread, new DisposableAction(thread.Join));
+ thread.Start();
}
private void Execute()
@@ -513,7 +515,7 @@ private static ReplicationStrategy CreateReplicationStrategyFromDocument(Replica
var url = x.Url;
if (string.IsNullOrEmpty(x.Database) == false)
{
- url = "/databases/" + x.Database;
+ url = url + "/databases/" + x.Database;
}
replicationStrategy.ConnectionStringOptions = new RavenConnectionStringOptions
{
@@ -34,15 +34,23 @@ public void CanReplicateBetweenTwoMultiTenantDatabases()
{
store.Initialize();
var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
- replicationInformerForDatabase.UpdateReplicationInformationIfNeeded((ServerClient) store.DatabaseCommands)
+ var databaseCommands = (ServerClient) store.DatabaseCommands;
+ replicationInformerForDatabase.UpdateReplicationInformationIfNeeded(databaseCommands)
.Wait();
+ var replicationDestinations = replicationInformerForDatabase.ReplicationDestinations;
+
+ Assert.NotEmpty(replicationDestinations);
+
using (var session = store.OpenSession())
{
session.Store(new Item {});
session.SaveChanges();
}
+ var sanityCheck = store.DatabaseCommands.Head("items/1");
+ Assert.NotNull(sanityCheck);
+
WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");
}
}
@@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
+using System.Diagnostics;
using System.Threading;
using Raven.Abstractions.Replication;
using Raven.Client;
@@ -136,6 +137,7 @@ protected virtual void SetupDestination(ReplicationDestination replicationDestin
protected void SetupReplication(IDatabaseCommands source, params string[] urls)
{
+ Assert.NotEmpty(urls);
source.Put(replication::Raven.Bundles.Replication.ReplicationConstants.RavenReplicationDestinations,
null, new RavenJObject
{
@@ -174,7 +176,10 @@ protected void WaitForDocument(IDatabaseCommands commands, string expectedId)
break;
Thread.Sleep(100);
}
- Assert.NotNull(commands.Head(expectedId));
+
+ var jsonDocumentMetadata = commands.Head(expectedId);
+
+ Assert.NotNull(jsonDocumentMetadata);
}
}
}
View
@@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Bundles.UniqueConstra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Client.UniqueConstraints", "Raven.Client.UniqueConstraints\Raven.Client.UniqueConstraints.csproj", "{D185331D-2B7C-4251-8EBE-140EDE1FAB9F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.StressTests", "..\Raven.StressTests\Raven.StressTests.csproj", "{005A5143-4E38-424B-A2D1-25EF88DA05CB}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -329,6 +331,16 @@ Global
{D185331D-2B7C-4251-8EBE-140EDE1FAB9F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D185331D-2B7C-4251-8EBE-140EDE1FAB9F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D185331D-2B7C-4251-8EBE-140EDE1FAB9F}.Release|x86.ActiveCfg = Release|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {005A5143-4E38-424B-A2D1-25EF88DA05CB}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -6,50 +6,15 @@
using Raven.Bundles.Tests.Authorization.Bugs;
using Raven.Bundles.Tests.Replication;
using Raven.Database.Server;
+using Raven.StressTests.Races;
namespace Raven.Tryouts
{
internal class Program
{
private static void Main()
{
- if (Directory.Exists("Logs"))
- {
- foreach (var file in Directory.GetFiles("Logs"))
- {
- File.Delete(file);
- }
- }
- SetupLogging();
-
- try
- {
- for (int i = 0; i < 1000; i++)
- {
- Environment.SetEnvironmentVariable("Run", i.ToString());
- Console.Clear();
- Console.WriteLine(i);
- using (var x = new FailoverBetweenTwoMultiTenantDatabases())
- x.CanFailoverReplicationBetweenTwoMultiTenantDatabases_WithExplicitUrl();
- }
- }
- finally
- {
- LogManager.Flush();
- }
- }
-
-
- private static void SetupLogging()
- {
- HttpEndpointRegistration.RegisterHttpEndpointTarget();
-
- using (var stream = typeof(Program).Assembly.GetManifestResourceStream("Raven.Tryouts.DefaultLogging.config"))
- using (var reader = XmlReader.Create(stream))
- {
- LogManager.Configuration = new XmlLoggingConfiguration(reader, "default-config");
- }
-
+ new BundelsRaceConditions().FailoverBetweenTwoMultiTenantDatabases_CanReplicateBetweenTwoMultiTenantDatabases();
}
}
}
@@ -67,6 +67,10 @@
<Project>{DA99A419-E137-40DB-9495-0C363B479D4B}</Project>
<Name>Raven.Storage.Managed</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Raven.StressTests\Raven.StressTests.csproj">
+ <Project>{005A5143-4E38-424B-A2D1-25EF88DA05CB}</Project>
+ <Name>Raven.StressTests</Name>
+ </ProjectReference>
<ProjectReference Include="..\Raven.Bundles.Tests\Raven.Bundles.Tests.csproj">
<Project>{35CFAB1C-7934-4481-AC0D-7102F7DEE7F8}</Project>
<Name>Raven.Bundles.Tests</Name>
View
@@ -1,25 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.StackOverflow.Etl", "Raven.StackOverflow.Etl\Raven.StackOverflow.Etl.csproj", "{3CA2ED91-8A67-4CD4-B728-91470E3CE97C}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uploader", "Uploader\Uploader.csproj", "{E4D12C01-659E-4BA9-8B87-D967C175FBF0}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x86 = Debug|x86
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3CA2ED91-8A67-4CD4-B728-91470E3CE97C}.Debug|x86.ActiveCfg = Debug|x86
- {3CA2ED91-8A67-4CD4-B728-91470E3CE97C}.Debug|x86.Build.0 = Debug|x86
- {3CA2ED91-8A67-4CD4-B728-91470E3CE97C}.Release|x86.ActiveCfg = Release|x86
- {3CA2ED91-8A67-4CD4-B728-91470E3CE97C}.Release|x86.Build.0 = Release|x86
- {E4D12C01-659E-4BA9-8B87-D967C175FBF0}.Debug|x86.ActiveCfg = Debug|x86
- {E4D12C01-659E-4BA9-8B87-D967C175FBF0}.Debug|x86.Build.0 = Debug|x86
- {E4D12C01-659E-4BA9-8B87-D967C175FBF0}.Release|x86.ActiveCfg = Release|x86
- {E4D12C01-659E-4BA9-8B87-D967C175FBF0}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
@@ -1,12 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="Constants.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-namespace Raven.StackOverflow.Etl
-{
- public class Constants
- {
- public const int BatchSize = 1024;
- }
-}
@@ -1,135 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Raven.StackOverflow.Etl
-{
- public class FileToRavenCommand : ICommand
- {
- public string CommandText
- {
- get { return "file2raven"; }
- }
-
- public string InputDirectory { get; private set; }
- public string OutputRavenUrl { get; private set; }
-
- public void Run()
- {
- ExecuteAndWaitAll(
- LoadDataFor("Users*.json")
- //,LoadDataFor("Posts*.json")
- );
- ExecuteAndWaitAll(
- LoadDataFor("Badges*.json")
- //,LoadDataFor("Votes*.json"),
- //LoadDataFor("Comments*.json")
- );
- }
-
- public IEnumerable<Action> LoadDataFor(string searchPattern)
- {
- Console.WriteLine("Loading {0}.", Path.Combine(InputDirectory, searchPattern ?? "*"));
- var timeSpans = new List<TimeSpan>();
- foreach (var fileModifable in Directory.GetFiles(InputDirectory, searchPattern))
- {
- var file = fileModifable;
- yield return () =>
- {
- var sp = Stopwatch.StartNew();
- HttpWebResponse webResponse;
- while (true)
- {
-
- var httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(new Uri(OutputRavenUrl), "bulk_docs"));
- httpWebRequest.Method = "POST";
- using (var requestStream = httpWebRequest.GetRequestStream())
- {
- var readAllBytes = File.ReadAllBytes(file);
- requestStream.Write(readAllBytes, 0, readAllBytes.Length);
- }
- try
- {
- webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
- webResponse.Close();
- break;
- }
- catch (WebException e)
- {
- webResponse = e.Response as HttpWebResponse;
- if (webResponse != null &&
- webResponse.StatusCode == HttpStatusCode.Conflict)
- {
- Console.WriteLine("{0} - {1} - {2} - {3}", Path.GetFileName(file), sp.Elapsed, webResponse.StatusCode,
- Thread.CurrentThread.ManagedThreadId);
- continue;
- }
-
- Console.WriteLine(new StreamReader(e.Response.GetResponseStream()).ReadToEnd());
- throw;
- }
- }
- var timeSpan = sp.Elapsed;
- timeSpans.Add(timeSpan);
- Program.durations.Add(new Tuple<string, TimeSpan>(searchPattern, timeSpan));
- Console.WriteLine("{0} - {1} - {2} - {3}", Path.GetFileName(file), timeSpan, webResponse.StatusCode,
- Thread.CurrentThread.ManagedThreadId);
- };
- }
- }
-
- public static void ExecuteAndWaitAll(params IEnumerable<Action>[] taskGenerators)
- {
- Parallel.ForEach(from generator in taskGenerators
- from action in generator
- select action,
- new ParallelOptions { MaxDegreeOfParallelism = 10 },
- action =>
- {
- try
- {
- action();
- }
- catch (WebException e)
- {
- var readToEnd = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
- Console.WriteLine(readToEnd);
- throw;
- }
- });
-
- //foreach (var act in from generator in taskGenerators
- // from action in generator
- // select action)
- //{
- // act();
- //}
- }
-
- public void LoadArgs(string[] remainingArgs)
- {
- if (remainingArgs.Count() != 2)
- throw new Exception("");
-
- InputDirectory = remainingArgs[0];
-
- if (!Directory.Exists(InputDirectory))
- throw new ArgumentException("Input directory not found.");
-
- OutputRavenUrl = remainingArgs[1];
-
- if (!new Uri(OutputRavenUrl).Scheme.Equals("http", StringComparison.InvariantCultureIgnoreCase))
- throw new ArgumentException("RavenDB url expected as second parameter");
- }
-
- public void WriteHelp(TextWriter tw)
- {
- Console.WriteLine("Raven.StackOverflow.Etl.exe " + CommandText + " <inputDirectory> <outputRavenUrl>");
- }
- }
-}
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.IO;
-using Raven.Abstractions.Commands;
-using Rhino.Etl.Core.Operations;
-
-namespace Raven.StackOverflow.Etl.Generic
-{
- public abstract class BatchFileWritingProcess : AbstractOperation
- {
- protected BatchFileWritingProcess(string outputDirectory)
- {
- OutputDirectory = outputDirectory;
- }
-
- public string OutputDirectory { get; private set; }
-
- public string GetOutputPath(params string[] pathElements)
- {
- string result = OutputDirectory;
-
- foreach (var element in pathElements)
- result = Path.Combine(result, element);
-
- var parent = new DirectoryInfo(result).Parent;
-
- if (!parent.Exists)
- parent.Create();
-
- return result;
- }
-
- public void WriteCommandsTo(string filename, IEnumerable<ICommandData> commands)
- {
- File.WriteAllText(GetOutputPath(filename),
- "[" + String.Join(",\n", commands.Select(c => c.ToJson().ToString())) + "]");
- }
- }
-}
Oops, something went wrong.

0 comments on commit b9b826a

Please sign in to comment.