Ejemplo n.º 1
0
        bool DynTestCanStart(StartDependencyImpact impact)
        {
            DynamicPropagation p = DynGetPropagationInfo();

            Debug.Assert(p != null);
            return(p.TestCanStart(impact));
        }
Ejemplo n.º 2
0
            internal bool TestCanStart(StartDependencyImpact impact)
            {
                Debug.Assert(Service.DynamicStatus == null && Service.FinalConfigSolvedStatus == SolvedConfigurationStatus.Runnable);
                Debug.Assert(impact != StartDependencyImpact.Unknown);

                if (TheOnlyPlugin != null)
                {
                    if (!TheOnlyPlugin.DynamicCanStart(impact))
                    {
                        return(false);
                    }
                }
                else
                {
                    foreach (var s in GetExcludedServices(impact))
                    {
                        if (s.DynamicStatus != null && s.DynamicStatus.Value >= RunningStatus.Running)
                        {
                            return(false);
                        }
                    }
                    foreach (var s in GetIncludedServices(impact, false))
                    {
                        if (s.DynamicStatus != null && s.DynamicStatus.Value <= RunningStatus.Stopped)
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
Ejemplo n.º 3
0
 internal void OnRemoved()
 {
     Debug.Assert(_statusReason != null);
     _statusReason = null;
     _status       = ConfigurationStatus.Optional;
     _impact       = StartDependencyImpact.Unknown;
 }
Ejemplo n.º 4
0
            internal void PropagateStart()
            {
                Debug.Assert(Service.DynamicStatus != null && Service.DynamicStatus.Value >= RunningStatus.Running);

                StartDependencyImpact impact = Service.ConfigSolvedImpact;

                if (TheOnlyPlugin != null)
                {
                    TheOnlyPlugin.DynamicStartBy(impact, PluginRunningStatusReason.StartedByRunningService);
                }
                else if (TheOnlyService != null)
                {
                    TheOnlyService.DynamicStartBy(ServiceRunningStatusReason.StartedByPropagation);
                }
                else
                {
                    foreach (var s in GetExcludedServices(impact))
                    {
                        Debug.Assert(s.DynamicStatus == null || s.DynamicStatus.Value <= RunningStatus.Stopped);
                        if (s.DynamicStatus == null)
                        {
                            s.DynamicStopBy(ServiceRunningStatusReason.StoppedByPropagation);
                        }
                    }
                    foreach (var s in GetIncludedServices(impact, false))
                    {
                        Debug.Assert(s.DynamicStatus == null || s.DynamicStatus.Value >= RunningStatus.Running);
                        if (s.DynamicStatus == null)
                        {
                            s.DynamicStartBy(ServiceRunningStatusReason.StartedByPropagation);
                        }
                    }
                }
            }
Ejemplo n.º 5
0
 public bool DynamicStartByCommand( StartDependencyImpact impact )
 {
     if( _dynamicStatus != null ) return _dynamicStatus.Value >= RunningStatus.Running;
     if( impact == StartDependencyImpact.Unknown ) impact = ConfigSolvedImpact;
     if( !DynTestCanStart( impact ) ) return false;
     DynamicStartBy( ServiceRunningStatusReason.StartedByCommand );
     return true;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// A FinalConfigurationItem is an immutable object that displays the latest configuration of an item.
        /// </summary>
        public FinalConfigurationItem( string serviceOrPluginFullName, ConfigurationStatus status, StartDependencyImpact impact = StartDependencyImpact.Unknown )
        {
            Debug.Assert( !String.IsNullOrEmpty( serviceOrPluginFullName ) );

            _serviceOrPluginFullName = serviceOrPluginFullName;
            _status = status;
            _impact = impact;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// A FinalConfigurationItem is an immutable object that displays the latest configuration of an item.
        /// </summary>
        public FinalConfigurationItem(string serviceOrPluginFullName, ConfigurationStatus status, StartDependencyImpact impact = StartDependencyImpact.Unknown)
        {
            Debug.Assert(!String.IsNullOrEmpty(serviceOrPluginFullName));

            _serviceOrPluginFullName = serviceOrPluginFullName;
            _status = status;
            _impact = impact;
        }
Ejemplo n.º 8
0
 public SolvedItemSnapshot(IYodiiItemData item)
 {
     _disabledReason       = item.DisabledReason;
     _runningStatus        = item.DynamicStatus;
     _configOriginalStatus = item.ConfigOriginalStatus;
     _configSolvedStatus   = item.ConfigSolvedStatus;
     _configOriginalImpact = item.ConfigOriginalImpact;
     _configSolvedImpact   = item.RawConfigSolvedImpact;
 }
Ejemplo n.º 9
0
 public SolvedItemSnapshot( IYodiiItemData item )
 {
     _disabledReason = item.DisabledReason;
     _runningStatus = item.DynamicStatus;
     _configOriginalStatus = item.ConfigOriginalStatus;
     _configSolvedStatus = item.ConfigSolvedStatus;
     _configOriginalImpact = item.ConfigOriginalImpact;
     _configSolvedImpact = item.RawConfigSolvedImpact;
 }
Ejemplo n.º 10
0
        public IYodiiEngineResult Start(string callerKey, StartDependencyImpact impact = StartDependencyImpact.Unknown)
        {
            if (!_capability.CanStartWith(impact))
            {
                throw new InvalidOperationException("You must call Capability.CanStart with the wanted impact and ensure that it returns true before calling Start.");
            }
            YodiiCommand command = new YodiiCommand(true, _fullName, IsPlugin, impact, callerKey);

            return(_engine.AddYodiiCommand(command));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new YodiiCommand.
 /// </summary>
 /// <param name="start">True to start the plugin or the service, false to stop it.</param>
 /// <param name="fullName">The plugin or service name.</param>
 /// <param name="isPlugin">True if command is for a plugin, false for a service.</param>
 /// <param name="impact">Dependency impact when starting. Must be <see cref="StartDependencyImpact.Unknown"/> when <paramref name="start"/> is false.</param>
 /// <param name="callerKey">Calling object identifier. Can be null: it is normalized to the empty string.</param>
 public YodiiCommand( bool start, string fullName, bool isPlugin, StartDependencyImpact impact, string callerKey )
 {
     if( !start && impact != StartDependencyImpact.Unknown ) throw new ArgumentException( "Impact must be None when stopping a plugin or a service.", "impact" );
     if( String.IsNullOrEmpty( fullName ) ) throw new ArgumentException( "A service or plugin name can not be null or empty.", "fullName" );
     _callerKey = callerKey ?? String.Empty;
     _start = start;
     _impact = impact;
     _fullName = fullName;
     _isPlugin = isPlugin;
 }
 bool ComputeStartableFor( IServiceDependentObject o, StartDependencyImpact impact )
 {
     foreach( var s in o.GetIncludedServices( impact, false ) )
     {
         if( s.Disabled ) return false;
     }
     foreach( var s in o.GetExcludedServices( impact ) )
     {
         if( s.FinalConfigSolvedStatus == SolvedConfigurationStatus.Running ) return false;
     }
     return true;
 }
Ejemplo n.º 13
0
 internal bool DynamicCanStart(StartDependencyImpact impact)
 {
     if (_dynamicStatus != null)
     {
         return(_dynamicStatus.Value >= RunningStatus.Running);
     }
     if (impact == StartDependencyImpact.Unknown)
     {
         impact = ConfigSolvedImpact;
     }
     return(DynTestCanStart(impact));
 }
Ejemplo n.º 14
0
            public IEnumerable <ServiceData> GetExcludedServices(StartDependencyImpact impact)
            {
                if (_theOnlyPlugin != null)
                {
                    return(_theOnlyPlugin.GetExcludedServices(impact));
                }
                if (_theOnlyService != null)
                {
                    return(GetPropagationInfo(_theOnlyService).GetExcludedServices(impact));
                }

                IEnumerable <ServiceData> exclExist = _exclServices[(int)impact - 1];

                if (exclExist == null)
                {
                    HashSet <ServiceData> excl = null;
                    ServiceData           spec = Service.FirstSpecialization;
                    while (spec != null)
                    {
                        BasePropagation prop = GetPropagationInfo(spec);
                        if (prop != null)
                        {
                            if (excl == null)
                            {
                                excl = new HashSet <ServiceData>(prop.GetExcludedServices(impact));
                            }
                            else
                            {
                                excl.IntersectWith(prop.GetExcludedServices(impact));
                            }
                        }
                        spec = spec.NextSpecialization;
                    }
                    PluginData p = Service.FirstPlugin;
                    while (p != null)
                    {
                        if (!p.Disabled)
                        {
                            if (excl == null)
                            {
                                excl = new HashSet <ServiceData>(p.GetExcludedServices(impact));
                            }
                            else
                            {
                                excl.IntersectWith(p.GetExcludedServices(impact));
                            }
                        }
                        p = p.NextPluginForService;
                    }
                    _exclServices[(int)impact - 1] = exclExist = excl ?? Enumerable.Empty <ServiceData>();
                }
                return(exclExist);
            }
Ejemplo n.º 15
0
        internal ConfigurationItem( ConfigurationLayer configurationLayer, string serviceOrPluginFullName, ConfigurationStatus initialStatus, StartDependencyImpact initialImpact, string initialStatusReason = "")
        {
            Debug.Assert( !String.IsNullOrEmpty( serviceOrPluginFullName ) );
            Debug.Assert( configurationLayer != null );
            Debug.Assert( initialStatusReason != null );

            _owner = configurationLayer;
            _serviceOrPluginFullName = serviceOrPluginFullName;
            _status = initialStatus;
            _impact = initialImpact;
            _statusReason = initialStatusReason;
        }
Ejemplo n.º 16
0
        internal ConfigurationItem(ConfigurationLayer configurationLayer, string serviceOrPluginFullName, ConfigurationStatus initialStatus, StartDependencyImpact initialImpact, string initialStatusReason = "")
        {
            Debug.Assert(!String.IsNullOrEmpty(serviceOrPluginFullName));
            Debug.Assert(configurationLayer != null);
            Debug.Assert(initialStatusReason != null);

            _owner = configurationLayer;
            _serviceOrPluginFullName = serviceOrPluginFullName;
            _status       = initialStatus;
            _impact       = initialImpact;
            _statusReason = initialStatusReason;
        }
Ejemplo n.º 17
0
 internal bool DynamicCanStart(StartDependencyImpact impact)
 {
     if (_dynamicStatus != null)
     {
         return(_dynamicStatus.Value >= RunningStatus.Running);
     }
     Debug.Assert(_dynamicTotalAvailablePluginsCount != 0);
     if (impact == StartDependencyImpact.Unknown)
     {
         impact = ConfigSolvedImpact;
     }
     return(DynTestCanStart(impact));
 }
Ejemplo n.º 18
0
 public bool CanStartWith( StartDependencyImpact impact )
 {
     if( impact != StartDependencyImpact.Unknown && (impact & StartDependencyImpact.IsTryOnly) == 0 )
     {
         switch( impact )
         {
             case StartDependencyImpact.FullStart: return _flags.CanStartWithFullStart;
             case StartDependencyImpact.StartRecommended: return _flags.CanStartWithStartRecommended;
             case StartDependencyImpact.StopOptionalAndRunnable: return _flags.CanStartWithStopOptionalAndRunnable;
             case StartDependencyImpact.FullStop: return _flags.CanStartWithFullStop;
         }
     }
     return _flags.CanStart;
 }
Ejemplo n.º 19
0
        protected LiveYodiiItemInfo( YodiiEngine engine, IYodiiItemData d, string fullName )
        {
            Debug.Assert( d != null && engine != null && !String.IsNullOrEmpty( fullName ) );

            _engine = engine;
            _capability = new LiveRunCapability( d.FinalConfigSolvedStatus, d.FinalStartableStatus );
            _fullName = fullName;
            Debug.Assert( d.DynamicStatus != null );
            _disabledReason = d.DisabledReason;
            _runningStatus = d.DynamicStatus.Value;
            _configOriginalStatus = d.ConfigOriginalStatus;
            _configSolvedStatus = d.ConfigSolvedStatus;
            _configOriginalImpact = d.ConfigOriginalImpact;
            _configSolvedImpact = d.RawConfigSolvedImpact;
        }
Ejemplo n.º 20
0
        public FinalConfigStartableStatus(IServiceDependentObject o)
        {
            Debug.Assert(o.FinalConfigSolvedStatus != SolvedConfigurationStatus.Disabled);
            Debug.Assert(ComputeStartableFor(o, StartDependencyImpact.Minimal));

            StartDependencyImpact config = o.ConfigSolvedImpact;

            Debug.Assert(ComputeStartableFor(o, config));
            Debug.Assert(ComputeStartableFor(o, StartDependencyImpact.Minimal));

            CanStartWithFullStop = config != StartDependencyImpact.FullStop ? ComputeStartableFor(o, StartDependencyImpact.FullStop) : true;
            CallableWithStopOptionalAndRunnable = config != StartDependencyImpact.StopOptionalAndRunnable ? ComputeStartableFor(o, StartDependencyImpact.StopOptionalAndRunnable) : true;
            CallableWithStartRecommended        = config != StartDependencyImpact.StartRecommended ? ComputeStartableFor(o, StartDependencyImpact.StartRecommended) : true;
            CallableWithFullStart = config != StartDependencyImpact.FullStart ? ComputeStartableFor(o, StartDependencyImpact.FullStart) : true;
        }
Ejemplo n.º 21
0
        protected LiveYodiiItemInfo(YodiiEngine engine, IYodiiItemData d, string fullName)
        {
            Debug.Assert(d != null && engine != null && !String.IsNullOrEmpty(fullName));

            _engine     = engine;
            _capability = new LiveRunCapability(d.FinalConfigSolvedStatus, d.FinalStartableStatus);
            _fullName   = fullName;
            Debug.Assert(d.DynamicStatus != null);
            _disabledReason       = d.DisabledReason;
            _runningStatus        = d.DynamicStatus.Value;
            _configOriginalStatus = d.ConfigOriginalStatus;
            _configSolvedStatus   = d.ConfigSolvedStatus;
            _configOriginalImpact = d.ConfigOriginalImpact;
            _configSolvedImpact   = d.RawConfigSolvedImpact;
        }
Ejemplo n.º 22
0
        public IYodiiEngineResult SetImpact(StartDependencyImpact newImpact)
        {
            IYodiiEngineResult result = _owner.OnConfigurationItemChanging(this, new FinalConfigurationItem(_serviceOrPluginFullName, _status, _impact));

            if (result.Success)
            {
                _impact = newImpact;
                NotifyPropertyChanged("Impact");
                if (_owner.ConfigurationManager != null)
                {
                    _owner.ConfigurationManager.OnConfigurationChanged();
                }
            }
            return(result);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new YodiiCommand.
 /// </summary>
 /// <param name="start">True to start the plugin or the service, false to stop it.</param>
 /// <param name="fullName">The plugin or service name.</param>
 /// <param name="isPlugin">True if command is for a plugin, false for a service.</param>
 /// <param name="impact">Dependency impact when starting. Must be <see cref="StartDependencyImpact.Unknown"/> when <paramref name="start"/> is false.</param>
 /// <param name="callerKey">Calling object identifier. Can be null: it is normalized to the empty string.</param>
 public YodiiCommand(bool start, string fullName, bool isPlugin, StartDependencyImpact impact, string callerKey)
 {
     if (!start && impact != StartDependencyImpact.Unknown)
     {
         throw new ArgumentException("Impact must be None when stopping a plugin or a service.", "impact");
     }
     if (String.IsNullOrEmpty(fullName))
     {
         throw new ArgumentException("A service or plugin name can not be null or empty.", "fullName");
     }
     _callerKey = callerKey ?? String.Empty;
     _start     = start;
     _impact    = impact;
     _fullName  = fullName;
     _isPlugin  = isPlugin;
 }
Ejemplo n.º 24
0
        public bool CanStartWith(StartDependencyImpact impact)
        {
            if (impact != StartDependencyImpact.Unknown && (impact & StartDependencyImpact.IsTryOnly) == 0)
            {
                switch (impact)
                {
                case StartDependencyImpact.FullStart: return(_flags.CanStartWithFullStart);

                case StartDependencyImpact.StartRecommended: return(_flags.CanStartWithStartRecommended);

                case StartDependencyImpact.StopOptionalAndRunnable: return(_flags.CanStartWithStopOptionalAndRunnable);

                case StartDependencyImpact.FullStop: return(_flags.CanStartWithFullStop);
                }
            }
            return(_flags.CanStart);
        }
Ejemplo n.º 25
0
 public bool DynamicStartByCommand(StartDependencyImpact impact)
 {
     if (_dynamicStatus != null)
     {
         return(_dynamicStatus.Value >= RunningStatus.Running);
     }
     if (impact == StartDependencyImpact.Unknown)
     {
         impact = ConfigSolvedImpact;
     }
     if (!DynTestCanStart(impact))
     {
         return(false);
     }
     DynamicStartBy(ServiceRunningStatusReason.StartedByCommand);
     return(true);
 }
Ejemplo n.º 26
0
 bool ComputeStartableFor(IServiceDependentObject o, StartDependencyImpact impact)
 {
     foreach (var s in o.GetIncludedServices(impact, false))
     {
         if (s.Disabled)
         {
             return(false);
         }
     }
     foreach (var s in o.GetExcludedServices(impact))
     {
         if (s.FinalConfigSolvedStatus == SolvedConfigurationStatus.Running)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 27
0
 bool DynTestCanStart(StartDependencyImpact impact)
 {
     foreach (var s in GetExcludedServices(impact))
     {
         if (s.DynamicStatus != null && s.DynamicStatus.Value >= RunningStatus.Running)
         {
             return(false);
         }
     }
     foreach (var s in GetIncludedServices(impact, false))
     {
         if (s.DynamicStatus != null && s.DynamicStatus.Value <= RunningStatus.Stopped)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 28
0
        private void StartLiveItemExecute(object obj)
        {
            if (!CanStartLiveItem(obj))
            {
                return;
            }

            if (LiveObject.RunningStatus == RunningStatus.Stopped)
            {
                StartDependencyImpact impact = StartDependencyImpact.Unknown;
                if (obj != null && obj is StartDependencyImpact)
                {
                    impact = (StartDependencyImpact)obj;
                }

                LiveObject.Start(impact);
            }
        }
Ejemplo n.º 29
0
        internal void DynamicStartBy(StartDependencyImpact impact, PluginRunningStatusReason reason)
        {
            Debug.Assert(_dynamicStatus == null || _dynamicStatus.Value >= RunningStatus.Running);
            if (_dynamicStatus == null)
            {
                _dynamicStatus = RunningStatus.Running;
                _dynamicReason = reason;
            }
            if (Service != null)
            {
                Service.OnDirectPluginStarted(this);
            }

            foreach (var sRef in PluginInfo.ServiceReferences)
            {
                ServiceData s = _solver.FindExistingService(sRef.Reference.ServiceFullName);
                s.DynamicStartByDependency(impact, sRef.Requirement);
            }
        }
Ejemplo n.º 30
0
        private bool CanStartLiveItem(object obj)
        {
            if (LiveObject == null)
            {
                return(false);
            }
            if (LiveObject.RunningStatus == RunningStatus.Disabled || LiveObject.RunningStatus == RunningStatus.RunningLocked || LiveObject.RunningStatus == RunningStatus.Running)
            {
                return(false);
            }

            StartDependencyImpact impact = StartDependencyImpact.Unknown;

            if (obj != null && obj is StartDependencyImpact)
            {
                impact = (StartDependencyImpact)obj;
            }

            return(LiveObject.Capability.CanStartWith(impact));
        }
Ejemplo n.º 31
0
        public PluginRunningStatusReason GetStoppedReasonForStoppedReference(DependencyRequirement requirement)
        {
            StartDependencyImpact impact = _configSolvedImpact;

            switch (requirement)
            {
            case DependencyRequirement.Running: return(PluginRunningStatusReason.StoppedByRunningReference);

            case DependencyRequirement.RunnableRecommended:
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    return(PluginRunningStatusReason.StoppedByRunnableRecommendedReference);
                }
                break;

            case DependencyRequirement.Runnable:
                if (impact == StartDependencyImpact.FullStart)
                {
                    return(PluginRunningStatusReason.StoppedByRunnableReference);
                }
                break;

            case DependencyRequirement.OptionalRecommended:
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    return(PluginRunningStatusReason.StoppedByOptionalRecommendedReference);
                }
                break;

            case DependencyRequirement.Optional:
                if (impact == StartDependencyImpact.FullStart)
                {
                    return(PluginRunningStatusReason.StoppedByOptionalReference);
                }
                break;
            }
            return(PluginRunningStatusReason.None);
        }
Ejemplo n.º 32
0
        ServiceData(IServiceInfo s, ConfigurationStatus serviceStatus, StartDependencyImpact impact)
        {
            _backReferences       = new List <BackReference>();
            ServiceInfo           = s;
            ConfigOriginalStatus  = serviceStatus;
            RawConfigSolvedImpact = ConfigOriginalImpact = impact;
            if (RawConfigSolvedImpact == StartDependencyImpact.Unknown && Generalization != null)
            {
                RawConfigSolvedImpact = Generalization.ConfigSolvedImpact;
            }
            _configSolvedImpact = RawConfigSolvedImpact;
            if (_configSolvedImpact == StartDependencyImpact.Unknown || (_configSolvedImpact & StartDependencyImpact.IsTryOnly) != 0)
            {
                _configSolvedImpact = StartDependencyImpact.Minimal;
            }

            if (ConfigSolvedImpact == StartDependencyImpact.Unknown)
            {
                if (Generalization != null)
                {
                    _configSolvedImpact = Generalization.ConfigOriginalImpact;
                }
            }
        }
Ejemplo n.º 33
0
            public IEnumerable <ServiceData> GetIncludedServices(StartDependencyImpact impact, bool forRunnableStatus)
            {
                if (_theOnlyPlugin != null)
                {
                    return(_theOnlyPlugin.GetIncludedServices(impact, forRunnableStatus));
                }
                if (_theOnlyService != null)
                {
                    return(GetPropagationInfo(_theOnlyService).GetIncludedServices(impact, forRunnableStatus));
                }

                int iImpact = (int)impact;

                if (forRunnableStatus)
                {
                    iImpact *= 2;
                }
                --iImpact;

                IEnumerable <ServiceData> inclExist = _inclServices[iImpact];

                if (inclExist == null)
                {
                    HashSet <ServiceData> incl = null;
                    ServiceData           spec = Service.FirstSpecialization;
                    while (spec != null)
                    {
                        BasePropagation prop = GetPropagationInfo(spec);
                        if (prop != null)
                        {
                            if (incl == null)
                            {
                                incl = new HashSet <ServiceData>(prop.GetIncludedServices(impact, forRunnableStatus));
                            }
                            else
                            {
                                incl.IntersectWith(prop.GetIncludedServices(impact, forRunnableStatus));
                            }
                        }
                        spec = spec.NextSpecialization;
                    }
                    PluginData p = Service.FirstPlugin;
                    while (p != null)
                    {
                        if (!p.Disabled)
                        {
                            if (incl == null)
                            {
                                incl = new HashSet <ServiceData>(p.GetIncludedServices(impact, forRunnableStatus));
                            }
                            else
                            {
                                incl.IntersectWith(p.GetIncludedServices(impact, forRunnableStatus));
                            }
                        }
                        p = p.NextPluginForService;
                    }
                    _inclServices[iImpact] = inclExist = incl ?? Service.InheritedServicesWithThis;
                }
                return(inclExist);
            }
Ejemplo n.º 34
0
 internal ServiceData( IServiceInfo s, ServiceData generalization, ConfigurationStatus serviceStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown )
     : this(s, serviceStatus, impact)
 {
     Family = generalization.Family;
     _inheritedServicesWithThis = new ServiceData[generalization._inheritedServicesWithThis.Length + 1];
     generalization._inheritedServicesWithThis.CopyTo( _inheritedServicesWithThis, 0 );
     _inheritedServicesWithThis[_inheritedServicesWithThis.Length - 1] = this;
     Generalization = generalization;
     NextSpecialization = Generalization.FirstSpecialization;
     Generalization.FirstSpecialization = this;
     Initialize();
     if( !Disabled )
         for( int i = 0; i < _inheritedServicesWithThis.Length - 1; ++i )
             ++_inheritedServicesWithThis[i].AvailableServiceCount;
 }
Ejemplo n.º 35
0
 internal ServiceData( IConfigurationSolver solver, IServiceInfo s, ConfigurationStatus serviceStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown )
     : this(s, serviceStatus, impact)
 {
     Family = new ServiceFamily( solver, this );
     _inheritedServicesWithThis = new ServiceData[] { this };
     Initialize();
 }
            public IEnumerable<ServiceData> GetExcludedServices( StartDependencyImpact impact )
            {
                if( _theOnlyPlugin != null ) return _theOnlyPlugin.GetExcludedServices( impact );
                if( _theOnlyService != null ) return GetPropagationInfo( _theOnlyService ).GetExcludedServices( impact );

                IEnumerable<ServiceData> exclExist = _exclServices[(int)impact - 1];
                if( exclExist == null )
                {
                    HashSet<ServiceData> excl = null;
                    ServiceData spec = Service.FirstSpecialization;
                    while( spec != null )
                    {
                        BasePropagation prop = GetPropagationInfo( spec );
                        if( prop != null )
                        {
                            if( excl == null ) excl = new HashSet<ServiceData>( prop.GetExcludedServices( impact ) );
                            else excl.IntersectWith( prop.GetExcludedServices( impact ) );
                        }
                        spec = spec.NextSpecialization;
                    }
                    PluginData p = Service.FirstPlugin;
                    while( p != null )
                    {
                        if( !p.Disabled )
                        {
                            if( excl == null ) excl = new HashSet<ServiceData>( p.GetExcludedServices( impact ) );
                            else excl.IntersectWith( p.GetExcludedServices( impact ) );
                        }
                        p = p.NextPluginForService;
                    }
                    _exclServices[(int)impact - 1] = exclExist = excl ?? Enumerable.Empty<ServiceData>();
                }
                return exclExist;
            }
Ejemplo n.º 37
0
 internal bool DynamicCanStart( StartDependencyImpact impact )
 {
     if( _dynamicStatus != null ) return _dynamicStatus.Value >= RunningStatus.Running;
     if( impact == StartDependencyImpact.Unknown ) impact = ConfigSolvedImpact;
     return DynTestCanStart( impact );
 }
Ejemplo n.º 38
0
        /// <summary>
        /// This function encapsulates all configuration constraints regarding the <see cref="StartDependencyImpact"/> of an item.
        /// </summary>
        /// <param name="s1">Current <see cref="StartDependencyImpact"/></param>
        /// <param name="s2">Wanted <see cref="StartDependencyImpact"/></param>
        /// <param name="invalidCombination">string expliciting the error. Empty if all is well</param>
        public static StartDependencyImpact Combine( StartDependencyImpact i1, StartDependencyImpact i2, out string invalidCombination )
        {
            invalidCombination = "";
            if( i1 == i2 ) return i1;

            if( i1 == StartDependencyImpact.Unknown ) i1 = StartDependencyImpact.Minimal;
            if( i2 == StartDependencyImpact.Unknown ) i2 = StartDependencyImpact.Minimal;

            switch( i1 )
            {
                case StartDependencyImpact.FullStop:
                    if( i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.Minimal
                        || i2 == StartDependencyImpact.TryFullStop
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i1;
                    ///Impacts causing conflict: FullStart, StartRecommended, StartRecommendedAndStopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.StopOptionalAndRunnable:
                    if( i2 == StartDependencyImpact.Minimal
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryFullStop
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i1;
                    if( i2 == StartDependencyImpact.FullStop || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ) return i2;
                    ///Impacts causing conflict: FullStart, StartRecommanded
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.Minimal:
                    return i2;

                case StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable:
                    if( i2 == StartDependencyImpact.Minimal
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryFullStop
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i1;
                        //Impacts causing conflicts: FullStart, FullStop
                    else invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.StartRecommended:
                    if( i2 == StartDependencyImpact.Minimal
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryFullStop
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i1;
                    else if( i2 == StartDependencyImpact.FullStart || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ) return i2;
                    ///Impacts causing conflicts: FullStop, StopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.FullStart:
                    if( i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.Minimal
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryFullStop
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i1;
                    ///Impacts causing conflict: FullStop, StopOptionalAndRunnable, StartRecommendedAndStopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.TryFullStop:
                    if( i2 == StartDependencyImpact.FullStart
                        || i2 == StartDependencyImpact.FullStop
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ) return i2;
                    else if( i2 == StartDependencyImpact.Minimal || i2 == StartDependencyImpact.TryStopOptionalAndRunnable ) return i1;
                    ///Impacts causing conflict: TryFullStart, TryStartRecommended, TryStartRecommendedAndStopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.TryFullStart:
                    if( i2 == StartDependencyImpact.FullStart
                        || i2 == StartDependencyImpact.FullStop
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ) return i2;
                    else if( i2 == StartDependencyImpact.Minimal || i2 == StartDependencyImpact.TryStartRecommended ) return i1;
                    ///Impacts causing conflict: TryFullStop, TryStopOptionalAndRunnable, TryStartRecommendedAndStopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.TryStartRecommended:
                    if( i2 == StartDependencyImpact.FullStart
                        || i2 == StartDependencyImpact.FullStop
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryFullStart
                        || i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable ) return i2;
                    else if( i2 == StartDependencyImpact.Minimal ) return i1;
                    ///Impacts causing conflict: TryFullStop, TryStopOptionalAndRunnable
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable:
                    if( i2 == StartDependencyImpact.FullStart
                        || i2 == StartDependencyImpact.FullStop
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryStartRecommended
                        || i2 == StartDependencyImpact.TryStopOptionalAndRunnable ) return i2;
                    //Impacts causing conflict: TryFullStart, TryFullStop
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;

                case StartDependencyImpact.TryStopOptionalAndRunnable:
                    if( i2 == StartDependencyImpact.FullStart
                        || i2 == StartDependencyImpact.FullStop
                        || i2 == StartDependencyImpact.StartRecommended
                        || i2 == StartDependencyImpact.StopOptionalAndRunnable
                        || i2 == StartDependencyImpact.TryFullStop ) return i2;
                    else if( i2 == StartDependencyImpact.Minimal ) return i1;
                    ///Impacts causing conflict: TryFullStart, TryStartRecommanded
                    invalidCombination = string.Format( "{0} and {1} cannot be combined", i1, i2 );
                    break;
            }
            return StartDependencyImpact.Unknown;
        }
Ejemplo n.º 39
0
 public IYodiiEngineResult SetImpact( StartDependencyImpact newImpact )
 {
     IYodiiEngineResult result = _owner.OnConfigurationItemChanging( this, new FinalConfigurationItem( _serviceOrPluginFullName, _status, _impact ) );
     if( result.Success )
     {
         _impact = newImpact;
         NotifyPropertyChanged( "Impact" );
         if( _owner.ConfigurationManager != null ) _owner.ConfigurationManager.OnConfigurationChanged();
     }
     return result;
 }
Ejemplo n.º 40
0
 internal ServiceData(IServiceInfo s, ServiceData generalization, ConfigurationStatus serviceStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown)
     : this(s, serviceStatus, impact)
 {
     Family = generalization.Family;
     _inheritedServicesWithThis = new ServiceData[generalization._inheritedServicesWithThis.Length + 1];
     generalization._inheritedServicesWithThis.CopyTo(_inheritedServicesWithThis, 0);
     _inheritedServicesWithThis[_inheritedServicesWithThis.Length - 1] = this;
     Generalization     = generalization;
     NextSpecialization = Generalization.FirstSpecialization;
     Generalization.FirstSpecialization = this;
     Initialize();
     if (!Disabled)
     {
         for (int i = 0; i < _inheritedServicesWithThis.Length - 1; ++i)
         {
             ++_inheritedServicesWithThis[i].AvailableServiceCount;
         }
     }
 }
Ejemplo n.º 41
0
 internal void OnRemoved()
 {
     Debug.Assert( _statusReason != null );
     _statusReason = null;
     _status = ConfigurationStatus.Optional;
     _impact = StartDependencyImpact.Unknown;
 }
Ejemplo n.º 42
0
 internal ServiceData(IConfigurationSolver solver, IServiceInfo s, ConfigurationStatus serviceStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown)
     : this(s, serviceStatus, impact)
 {
     Family = new ServiceFamily(solver, this);
     _inheritedServicesWithThis = new ServiceData[] { this };
     Initialize();
 }
            public IEnumerable<ServiceData> GetIncludedServices( StartDependencyImpact impact, bool forRunnableStatus )
            {
                if( _theOnlyPlugin != null ) return _theOnlyPlugin.GetIncludedServices( impact, forRunnableStatus );
                if( _theOnlyService != null ) return GetPropagationInfo( _theOnlyService ).GetIncludedServices( impact, forRunnableStatus );

                int iImpact = (int)impact;
                if( forRunnableStatus ) iImpact *= 2;
                --iImpact;

                IEnumerable<ServiceData> inclExist = _inclServices[iImpact];
                if( inclExist == null )
                {
                    HashSet<ServiceData> incl = null;
                    ServiceData spec = Service.FirstSpecialization;
                    while( spec != null )
                    {
                        BasePropagation prop = GetPropagationInfo( spec );
                        if( prop != null )
                        {
                            if( incl == null ) incl = new HashSet<ServiceData>( prop.GetIncludedServices( impact, forRunnableStatus ) );
                            else incl.IntersectWith( prop.GetIncludedServices( impact, forRunnableStatus ) );
                        }
                        spec = spec.NextSpecialization;
                    }
                    PluginData p = Service.FirstPlugin;
                    while( p != null )
                    {
                        if( !p.Disabled )
                        {
                            if( incl == null ) incl = new HashSet<ServiceData>( p.GetIncludedServices( impact, forRunnableStatus ) );
                            else incl.IntersectWith( p.GetIncludedServices( impact, forRunnableStatus ) );
                        }
                        p = p.NextPluginForService;
                    }
                    _inclServices[iImpact] = inclExist = incl ?? Service.InheritedServicesWithThis;
                }
                return inclExist;
            }
Ejemplo n.º 44
0
        /// <summary>
        /// This function encapsulates all configuration constraints regarding the <see cref="StartDependencyImpact"/> of an item.
        /// </summary>
        /// <param name="s1">Current <see cref="StartDependencyImpact"/></param>
        /// <param name="s2">Wanted <see cref="StartDependencyImpact"/></param>
        /// <param name="invalidCombination">string expliciting the error. Empty if all is well</param>
        public static StartDependencyImpact Combine(StartDependencyImpact i1, StartDependencyImpact i2, out string invalidCombination)
        {
            invalidCombination = "";
            if (i1 == i2)
            {
                return(i1);
            }

            if (i1 == StartDependencyImpact.Unknown)
            {
                i1 = StartDependencyImpact.Minimal;
            }
            if (i2 == StartDependencyImpact.Unknown)
            {
                i2 = StartDependencyImpact.Minimal;
            }

            switch (i1)
            {
            case StartDependencyImpact.FullStop:
                if (i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.Minimal ||
                    i2 == StartDependencyImpact.TryFullStop ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i1);
                }
                ///Impacts causing conflict: FullStart, StartRecommended, StartRecommendedAndStopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.StopOptionalAndRunnable:
                if (i2 == StartDependencyImpact.Minimal ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryFullStop ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i1);
                }
                if (i2 == StartDependencyImpact.FullStop || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i2);
                }
                ///Impacts causing conflict: FullStart, StartRecommanded
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.Minimal:
                return(i2);

            case StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable:
                if (i2 == StartDependencyImpact.Minimal ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryFullStop ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i1);
                }
                //Impacts causing conflicts: FullStart, FullStop
                else
                {
                    invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                }
                break;

            case StartDependencyImpact.StartRecommended:
                if (i2 == StartDependencyImpact.Minimal ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryFullStop ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i1);
                }
                else if (i2 == StartDependencyImpact.FullStart || i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i2);
                }
                ///Impacts causing conflicts: FullStop, StopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.FullStart:
                if (i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.Minimal ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryFullStop ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i1);
                }
                ///Impacts causing conflict: FullStop, StopOptionalAndRunnable, StartRecommendedAndStopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.TryFullStop:
                if (i2 == StartDependencyImpact.FullStart ||
                    i2 == StartDependencyImpact.FullStop ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i2);
                }
                else if (i2 == StartDependencyImpact.Minimal || i2 == StartDependencyImpact.TryStopOptionalAndRunnable)
                {
                    return(i1);
                }
                ///Impacts causing conflict: TryFullStart, TryStartRecommended, TryStartRecommendedAndStopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.TryFullStart:
                if (i2 == StartDependencyImpact.FullStart ||
                    i2 == StartDependencyImpact.FullStop ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i2);
                }
                else if (i2 == StartDependencyImpact.Minimal || i2 == StartDependencyImpact.TryStartRecommended)
                {
                    return(i1);
                }
                ///Impacts causing conflict: TryFullStop, TryStopOptionalAndRunnable, TryStartRecommendedAndStopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.TryStartRecommended:
                if (i2 == StartDependencyImpact.FullStart ||
                    i2 == StartDependencyImpact.FullStop ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryFullStart ||
                    i2 == StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable)
                {
                    return(i2);
                }
                else if (i2 == StartDependencyImpact.Minimal)
                {
                    return(i1);
                }
                ///Impacts causing conflict: TryFullStop, TryStopOptionalAndRunnable
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.TryStartRecommendedAndStopOptionalAndRunnable:
                if (i2 == StartDependencyImpact.FullStart ||
                    i2 == StartDependencyImpact.FullStop ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StartRecommendedAndStopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryStartRecommended ||
                    i2 == StartDependencyImpact.TryStopOptionalAndRunnable)
                {
                    return(i2);
                }
                //Impacts causing conflict: TryFullStart, TryFullStop
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;

            case StartDependencyImpact.TryStopOptionalAndRunnable:
                if (i2 == StartDependencyImpact.FullStart ||
                    i2 == StartDependencyImpact.FullStop ||
                    i2 == StartDependencyImpact.StartRecommended ||
                    i2 == StartDependencyImpact.StopOptionalAndRunnable ||
                    i2 == StartDependencyImpact.TryFullStop)
                {
                    return(i2);
                }
                else if (i2 == StartDependencyImpact.Minimal)
                {
                    return(i1);
                }
                ///Impacts causing conflict: TryFullStart, TryStartRecommanded
                invalidCombination = string.Format("{0} and {1} cannot be combined", i1, i2);
                break;
            }
            return(StartDependencyImpact.Unknown);
        }
Ejemplo n.º 45
0
 /// <summary>
 /// </summary>
 /// <param name="this">This live plugin/service info.</param>
 /// <param name="impact">The impact.</param>
 /// <returns>The engine result.</returns>
 public static IYodiiEngineResult Start(this ILiveYodiiItem @this, StartDependencyImpact impact)
 {
     return(@this.Start(null, impact));
 }
Ejemplo n.º 46
0
        public IEnumerable<ServiceData> GetIncludedServices( StartDependencyImpact impact, bool forRunnableStatus )
        {
            if( _runningIncludedServices == null )
            {
                var running = Service != null ? new HashSet<ServiceData>( Service.InheritedServicesWithThis ) : new HashSet<ServiceData>();
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement == DependencyRequirement.Running ) running.Add( _solver.FindExistingService( sRef.Reference.ServiceFullName ) );
                }
                _runningIncludedServices = running.ToReadOnlyList();
                bool newRunnableAdded = false;
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement == DependencyRequirement.Runnable ) newRunnableAdded |= running.Add( _solver.FindExistingService( sRef.Reference.ServiceFullName ) );
                }
                _runnableIncludedServices = newRunnableAdded ? running.ToReadOnlyList() : _runningIncludedServices;
            }

            if( impact == StartDependencyImpact.Minimal ) return forRunnableStatus ? _runnableIncludedServices : _runningIncludedServices;

            if( _inclServices == null ) _inclServices = new IReadOnlyList<ServiceData>[8];
            int iImpact = (int)impact;
            if( impact > StartDependencyImpact.Minimal ) --impact;
            if( forRunnableStatus ) iImpact *= 2;
            --iImpact;

            IReadOnlyList<ServiceData> i = _inclServices[iImpact];
            if( i == null )
            {
                var baseSet = forRunnableStatus ? _runnableIncludedServices : _runningIncludedServices;
                var incl = new HashSet<ServiceData>( baseSet );
                bool newAdded = false;
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
                    switch( sRef.Requirement )
                    {
                        case DependencyRequirement.RunnableRecommended:
                            {
                                if( impact >= StartDependencyImpact.StartRecommended )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.Runnable:
                            {
                                if( impact == StartDependencyImpact.FullStart )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.OptionalRecommended:
                            {
                                if( impact >= StartDependencyImpact.StartRecommended )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.Optional:
                            {
                                if( impact == StartDependencyImpact.FullStart )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                    }
                }
                i = _inclServices[iImpact] = newAdded ? incl.ToReadOnlyList() : baseSet;
            }
            return i;
        }
Ejemplo n.º 47
0
 bool DynTestCanStart( StartDependencyImpact impact )
 {
     foreach( var s in GetExcludedServices( impact ) )
     {
         if( s.DynamicStatus != null && s.DynamicStatus.Value >= RunningStatus.Running ) return false;
     }
     foreach( var s in GetIncludedServices( impact, false ) )
     {
         if( s.DynamicStatus != null && s.DynamicStatus.Value <= RunningStatus.Stopped ) return false;
     }
     return true;
 }
Ejemplo n.º 48
0
 /// <summary>
 /// </summary>
 /// <param name="this">This live plugin/service info.</param>
 /// <param name="impact">The impact.</param>
 /// <returns>The engine result.</returns>
 public static IYodiiEngineResult Start( this ILiveYodiiItem @this, StartDependencyImpact impact )
 {
     return @this.Start( null, impact );
 }
Ejemplo n.º 49
0
        internal void DynamicStartBy( StartDependencyImpact impact, PluginRunningStatusReason reason )
        {
            Debug.Assert( _dynamicStatus == null || _dynamicStatus.Value >= RunningStatus.Running );
            if( _dynamicStatus == null )
            {
                _dynamicStatus = RunningStatus.Running;
                _dynamicReason = reason;
            }
            if( Service != null ) Service.OnDirectPluginStarted( this );

            foreach( var sRef in PluginInfo.ServiceReferences )
            {
                ServiceData s = _solver.FindExistingService( sRef.Reference.ServiceFullName );
                s.DynamicStartByDependency( impact, sRef.Requirement );
            }
        }
Ejemplo n.º 50
0
 public IYodiiEngineResult Start( string callerKey, StartDependencyImpact impact = StartDependencyImpact.Unknown )
 {
     if( !_capability.CanStartWith( impact ) )
     {
         throw new InvalidOperationException( "You must call Capability.CanStart with the wanted impact and ensure that it returns true before calling Start." );
     }
     YodiiCommand command = new YodiiCommand( true, _fullName, IsPlugin, impact, callerKey );
     return _engine.AddYodiiCommand( command );
 }
Ejemplo n.º 51
0
 internal bool DynamicCanStart( StartDependencyImpact impact )
 {
     if( _dynamicStatus != null ) return _dynamicStatus.Value >= RunningStatus.Running;
     Debug.Assert( _dynamicTotalAvailablePluginsCount != 0 );
     if( impact == StartDependencyImpact.Unknown ) impact = ConfigSolvedImpact;
     return DynTestCanStart( impact );
 }
Ejemplo n.º 52
0
            public bool PropagateSolvedStatus()
            {
                Debug.Assert(Service.FinalConfigSolvedStatus == SolvedConfigurationStatus.Running);
                if (TheOnlyPlugin != null)
                {
                    if (!TheOnlyPlugin.SetRunningStatus(PluginRunningRequirementReason.FromServiceToSinglePlugin))
                    {
                        if (!Service.Disabled)
                        {
                            Service.SetDisabled(ServiceDisabledReason.PropagationToSinglePluginFailed);
                        }
                        else
                        {
                            Service._configDisabledReason = ServiceDisabledReason.PropagationToSinglePluginFailed;
                        }
                        return(false);
                    }
                }
                else if (TheOnlyService != null)
                {
                    if (!TheOnlyService.SetRunningStatus(ServiceSolvedConfigStatusReason.FromServiceToSingleSpecialization))
                    {
                        if (!Service.Disabled)
                        {
                            Service.SetDisabled(ServiceDisabledReason.PropagationToSingleSpecializationFailed);
                        }
                        else
                        {
                            Service._configDisabledReason = ServiceDisabledReason.PropagationToSingleSpecializationFailed;
                        }
                        return(false);
                    }
                }
                else
                {
                    StartDependencyImpact impact = Service.ConfigSolvedImpact;
                    Debug.Assert(impact != StartDependencyImpact.Unknown && (impact & StartDependencyImpact.IsTryOnly) == 0);

                    foreach (var s in GetIncludedServices(impact, false))
                    {
                        if (!s.SetRunningStatus(ServiceSolvedConfigStatusReason.FromPropagation))
                        {
                            if (!Service.Disabled)
                            {
                                Service.SetDisabled(ServiceDisabledReason.PropagationToCommonPluginReferencesFailed);
                            }
                            else
                            {
                                Service._configDisabledReason = ServiceDisabledReason.PropagationToCommonPluginReferencesFailed;
                            }
                            return(false);
                        }
                    }
                    if (!Service.Disabled)
                    {
                        foreach (var s in GetExcludedServices(impact))
                        {
                            if (!s.Disabled)
                            {
                                s.SetDisabled(ServiceDisabledReason.StopppedByPropagation);
                            }
                        }
                    }
                }
                return(true);
            }
            internal bool TestCanStart( StartDependencyImpact impact )
            {
                Debug.Assert( Service.DynamicStatus == null && Service.FinalConfigSolvedStatus == SolvedConfigurationStatus.Runnable );
                Debug.Assert( impact != StartDependencyImpact.Unknown );

                if( TheOnlyPlugin != null )
                {
                    if( !TheOnlyPlugin.DynamicCanStart( impact ) ) return false;
                }
                else
                {
                    foreach( var s in GetExcludedServices( impact ) )
                    {
                        if( s.DynamicStatus != null && s.DynamicStatus.Value >= RunningStatus.Running ) return false;
                    }
                    foreach( var s in GetIncludedServices( impact, false ) )
                    {
                        if( s.DynamicStatus != null && s.DynamicStatus.Value <= RunningStatus.Stopped ) return false;
                    }
                }
                return true;
            }
Ejemplo n.º 54
0
 internal void DynamicStartByDependency( StartDependencyImpact impact, DependencyRequirement req )
 {
     switch( req )
     {
         case DependencyRequirement.Running:
             {
                 Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                 DynamicStartBy( ServiceRunningStatusReason.StartedByRunningReference );
                 break;
             }
         case DependencyRequirement.RunnableRecommended:
             {
                 if( impact >= StartDependencyImpact.StartRecommended )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByRunnableRecommendedReference );
                 }
                 else if( impact == StartDependencyImpact.FullStop )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByRunnableRecommendedReference );
                 }
                 break;
             }
         case DependencyRequirement.Runnable:
             {
                 if( impact == StartDependencyImpact.FullStart )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByRunnableReference );
                 }
                 else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByRunnableReference );
                 }
                 break;
             }
         case DependencyRequirement.OptionalRecommended:
             {
                 if( impact >= StartDependencyImpact.StartRecommended )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByOptionalRecommendedReference );
                 }
                 else if( impact == StartDependencyImpact.FullStop )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByOptionalRecommendedReference );
                 }
                 break;
             }
         case DependencyRequirement.Optional:
             {
                 if( impact == StartDependencyImpact.FullStart )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByOptionalReference );
                 }
                 else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByOptionalReference );
                 }
                 break;
             }
     }
 }
