Permalink
Browse files

Moving to psake

restructuring project
removed DHT integration
  • Loading branch information...
ayende committed Sep 2, 2009
1 parent 591d611 commit 210d04785c31e331594024226563997f472b759f
Showing with 62,380 additions and 1,454 deletions.
  1. +11 −0 .gitignore
  2. +0 −70 Rhino.ServiceBus.DistributedHashTableIntegration/DhtClientSagaFacility.cs
  3. +0 −130 Rhino.ServiceBus.DistributedHashTableIntegration/DistributedHashTableSagaPersister.cs
  4. +0 −8 Rhino.ServiceBus.DistributedHashTableIntegration/ISagaStateMerger.cs
  5. +0 −10 Rhino.ServiceBus.DistributedHashTableIntegration/IVersionedSagaState.cs
  6. +0 −102 Rhino.ServiceBus.DistributedHashTableIntegration/OptimisticDistributedHashTableSagaPersister.cs
  7. +0 −85 ...erviceBus.DistributedHashTableIntegration/Rhino.ServiceBus.DistributedHashTableIntegration.csproj
  8. +0 −227 Rhino.ServiceBus.LogsService/MsmqLogReader.cs
  9. +0 −41 Rhino.ServiceBus.LogsService/Program.cs
  10. +0 −36 Rhino.ServiceBus.LogsService/Properties/AssemblyInfo.cs
  11. +0 −75 Rhino.ServiceBus.LogsService/Rhino.ServiceBus.LogsService.csproj
  12. +79 −81 Rhino.ServiceBus.Tests/DefaultReflectionTests.cs
  13. +0 −74 Rhino.ServiceBus.Tests/Dht/BaristaSaga.cs
  14. +0 −24 Rhino.ServiceBus.Tests/Dht/BaristaState.cs
  15. +0 −26 Rhino.ServiceBus.Tests/Dht/BaristaStateMerger.cs
  16. +0 −200 Rhino.ServiceBus.Tests/Dht/DistributedHashTableSagaPersisterTests.cs
  17. +0 −11 Rhino.ServiceBus.Tests/Dht/DrinkReady.cs
  18. +0 −29 Rhino.ServiceBus.Tests/Dht/InvalidBaristaSaga.cs
  19. +0 −10 Rhino.ServiceBus.Tests/Dht/PaymentComplete.cs
  20. +0 −18 Rhino.ServiceBus.Tests/Dht/PrepareDrink.cs
  21. +0 −28 Rhino.ServiceBus.Tests/Dht/UsageErrors.cs
  22. +3 −1 Rhino.ServiceBus.Tests/Hosting/Can_host_in_another_app_domain.cs
  23. +23 −36 Rhino.ServiceBus.Tests/Rhino.ServiceBus.Tests.csproj
  24. +0 −48 Rhino.ServiceBus.sln
  25. +7 −2 Rhino.ServiceBus/Hosting/RemoteAppDomainHost.cs
  26. +0 −4 Rhino.ServiceBus/Hosting/RemoteAppDomainLoadBalancerHost.cs
  27. +37 −35 Rhino.ServiceBus/Impl/DefaultReflection.cs
  28. +17 −19 Rhino.ServiceBus/Rhino.ServiceBus.csproj
  29. +6 −6 Rhino.ServiceBus/RhinoQueues/PhtSubscriptionStorage.cs
  30. +1 −0 Rhino.ServiceBus/RhinoQueues/RhinoQueuesTransport.cs
  31. +2 −0 Rhino.ServiceBus/RhinoQueues/TimeoutAction.cs
  32. +11 −7 Samples/Starbucks.Tests/Starbucks.Tests.csproj
  33. +15 −11 Samples/Starbucks/Starbucks.csproj
  34. BIN SharedLibs/Castle.Core.dll
  35. +3,197 −0 SharedLibs/Castle.Core.xml
  36. BIN SharedLibs/Castle.DynamicProxy2.dll
  37. +1,249 −0 SharedLibs/Castle.DynamicProxy2.xml
  38. BIN SharedLibs/Castle.MicroKernel.dll
  39. +5,484 −0 SharedLibs/Castle.MicroKernel.xml
  40. BIN SharedLibs/Castle.Windsor.dll
  41. +1,571 −0 SharedLibs/Castle.Windsor.xml
  42. BIN SharedLibs/Esent.Interop.dll
  43. +9,521 −0 SharedLibs/Esent.Interop.xml
  44. BIN SharedLibs/Rhino.DistributedHashTable.Client.dll
  45. BIN SharedLibs/Rhino.DistributedHashTable.dll
  46. BIN SharedLibs/Rhino.Mocks.dll
  47. +5,413 −0 SharedLibs/Rhino.Mocks.xml
  48. BIN SharedLibs/Rhino.PersistentHashTable.dll
  49. BIN SharedLibs/Rhino.Queues.dll
  50. BIN SharedLibs/Wintellect.Threading.dll
  51. +3,330 −0 SharedLibs/Wintellect.Threading.xml
  52. BIN SharedLibs/log4net.dll
  53. +28,655 −0 SharedLibs/log4net.xml
  54. BIN SharedLibs/xunit.dll
  55. BIN SharedLibs/xunit.extensions.dll
  56. BIN Tools/xUnit/XUnit.NAntTasks.dll
  57. BIN Tools/xUnit/xunit.console.exe
  58. +21 −0 Tools/xUnit/xunit.console.exe.config
  59. BIN Tools/xUnit/xunit.dll
  60. BIN Tools/xUnit/xunit.extensions.dll
  61. +705 −0 Tools/xUnit/xunit.extensions.xml
  62. BIN Tools/xUnit/xunit.gui.exe
  63. BIN Tools/xUnit/xunit.installer.exe
  64. BIN Tools/xUnit/xunit.runner.msbuild.dll
  65. BIN Tools/xUnit/xunit.runner.resharper.dll
  66. BIN Tools/xUnit/xunit.runner.tdnet.dll
  67. BIN Tools/xUnit/xunit.runner.utility.dll
  68. +407 −0 Tools/xUnit/xunit.runner.utility.xml
  69. +2,132 −0 Tools/xUnit/xunit.xml
  70. BIN Tools/zip.exe
  71. +4 −0 acknowledgements.txt
  72. BIN ayende-open-source.snk
  73. +103 −0 default.ps1
  74. +25 −0 license.txt
  75. +311 −0 psake.ps1
  76. +40 −0 psake_ext.ps1
