public DefaultRuntimeStatistics(
			IList<Exception> hostedServiceExceptions,
			IList<Type> configuredHostedServices,
			Type configuredServiceHost,
			FabricRuntimeState runtimeState,
			IFabricRuntimeSettings settings)
		{
			HostedServiceExceptions = hostedServiceExceptions;
			ConfiguredHostedServices = configuredHostedServices;
			ConfiguredServiceHost = configuredServiceHost;
			RuntimeState = runtimeState;
			Settings = settings;
		}
Exemple #2
0
		public virtual void Start()
		{
			this.WriteDebugMessage(string.Format("Starting {0}.", GetType().Name));

			var hostedServices = new List<IHostedService>();

			foreach (var hostedServiceType in CurrentSettings.HostedServices.Value)
			{
				try
				{
					hostedServices.Add((IHostedService)Container.Resolve(hostedServiceType));

					ConfiguredHostedServices.Add(hostedServiceType);
				}
				catch (ComponentNotFoundException e)
				{
					throw new HostedServiceNotResolvableException(
						string.Format("Unable to resolve hosted service of type {0} from container.", CurrentSettings.ServiceHost.Value),
						e);
				}
			}

			foreach (var hostedService in hostedServices)
			{
				_serviceHost.Install(hostedService);
			}

			_serviceHost.StartAll();

			State = FabricRuntimeState.Started;

			this.WriteInfoMessage(string.Format("Started {0}.", GetType().Name));
		}
Exemple #3
0
		public virtual void Shutdown()
		{
			this.WriteDebugMessage(string.Format("Shutting down {0}.", GetType().Name));

			State = FabricRuntimeState.Stopping;

			_serviceHost.CancelAll();

			State = FabricRuntimeState.Stopped;

			this.WriteInfoMessage(string.Format("Shut down {0}.", GetType().Name));
		}