Ejemplo n.º 55
0
        internal PluginData( IConfigurationSolver solver, IPluginInfo p, ServiceData service, ConfigurationStatus pluginStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown )
        {
            _solver = solver;
            PluginInfo = p;
            Service = service;
            ConfigOriginalStatus = pluginStatus;
            switch( pluginStatus )
            {
                case ConfigurationStatus.Disabled: _configSolvedStatus = SolvedConfigurationStatus.Disabled; break;
                case ConfigurationStatus.Running: _configSolvedStatus = SolvedConfigurationStatus.Running; break;
                default: _configSolvedStatus = SolvedConfigurationStatus.Runnable; break;
            }
            _configSolvedStatusReason = PluginRunningRequirementReason.Config;

            RawConfigSolvedImpact = ConfigOriginalImpact = impact;
            if( RawConfigSolvedImpact == StartDependencyImpact.Unknown && Service != null )
            {
                RawConfigSolvedImpact = Service.ConfigSolvedImpact;
            }
            _configSolvedImpact = RawConfigSolvedImpact;
            if( _configSolvedImpact == StartDependencyImpact.Unknown || (_configSolvedImpact & StartDependencyImpact.IsTryOnly) != 0 )
            {
                _configSolvedImpact = StartDependencyImpact.Minimal;
            }

            if( ConfigOriginalStatus == ConfigurationStatus.Disabled )
            {
                _configDisabledReason = PluginDisabledReason.Config;
            }
            else if( p.HasError )
            {
                _configDisabledReason = PluginDisabledReason.PluginInfoHasError;
            }
            else if( Service != null )
            {
                if( Service.Disabled )
                {
                    _configDisabledReason = PluginDisabledReason.ServiceIsDisabled;
                }
                else if( Service.Family.RunningPlugin != null )
                {
                    _configDisabledReason = PluginDisabledReason.AnotherRunningPluginExistsInFamilyByConfig;
                }
            }
            // Immediately check for Runnable references to Disabled Services: this disables us.
            if( !Disabled )
            {
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement >= DependencyRequirement.Runnable )
                    {
                        // If the required service is already disabled, we immediately disable this plugin.
                        if( sRef.Reference.HasError && !Disabled )
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceServiceIsOnError;
                            break;
                        }
                        ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
                        if( sr.Disabled && !Disabled )
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceIsDisabled;
                            break;
                        }
                    }
                }
            }
            if( Service != null ) Service.AddPlugin( this );
            if( !Disabled  )
            {
                // If the plugin is not yet disabled, we register it:
                // whenever the referenced service is disabled (or stopped during dynamic resolution), this
                // will disable (or stop) the plugin according to its ConfigSolvedImpact.
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    _solver.FindExistingService( sRef.Reference.ServiceFullName ).RegisterPluginReference( this, sRef.Requirement );
                }
                if( Service != null && ConfigOriginalStatus == ConfigurationStatus.Running )
                {
                    Service.Family.SetRunningPlugin( this );
                }
            }
        }
