コード例 #1
0
        /// <summary>
        /// Activates the dataset.
        /// </summary>
        /// <param name="preferredLocation">
        /// Indicates a preferred machine location for the dataset to be distributed to.
        /// </param>
        /// <param name="machineSelector">
        ///     The function that selects the most suitable machine for the dataset to run on.
        /// </param>
        /// <remarks>
        /// Note that the <paramref name="preferredLocation"/> is
        /// only a suggestion. The loader may decide to ignore the suggestion if there is a distribution
        /// plan that is better suited to the contents of the dataset.
        /// </remarks>
        public void Activate(
            DistributionLocations preferredLocation,
            Func <DistributionSuggestionProxy[], DistributionSuggestionProxy> machineSelector)
        {
            var selector = new MachineSelectorFacade(machineSelector);

            m_Dataset.Activate(preferredLocation, selector);
        }
コード例 #2
0
        /// <summary>
        /// Activates the dataset.
        /// </summary>
        /// <param name="preferredLocation">
        /// Indicates a preferred machine location for the dataset to be distributed to.
        /// </param>
        /// <param name="machineSelector">
        ///     The function that selects the most suitable machine for the dataset to run on.
        /// </param>
        /// <remarks>
        /// Note that the <paramref name="preferredLocation"/> is
        /// only a suggestion. The loader may decide to ignore the suggestion if there is a distribution
        /// plan that is better suited to the contents of the dataset.
        /// </remarks>
        public void Activate(
            DistributionLocations preferredLocation,
            MachineSelectorFacade machineSelector)
        {
            Func <IEnumerable <DistributionSuggestion>, SelectedProposal> func =
                enumerable =>
            {
                var selection = enumerable.ToList();
                var proxies   = selection.Select(s => new DistributionSuggestionProxy(s)).ToArray();
                var result    = machineSelector.SelectFrom(proxies);

                var selectedPlan = selection.Find(s => s.Plan.MachineToDistributeTo.Equals(result.MachineToDistributeTo));
                return(new SelectedProposal(selectedPlan.Plan));
            };

            // CancellationToken is not serializable hence ...
            var token = new CancellationTokenSource();

            m_Dataset.Activate(preferredLocation, func, token.Token)
            .ContinueWith(t => token.Dispose());
        }