View
@@ -0,0 +1,11 @@
+*resharper.user
+[Dd]ebug/
+[Rr]elease/
+build/
+[Bb]in/
+[Oo]bj/
+*.suo
+*.sln.cache
+_ReSharper.*/
+AssemblyInfo.cs
+*.user
@@ -1,70 +0,0 @@
-namespace Rhino.ServiceBus.DistributedHashTableIntegration
-{
- using System.Linq;
- using Castle.Core;
- using Castle.MicroKernel;
- using Castle.MicroKernel.Facilities;
- using DistributedHashTable;
- using Exceptions;
- using Internal;
- using Messages;
- using Sagas;
-
- public class DhtClientSagaFacility : AbstractFacility
- {
- private void Kernel_OnComponentRegistered(string key, IHandler handler)
- {
- var model = handler.ComponentModel;
-
- var list = model.Implementation.GetInterfaces()
- .Where(x => x.IsGenericType &&
- x.IsGenericTypeDefinition == false &&
- x.GetGenericTypeDefinition() == typeof(ISaga<>))
- .ToList();
-
- if (list.Count == 0)
- return;
-
- if (list.Count > 1)
- {
- throw new InvalidUsageException(model.Implementation +
- " implements more than one ISaga<T>, this is not permitted");
- }
-
- var sagaType = list[0];
- var sagaStateType = sagaType.GetGenericArguments()[0];
-
- if (typeof(Orchestrates<MergeSagaState>).IsAssignableFrom(model.Implementation))
- {
- Kernel.AddComponent(
- "SagaPersister<" + model.Implementation + ">",
- typeof(ISagaPersister<>)
- .MakeGenericType(model.Implementation),
- typeof(DistributedHashTableSagaPersister<,>)
- .MakeGenericType(model.Implementation, sagaStateType)
- );
- }
- else if (typeof(SupportsOptimisticConcurrency).IsAssignableFrom(model.Implementation))
- {
- Kernel.AddComponent(
- "SagaPersister<" + model.Implementation + ">",
- typeof(ISagaPersister<>)
- .MakeGenericType(model.Implementation),
- typeof(OptimisticDistributedHashTableSagaPersister<,>)
- .MakeGenericType(model.Implementation, sagaStateType)
- );
- }
- else
- {
- throw new InvalidUsageException(
- "When using DHT for saga state, you must implement either SupportsOptimisticConcurrency or Orchestrates<MergeSagaState>");
- }
- }
-
- protected override void Init()
- {
- Kernel.ComponentRegistered += Kernel_OnComponentRegistered;
- Kernel.AddComponent("dht", typeof(IDistributedHashTableClient), typeof(DistributedHashTableClient));
- }
- }
-}
@@ -1,130 +0,0 @@
-using System;
-using System.IO;
-using Rhino.ServiceBus.Internal;
-using System.Linq;
-using Rhino.ServiceBus.Messages;
-
-namespace Rhino.ServiceBus.DistributedHashTableIntegration
-{
- using Castle.MicroKernel;
- using DistributedHashTable;
- using PersistentHashTable;
- using Sagas;
-
- public class DistributedHashTableSagaPersister<TSaga, TState> : ISagaPersister<TSaga>
- where TSaga : class, ISaga<TState>
- where TState : IVersionedSagaState
- {
- private readonly IDistributedHashTableClient distributedHashTable;
- private readonly ISagaStateMerger<TState> stateMerger;
- private readonly IMessageSerializer messageSerializer;
- private readonly IKernel kernel;
- private readonly IServiceBus bus;
- private readonly IReflection reflection;
-
- public DistributedHashTableSagaPersister(IDistributedHashTableClient distributedHashTable, ISagaStateMerger<TState> stateMerger, IMessageSerializer messageSerializer, IKernel kernel, IReflection reflection, IServiceBus bus)
- {
- this.distributedHashTable = distributedHashTable;
- this.bus = bus;
- this.stateMerger = stateMerger;
- this.messageSerializer = messageSerializer;
- this.kernel = kernel;
- this.reflection = reflection;
- }
-
-
- private static string CreateKey(Guid id)
- {
- return typeof(TSaga).FullName + "-" + id;
- }
-
-
- public TSaga Get(Guid id)
- {
- var values = distributedHashTable.Get(new[]
- {
- new GetRequest{Key = CreateKey(id)},
- }).First();
- if (values.Length == 0)
- return null;
- TState state;
- if (values.Length != 1)
- {
- var states = new TState[values.Length];
- for (var i = 0; i < values.Length; i++)
- {
- var value = values[i];
- using (var ms = new MemoryStream(value.Data))
- {
- object[] msgs = messageSerializer.Deserialize(ms);
- states[i] = (TState)msgs[0];
- states[i].ParentVersions = value.ParentVersions;
- states[i].Version = value.Version;
- }
- }
- state = stateMerger.Merge(states);
- state.ParentVersions = values
- .Select(x => x.Version)
- .ToArray();
- }
- else
- {
- using (var ms = new MemoryStream(values[0].Data))
- {
- object[] msgs = messageSerializer.Deserialize(ms);
- state = (TState)msgs[0];
- state.ParentVersions = new[] { values[0].Version };
- }
- }
- var saga = kernel.Resolve<TSaga>();
- saga.Id = id;
- reflection.Set(saga, "State", type => state);
- return saga;
- }
-
- public void Save(TSaga saga)
- {
- using (var message = new MemoryStream())
- {
- var state = (TState)reflection.Get(saga, "State");
- messageSerializer.Serialize(new object[] { state }, message);
- var putResults = distributedHashTable.Put(new[]
- {
- new PutRequest
- {
- Bytes = message.ToArray(),
- Key = CreateKey(saga.Id),
- ParentVersions = state.ParentVersions ?? new ValueVersion[0]
- },
- });
- if(putResults[0].ConflictExists)
- {
- bus.Send(bus.Endpoint, new MergeSagaState
- {
- CorrelationId = saga.Id
- });
- }
- }
- }
-
- public void Complete(TSaga saga)
- {
- var state = (TState) reflection.Get(saga, "State");
- var removed = distributedHashTable.Remove(new[]
- {
- new RemoveRequest
- {
- Key = CreateKey(saga.Id),
- ParentVersions = state.ParentVersions ?? new ValueVersion[0]
- },
- });
- if (removed[0] == false)
- {
- bus.Send(bus.Endpoint, new MergeSagaState
- {
- CorrelationId = saga.Id
- });
- }
- }
- }
-}
@@ -1,8 +0,0 @@
-namespace Rhino.ServiceBus.DistributedHashTableIntegration
-{
- public interface ISagaStateMerger<TState>
- where TState : IVersionedSagaState
- {
- TState Merge(TState[] states);
- }
-}
@@ -1,10 +0,0 @@
-namespace Rhino.ServiceBus.DistributedHashTableIntegration
-{
- using PersistentHashTable;
-
- public interface IVersionedSagaState
- {
- ValueVersion Version { get; set; }
- ValueVersion[] ParentVersions { get; set; }
- }
-}
@@ -1,102 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using Castle.MicroKernel;
-using Rhino.ServiceBus.Exceptions;
-using Rhino.ServiceBus.Internal;
-
-namespace Rhino.ServiceBus.DistributedHashTableIntegration
-{
- using DistributedHashTable;
- using PersistentHashTable;
- using Sagas;
-
- public class OptimisticDistributedHashTableSagaPersister<TSaga, TState> : ISagaPersister<TSaga>
- where TSaga : class, ISaga<TState>
- where TState : IVersionedSagaState
- {
- private readonly IDistributedHashTableClient distributedHashTable;
- private readonly IReflection reflection;
- private readonly IMessageSerializer messageSerializer;
- private readonly IKernel kernel;
-
- public OptimisticDistributedHashTableSagaPersister(IDistributedHashTableClient distributedHashTable, IReflection reflection, IMessageSerializer messageSerializer, IKernel kernel)
- {
- this.distributedHashTable = distributedHashTable;
- this.reflection = reflection;
- this.messageSerializer = messageSerializer;
- this.kernel = kernel;
- }
-
- private static string CreateKey(Guid id)
- {
- return typeof(TSaga).FullName + "-" + id;
- }
-
- public TSaga Get(Guid id)
- {
- var values = distributedHashTable.Get(new[]
- {
- new GetRequest {Key = CreateKey(id)},
- }).First();
-
- if(values.Length==0)
- return null;
-
- var value = values[0];
-
- TState state;
- using (var ms = new MemoryStream(value.Data))
- {
- var msgs = messageSerializer.Deserialize(ms);
- state = (TState)msgs[0];
- state.Version = value.Version;
- state.ParentVersions = value.ParentVersions;
- }
- var saga = kernel.Resolve<TSaga>();
- saga.Id = id;
- reflection.Set(saga, "State", type => state);
- return saga;
- }
-
- public void Save(TSaga saga)
- {
- using (var message = new MemoryStream())
- {
- var state = (TState)reflection.Get(saga, "State");
- messageSerializer.Serialize(new object[] { state }, message);
- var putResults = distributedHashTable.Put(new[]
- {
- new PutRequest
- {
- Bytes = message.ToArray(),
- Key = CreateKey(saga.Id),
- OptimisticConcurrency = true,
- ParentVersions = (state.Version != null ? new[] { state.Version } : new ValueVersion[0])
- },
- });
- if (putResults[0].ConflictExists)
- {
- throw new OptimisticConcurrencyException("Saga state is not the latest: " + saga.Id);
- }
- }
- }
-
- public void Complete(TSaga saga)
- {
- var state = (TState) reflection.Get(saga, "State");
- var removed = distributedHashTable.Remove(new[]
- {
- new RemoveRequest
- {
- Key = CreateKey(saga.Id),
- ParentVersions = new []{state.Version}
- },
- });
- if (removed[0] == false)
- {
- throw new OptimisticConcurrencyException("Saga state is not the latest: " + saga.Id);
- }
- }
- }
-}
Oops, something went wrong.

0 comments on commit 210d047

Please sign in to comment.