Ejemplo n.º 56
0
 bool DynTestCanStart( StartDependencyImpact impact )
 {
     DynamicPropagation p = DynGetPropagationInfo();
     Debug.Assert( p != null );
     return p.TestCanStart( impact );
 }
Ejemplo n.º 57
0
 public IEnumerable<ServiceData> GetExcludedServices( StartDependencyImpact impact )
 {
     if( _exclServices == null ) _exclServices = new IReadOnlyList<ServiceData>[6];
     IReadOnlyList<ServiceData> e = _exclServices[(int)impact-1];
     if( e == null )
     {
         HashSet<ServiceData> excl = new HashSet<ServiceData>();
         foreach( var sRef in PluginInfo.ServiceReferences )
         {
             ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
             switch( sRef.Requirement )
             {
                 case DependencyRequirement.Running:
                     {
                         excl.UnionWith( sr.DirectExcludedServices );
                         break;
                     }
                 case DependencyRequirement.RunnableRecommended:
                     {
                         if( impact >= StartDependencyImpact.StartRecommended )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact == StartDependencyImpact.FullStop )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.Runnable:
                     {
                         if( impact == StartDependencyImpact.FullStart )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.OptionalRecommended:
                     {
                         if( impact >= StartDependencyImpact.StartRecommended )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact == StartDependencyImpact.FullStop )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.Optional:
                     {
                         if( impact == StartDependencyImpact.FullStart )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
             }
         }
         e = _exclServices[(int)impact-1] = excl.ToReadOnlyList();
     }
     return e;
 }
Ejemplo n.º 58
0
        ServiceData( IServiceInfo s, ConfigurationStatus serviceStatus, StartDependencyImpact impact )
        {
            _backReferences = new List<BackReference>();
            ServiceInfo = s;
            ConfigOriginalStatus = serviceStatus;
            RawConfigSolvedImpact = ConfigOriginalImpact = impact;
            if( RawConfigSolvedImpact == StartDependencyImpact.Unknown && Generalization != null )
            {
                RawConfigSolvedImpact = Generalization.ConfigSolvedImpact;
            }
            _configSolvedImpact = RawConfigSolvedImpact;
            if( _configSolvedImpact == StartDependencyImpact.Unknown || (_configSolvedImpact & StartDependencyImpact.IsTryOnly) != 0 )
            {
                _configSolvedImpact = StartDependencyImpact.Minimal;
            }

            if( ConfigSolvedImpact == StartDependencyImpact.Unknown )
            {
                if( Generalization != null ) _configSolvedImpact = Generalization.ConfigOriginalImpact;
            }
        }