/// <summary> /// Rates a proposal based on the amount of time necessary to transfer and load the /// dataset to the machine that created the proposal. /// </summary> /// <param name="proposal">The proposal.</param> /// <returns> /// A positive number that describes the 'usefulness' of the proposal. Lower numbers are better. /// </returns> public static double Rate(this DatasetActivationProposal proposal) { if (proposal == null) { return(double.NaN); } // If the dataset takes up more disk space than the slave has available then we // won't distribute to that slave, otherwise the amount of disk space is irrelevant. double multiplier = (proposal.PercentageOfAvailableDisk > 100) ? double.PositiveInfinity : 1.0; // If the dataset takes up more than 80% of the maximum memory then // we won't distribute to that slave, otherwise the maximum memory is irrelevant // The 80% number is based on the idea that the OS and services will need some memory, // other than that is just a random high-ish number. multiplier *= (proposal.PercentageOfMaximumMemory >= 80) ? double.PositiveInfinity : 1.0; // If the datset takes up more space than the available memory then we get worse // performance but it should still be possible to load it. We have a small preference // for taking up more of the memory so that we favor machines that are better matched // to the current dataset. multiplier *= MemoryMultiplier(proposal.PercentageOfPhysicalMemory); // Turn the time into some floating point number, getting bigger as time gets bigger // but not linearly so that we can still handle large time spans. var timeValue = TimeToNumber(proposal.TransferTime + proposal.ActivationTime); return(timeValue * multiplier); }
public void CompareWithUnequalObjects() { var proposal1 = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(50), TransferTime = new TimeSpan(50), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var proposal2 = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(500), TransferTime = new TimeSpan(500), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var comparer = new DatasetActivationProposalComparer(); Assert.AreEqual(-1, comparer.Compare(proposal1, proposal2)); }
public void CompareWithSecondObjectNull() { var proposal = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(100), TransferTime = new TimeSpan(100), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var comparer = new DatasetActivationProposalComparer(); Assert.AreEqual(1, comparer.Compare(proposal, null)); }
public DistributionPlan( Func<DistributionPlan, CancellationToken, Action<int, string, bool>, Task<DatasetOnlineInformation>> activator, IDatasetOfflineInformation dataset, NetworkIdentifier machine, DatasetActivationProposal proposal) { { Enforce.Argument(() => activator); Enforce.Argument(() => dataset); Enforce.Argument(() => machine); Enforce.Argument(() => proposal); } m_Activator = activator; DistributionFor = dataset; MachineToDistributeTo = machine; Proposal = proposal; }
public DistributionPlan( Func <DistributionPlan, CancellationToken, Action <int, string, bool>, Task <DatasetOnlineInformation> > activator, IDatasetOfflineInformation dataset, NetworkIdentifier machine, DatasetActivationProposal proposal) { { Enforce.Argument(() => activator); Enforce.Argument(() => dataset); Enforce.Argument(() => machine); Enforce.Argument(() => proposal); } m_Activator = activator; DistributionFor = dataset; MachineToDistributeTo = machine; Proposal = proposal; }
private static DistributionPlan CreateNewDistributionPlan( DatasetActivationProposal proposal, IDatasetOfflineInformation offlineInfo, SystemDiagnostics systemDiagnostics) { var plan = new DistributionPlan( (p, t, r) => Task<DatasetOnlineInformation>.Factory.StartNew( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock<ISendCommandsToRemoteEndpoints>().Object, new Mock<INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t), offlineInfo, NetworkIdentifier.ForLocalMachine(), proposal); return plan; }
private static DistributionPlan CreateNewDistributionPlan( DatasetActivationProposal proposal, IDatasetOfflineInformation offlineInfo, SystemDiagnostics systemDiagnostics) { var plan = new DistributionPlan( (p, t, r) => Task <DatasetOnlineInformation> .Factory.StartNew( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock <ISendCommandsToRemoteEndpoints>().Object, new Mock <INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t, TaskCreationOptions.None, new CurrentThreadTaskScheduler()), offlineInfo, NetworkIdentifier.ForLocalMachine(), proposal); return(plan); }
public void ProposeDistributionFor() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offlineInfo = CreateOfflineInfo(new Mock <IPersistenceInformation>().Object); var result = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var localDistributor = new Mock <ICalculateDistributionParameters>(); { localDistributor.Setup(l => l.ProposeForLocalMachine(It.IsAny <ExpectedDatasetLoad>())) .Returns(result); } var communicationLayer = new Mock <ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is <ChannelType>(c => c == ChannelType.NamedPipe))) .Returns( new Tuple <EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.pipe://localhost/pipe"), new Uri("net.pipe://localhost/pipe/data"))); } var loader = new Mock <IDatasetActivator>(); var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); var uploads = new Mock <IStoreUploads>(); var distributor = new LocalDatasetDistributor( localDistributor.Object, loader.Object, commandHub.Object, notificationHub.Object, uploads.Object, (d, e, n) => { return(new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics)); }, communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); var request = new DatasetActivationRequest { DatasetToActivate = offlineInfo, ExpectedLoadPerMachine = new ExpectedDatasetLoad(), PreferredLocations = DistributionLocations.All, }; var plans = distributor.ProposeDistributionFor(request, new CancellationToken()); Assert.AreEqual(1, plans.Count()); var plan = plans.First(); Assert.IsTrue(ReferenceEquals(offlineInfo, plan.DistributionFor)); Assert.AreEqual(new NetworkIdentifier(result.Endpoint.OriginatesOnMachine()), plan.MachineToDistributeTo); Assert.IsTrue(ReferenceEquals(result, plan.Proposal)); }
public void ImplementPlan() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var loaderEndpoint = new EndpointId("myMachine:8080"); var proposal = new DatasetActivationProposal { Endpoint = loaderEndpoint, IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var filePath = @"c:\temp\myfile.txt"; var storage = new Mock<IPersistenceInformation>(); { storage.Setup(s => s.AsFile()) .Returns(new FileInfo(filePath)); } var plan = CreateNewDistributionPlan(proposal, CreateOfflineInfo(storage.Object), systemDiagnostics); var datasetEndpoint = new EndpointId("OtherMachine:5678"); var loaderCommands = new Mock<IDatasetActivationCommands>(); { loaderCommands.Setup(l => l.Activate(It.IsAny<EndpointId>(), It.IsAny<ChannelType>(), It.IsAny<Uri>(), It.IsAny<DatasetId>())) .Returns( Task.Factory.StartNew( () => datasetEndpoint, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())); } var applicationCommands = new Mock<IDatasetApplicationCommands>(); { applicationCommands.Setup(c => c.Load(It.IsAny<EndpointId>(), It.IsAny<UploadToken>())) .Returns( Task.Factory.StartNew( () => { }, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())); } var commandHub = new Mock<ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.HasCommandsFor(It.IsAny<EndpointId>())) .Returns(true); commandHub.Setup(h => h.CommandsFor<IDatasetActivationCommands>(It.IsAny<EndpointId>())) .Returns(loaderCommands.Object); commandHub.Setup(h => h.CommandsFor<IDatasetApplicationCommands>(It.IsAny<EndpointId>())) .Callback<EndpointId>(e => Assert.AreSame(datasetEndpoint, e)) .Returns(applicationCommands.Object); } var notifications = new Mock<IDatasetApplicationNotifications>(); var notificationHub = new Mock<INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny<EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor<IDatasetApplicationNotifications>(It.IsAny<EndpointId>())) .Callback<EndpointId>(e => Assert.AreSame(datasetEndpoint, e)) .Returns(notifications.Object); } var config = new Mock<IConfiguration>(); { config.Setup(c => c.HasValueFor(It.IsAny<ConfigurationKey>())) .Returns(false); } var communicationLayer = new Mock<ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is<ChannelType>(c => c == ChannelType.TcpIP))) .Returns( new Tuple<EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.tcp://localhost/tcp"), new Uri("net.tcp://localhost/tcp/data"))); } var distributor = new RemoteDatasetDistributor( config.Object, commandHub.Object, notificationHub.Object, new Mock<IStoreUploads>().Object, (d, e, n) => new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics), communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); // Add the remote endpoints commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( loaderEndpoint, new[] { typeof(IDatasetActivationCommands) })); Action<int, string, bool> progress = (p, m, e) => { }; var result = distributor.ImplementPlan(plan, new CancellationToken(), progress); result.Wait(); Assert.AreSame(datasetEndpoint, result.Result.Endpoint); Assert.AreSame(plan.DistributionFor.Id, result.Result.Id); Assert.AreSame(plan.MachineToDistributeTo, result.Result.RunsOn); }
public void ProposeDistributionFor() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offlineInfo = CreateOfflineInfo(new Mock<IPersistenceInformation>().Object); var result = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var loaderCommands = new Mock<IDatasetActivationCommands>(); { loaderCommands.Setup(l => l.ProposeFor(It.IsAny<ExpectedDatasetLoad>())) .Returns( Task.Factory.StartNew( () => result, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())) .Verifiable(); } var commandHub = new Mock<ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.CommandsFor<IDatasetActivationCommands>(It.IsAny<EndpointId>())) .Returns(loaderCommands.Object); } var notificationHub = new Mock<INotifyOfRemoteEndpointEvents>(); var offlimitsMachines = new SortedList<string, object> { { "someKeyStuff", "otherMachine" } }; var config = new Mock<IConfiguration>(); { config.Setup(c => c.HasValueFor(It.IsAny<ConfigurationKey>())) .Returns(true); config.Setup(c => c.Value<IDictionary<string, object>>(It.IsAny<ConfigurationKey>())) .Returns(offlimitsMachines); } var communicationLayer = new Mock<ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is<ChannelType>(c => c == ChannelType.TcpIP))) .Returns( new Tuple<EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.tcp://localhost/tcp"), new Uri("net.tcp://localhost/tcp/data"))); } var distributor = new RemoteDatasetDistributor( config.Object, commandHub.Object, notificationHub.Object, new Mock<IStoreUploads>().Object, (d, e, n) => new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics), communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); // Add the remote endpoints var forbiddenMachineId = new EndpointId("otherMachine:8080"); commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( forbiddenMachineId, new[] { typeof(IDatasetActivationCommands) })); var legalMachineId = new EndpointId("myMachine:8080"); commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( legalMachineId, new[] { typeof(IDatasetActivationCommands) })); var request = new DatasetActivationRequest { DatasetToActivate = offlineInfo, ExpectedLoadPerMachine = new ExpectedDatasetLoad(), PreferredLocations = DistributionLocations.All, }; var plans = distributor.ProposeDistributionFor(request, new CancellationToken()); var listPlans = plans.ToList(); Assert.AreEqual(1, listPlans.Count()); var plan = listPlans[0]; Assert.IsTrue(ReferenceEquals(offlineInfo, plan.DistributionFor)); Assert.AreEqual(new NetworkIdentifier(result.Endpoint.OriginatesOnMachine()), plan.MachineToDistributeTo); Assert.IsTrue(ReferenceEquals(result, plan.Proposal)); loaderCommands.Verify(l => l.ProposeFor(It.IsAny<ExpectedDatasetLoad>()), Times.Once()); }
public void ProposeDistributionFor() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offlineInfo = CreateOfflineInfo(new Mock<IPersistenceInformation>().Object); var result = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var localDistributor = new Mock<ICalculateDistributionParameters>(); { localDistributor.Setup(l => l.ProposeForLocalMachine(It.IsAny<ExpectedDatasetLoad>())) .Returns(result); } var communicationLayer = new Mock<ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is<ChannelType>(c => c == ChannelType.NamedPipe))) .Returns( new Tuple<EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.pipe://localhost/pipe"), new Uri("net.pipe://localhost/pipe/data"))); } var loader = new Mock<IDatasetActivator>(); var commandHub = new Mock<ISendCommandsToRemoteEndpoints>(); var notificationHub = new Mock<INotifyOfRemoteEndpointEvents>(); var uploads = new Mock<IStoreUploads>(); var distributor = new LocalDatasetDistributor( localDistributor.Object, loader.Object, commandHub.Object, notificationHub.Object, uploads.Object, (d, e, n) => { return new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics); }, communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); var request = new DatasetActivationRequest { DatasetToActivate = offlineInfo, ExpectedLoadPerMachine = new ExpectedDatasetLoad(), PreferredLocations = DistributionLocations.All, }; var plans = distributor.ProposeDistributionFor(request, new CancellationToken()); Assert.AreEqual(1, plans.Count()); var plan = plans.First(); Assert.IsTrue(ReferenceEquals(offlineInfo, plan.DistributionFor)); Assert.AreEqual(new NetworkIdentifier(result.Endpoint.OriginatesOnMachine()), plan.MachineToDistributeTo); Assert.IsTrue(ReferenceEquals(result, plan.Proposal)); }
public void ProposeDistributionFor() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offlineInfo = CreateOfflineInfo(new Mock <IPersistenceInformation>().Object); var result = new DatasetActivationProposal { Endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var loaderCommands = new Mock <IDatasetActivationCommands>(); { loaderCommands.Setup(l => l.ProposeFor(It.IsAny <ExpectedDatasetLoad>())) .Returns( Task.Factory.StartNew( () => result, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())) .Verifiable(); } var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.CommandsFor <IDatasetActivationCommands>(It.IsAny <EndpointId>())) .Returns(loaderCommands.Object); } var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); var offlimitsMachines = new SortedList <string, object> { { "someKeyStuff", "otherMachine" } }; var config = new Mock <IConfiguration>(); { config.Setup(c => c.HasValueFor(It.IsAny <ConfigurationKey>())) .Returns(true); config.Setup(c => c.Value <IDictionary <string, object> >(It.IsAny <ConfigurationKey>())) .Returns(offlimitsMachines); } var communicationLayer = new Mock <ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is <ChannelType>(c => c == ChannelType.TcpIP))) .Returns( new Tuple <EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.tcp://localhost/tcp"), new Uri("net.tcp://localhost/tcp/data"))); } var distributor = new RemoteDatasetDistributor( config.Object, commandHub.Object, notificationHub.Object, new Mock <IStoreUploads>().Object, (d, e, n) => new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics), communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); // Add the remote endpoints var forbiddenMachineId = new EndpointId("otherMachine:8080"); commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( forbiddenMachineId, new[] { typeof(IDatasetActivationCommands) })); var legalMachineId = new EndpointId("myMachine:8080"); commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( legalMachineId, new[] { typeof(IDatasetActivationCommands) })); var request = new DatasetActivationRequest { DatasetToActivate = offlineInfo, ExpectedLoadPerMachine = new ExpectedDatasetLoad(), PreferredLocations = DistributionLocations.All, }; var plans = distributor.ProposeDistributionFor(request, new CancellationToken()); var listPlans = plans.ToList(); Assert.AreEqual(1, listPlans.Count()); var plan = listPlans[0]; Assert.IsTrue(ReferenceEquals(offlineInfo, plan.DistributionFor)); Assert.AreEqual(new NetworkIdentifier(result.Endpoint.OriginatesOnMachine()), plan.MachineToDistributeTo); Assert.IsTrue(ReferenceEquals(result, plan.Proposal)); loaderCommands.Verify(l => l.ProposeFor(It.IsAny <ExpectedDatasetLoad>()), Times.Once()); }
public void ImplementPlan() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var loaderEndpoint = new EndpointId("myMachine:8080"); var proposal = new DatasetActivationProposal { Endpoint = loaderEndpoint, IsAvailable = true, ActivationTime = new TimeSpan(0, 1, 0), TransferTime = new TimeSpan(0, 1, 0), PercentageOfAvailableDisk = 50, PercentageOfMaximumMemory = 50, PercentageOfPhysicalMemory = 50, }; var filePath = @"c:\temp\myfile.txt"; var storage = new Mock <IPersistenceInformation>(); { storage.Setup(s => s.AsFile()) .Returns(new FileInfo(filePath)); } var plan = CreateNewDistributionPlan(proposal, CreateOfflineInfo(storage.Object), systemDiagnostics); var datasetEndpoint = new EndpointId("OtherMachine:5678"); var loaderCommands = new Mock <IDatasetActivationCommands>(); { loaderCommands.Setup(l => l.Activate(It.IsAny <EndpointId>(), It.IsAny <ChannelType>(), It.IsAny <Uri>(), It.IsAny <DatasetId>())) .Returns( Task.Factory.StartNew( () => datasetEndpoint, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())); } var applicationCommands = new Mock <IDatasetApplicationCommands>(); { applicationCommands.Setup(c => c.Load(It.IsAny <EndpointId>(), It.IsAny <UploadToken>())) .Returns( Task.Factory.StartNew( () => { }, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())); } var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.HasCommandsFor(It.IsAny <EndpointId>())) .Returns(true); commandHub.Setup(h => h.CommandsFor <IDatasetActivationCommands>(It.IsAny <EndpointId>())) .Returns(loaderCommands.Object); commandHub.Setup(h => h.CommandsFor <IDatasetApplicationCommands>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(datasetEndpoint, e)) .Returns(applicationCommands.Object); } var notifications = new Mock <IDatasetApplicationNotifications>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(datasetEndpoint, e)) .Returns(notifications.Object); } var config = new Mock <IConfiguration>(); { config.Setup(c => c.HasValueFor(It.IsAny <ConfigurationKey>())) .Returns(false); } var communicationLayer = new Mock <ICommunicationLayer>(); { communicationLayer.Setup(s => s.LocalConnectionFor(It.Is <ChannelType>(c => c == ChannelType.TcpIP))) .Returns( new Tuple <EndpointId, Uri, Uri>( EndpointIdExtensions.CreateEndpointIdForCurrentProcess(), new Uri("net.tcp://localhost/tcp"), new Uri("net.tcp://localhost/tcp/data"))); } var distributor = new RemoteDatasetDistributor( config.Object, commandHub.Object, notificationHub.Object, new Mock <IStoreUploads>().Object, (d, e, n) => new DatasetOnlineInformation( d, e, n, commandHub.Object, notificationHub.Object, systemDiagnostics), communicationLayer.Object, systemDiagnostics, new CurrentThreadTaskScheduler()); // Add the remote endpoints commandHub.Raise( h => h.OnEndpointSignedIn += null, new CommandSetAvailabilityEventArgs( loaderEndpoint, new[] { typeof(IDatasetActivationCommands) })); Action <int, string, bool> progress = (p, m, e) => { }; var result = distributor.ImplementPlan(plan, new CancellationToken(), progress); result.Wait(); Assert.AreSame(datasetEndpoint, result.Result.Endpoint); Assert.AreSame(plan.DistributionFor.Id, result.Result.Id); Assert.AreSame(plan.MachineToDistributeTo, result.Result.RunsOn); }