Example #1
0
 private void InitFields()
 {
     this.connection = null;
     this.serviceConnectionParams = null;
     this.threadInfo       = default(DbusUtils.VisitorThreadInfo);
     this.threadSignalLoop = null;
     this.hosts            = null;
 }
Example #2
0
 public static DbusUtils.VisitorThreadInfo RunSignalsAsync(out System.Threading.Thread threadSignalLoop, Udbus.Core.ServiceConnectionParams serviceConnectionParams)
 {
     DbusUtils.VisitorThreadInfo threadInfo = new DbusUtils.VisitorThreadInfo(serviceConnectionParams);
     threadSignalLoop = DbusUtils.LoopSignalsThread();
     threadSignalLoop.IsBackground = true;
     threadSignalLoop.Start(threadInfo);
     return(threadInfo);
 }
        public XenClientGuestService()
        {
            // EventSource needs to be something for logging not to throw exception.
            bool bNoSource = string.IsNullOrEmpty(this.EventLog.Source);

            if (bNoSource) // If no source string setup
            {
                if (!string.IsNullOrEmpty(this.ServiceName))
                {
                    this.EventLog.Source = this.ServiceName;
                }
                else
                {
                    this.EventLog.Source = Logging.LogCreation.Service;
                }
            } // Ends if no source string setup

            log = Logging.LogCreation.CreateServiceLogger(this); // Log pre initialised service.
            Udbus.Core.Logging.ILog logRoot = Logging.LogCreation.CreateRootLogger(this); // Root logger pre initialised service.

            InitializeComponent();

            // Try to ammend event source name to something more meaningful.
            if (bNoSource && !string.IsNullOrEmpty(this.ServiceName)) // If no source string setup
            {
                this.EventLog.Source = this.ServiceName;
            } // Ends if no source string setup

            logRoot = Logging.LogCreation.ReplaceRootLogger(this, logRoot); // Root logger
            log     = Logging.LogCreation.ReplaceServiceLogger(this, log); // Log post initialised service.

            // Initialize fields.
            this.dbusHosts = new DbusHosts(this.EventLog);
            Udbus.Core.ServiceConnectionParams serviceConnectionParams;
            this.diagSignals = XcDiagRunner.CreateDbusDiag(out serviceConnectionParams, log, Log_Io_Debug);
            this.diagSignals.GatherRequest += this.OnGatherRequest;
            System.Threading.Thread xcdiagSignalsThread;
            this.diagsignalsThreadInfo = DbusHosts.RunSignalsAsync(out xcdiagSignalsThread, serviceConnectionParams);

            //We're gonna start doing our own thing logs wise...
            if (!EventLog.SourceExists("XenClientGuestService"))
            {
                EventLog.CreateEventSource("XenClientGuestService", "Application");
            }
            EventLog.WriteEntry("XenClientGuestService", "XenClientGuestService Logs Initialised");
        }
Example #4
0
        private void FinishRunHosts(Udbus.v4v.v4vConnection connection, Udbus.Core.ServiceConnectionParams serviceConnectionParams)
        {
            this.connection = connection;
            this.serviceConnectionParams = serviceConnectionParams;

            log.Info("Connection helloed with name {0} and signalName {1}", serviceConnectionParams.Name, serviceConnectionParams.SignalName);
            System.Uri uriBase = new System.Uri(Udbus.WCF.Constants.BaseAddress);

            new Udbus.WCF.Service.Host.Init.InitHostMakerRegistry();
            new global::XenClientGuestService.wcf.Hosts.Init.InitHostMakerRegistry();
            Udbus.WCF.Service.Host.RegistryDictionaryHolder registry = Udbus.WCF.Service.Host.HostMakerRegistry.RegistryDictionaryClone;

            log.Info("Launching hosts...");

            // Build all hosts including "special" properties host.
            ICollection <Udbus.WCF.Service.Host.ServiceHostCreationData> hostdata = Udbus.WCF.Service.Host.HostMakerRegistry.BuildAllHosts(
                registry.Values
                , new Udbus.WCF.Host.WCFServiceParams(serviceConnectionParams)
                , new Uri[] { uriBase }
                );

            System.ServiceModel.NetNamedPipeBinding namedpipeBinding = new System.ServiceModel.NetNamedPipeBinding();
            System.ServiceModel.Channels.Binding    binding          = namedpipeBinding;
            binding.SendTimeout    = TimeSpan.MaxValue;
            binding.ReceiveTimeout = TimeSpan.MaxValue;

            foreach (Udbus.WCF.Service.Host.ServiceHostCreationData host in hostdata)
            {
                host.Host.AddServiceEndpoint(host.CreationParams.ContractType, binding, host.CreationParams.RelativeName);
            }

            this.hosts = hostdata.Select <Udbus.WCF.Service.Host.ServiceHostCreationData, System.ServiceModel.ServiceHost>(Udbus.WCF.Service.Host.ServiceHostCreationData.DataToHost);
            DbusUtils.RunHosts(hosts);

            this.threadInfo = RunSignalsAsync(out this.threadSignalLoop, serviceConnectionParams);
        }
Example #5
0
 private void InitFields()
 {
     this.connection = null;
     this.serviceConnectionParams = null;
     this.threadInfo = default(DbusUtils.VisitorThreadInfo);
     this.threadSignalLoop = null;
     this.hosts = null;
 }
Example #6
0
        private void FinishRunHosts(Udbus.v4v.v4vConnection connection, Udbus.Core.ServiceConnectionParams serviceConnectionParams)
        {
            this.connection = connection;
            this.serviceConnectionParams = serviceConnectionParams;

            log.Info("Connection helloed with name {0} and signalName {1}", serviceConnectionParams.Name, serviceConnectionParams.SignalName);
            System.Uri uriBase = new System.Uri(Udbus.WCF.Constants.BaseAddress);

            new Udbus.WCF.Service.Host.Init.InitHostMakerRegistry();
            new global::XenClientGuestService.wcf.Hosts.Init.InitHostMakerRegistry();
            Udbus.WCF.Service.Host.RegistryDictionaryHolder registry = Udbus.WCF.Service.Host.HostMakerRegistry.RegistryDictionaryClone;

            log.Info("Launching hosts...");

            // Build all hosts including "special" properties host.
            ICollection<Udbus.WCF.Service.Host.ServiceHostCreationData> hostdata = Udbus.WCF.Service.Host.HostMakerRegistry.BuildAllHosts(
                registry.Values
                , new Udbus.WCF.Host.WCFServiceParams(serviceConnectionParams)
                , new Uri[] { uriBase }
            );

            System.ServiceModel.NetNamedPipeBinding namedpipeBinding = new System.ServiceModel.NetNamedPipeBinding();
            System.ServiceModel.Channels.Binding binding = namedpipeBinding;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.ReceiveTimeout = TimeSpan.MaxValue;

            foreach (Udbus.WCF.Service.Host.ServiceHostCreationData host in hostdata)
            {
                host.Host.AddServiceEndpoint(host.CreationParams.ContractType, binding, host.CreationParams.RelativeName);
            }

            this.hosts = hostdata.Select<Udbus.WCF.Service.Host.ServiceHostCreationData, System.ServiceModel.ServiceHost>(Udbus.WCF.Service.Host.ServiceHostCreationData.DataToHost);
            DbusUtils.RunHosts(hosts);

            this.threadInfo = RunSignalsAsync(out this.threadSignalLoop, serviceConnectionParams);
        }
Example #7
0
 public static DbusUtils.VisitorThreadInfo RunSignalsAsync(out System.Threading.Thread threadSignalLoop, Udbus.Core.ServiceConnectionParams serviceConnectionParams)
 {
     DbusUtils.VisitorThreadInfo threadInfo = new DbusUtils.VisitorThreadInfo(serviceConnectionParams);
     threadSignalLoop = DbusUtils.LoopSignalsThread();
     threadSignalLoop.IsBackground = true;
     threadSignalLoop.Start(threadInfo);
     return threadInfo;
 }
        public XenClientGuestService()
        {
            // EventSource needs to be something for logging not to throw exception.
            bool bNoSource = string.IsNullOrEmpty(this.EventLog.Source);
            if (bNoSource) // If no source string setup
            {
                if (!string.IsNullOrEmpty(this.ServiceName))
                {
                    this.EventLog.Source = this.ServiceName;
                }
                else
                {
                    this.EventLog.Source = Logging.LogCreation.Service;
                }

            } // Ends if no source string setup

            log = Logging.LogCreation.CreateServiceLogger(this); // Log pre initialised service.
            Udbus.Core.Logging.ILog logRoot = Logging.LogCreation.CreateRootLogger(this); // Root logger pre initialised service.

            InitializeComponent();

            // Try to ammend event source name to something more meaningful.
            if (bNoSource && !string.IsNullOrEmpty(this.ServiceName)) // If no source string setup
            {
                this.EventLog.Source = this.ServiceName;

            } // Ends if no source string setup

            logRoot = Logging.LogCreation.ReplaceRootLogger(this, logRoot); // Root logger
            log = Logging.LogCreation.ReplaceServiceLogger(this, log); // Log post initialised service.

            // Initialize fields.
            this.dbusHosts = new DbusHosts(this.EventLog);
            Udbus.Core.ServiceConnectionParams serviceConnectionParams;
            this.diagSignals = XcDiagRunner.CreateDbusDiag(out serviceConnectionParams, log, Log_Io_Debug);
            this.diagSignals.GatherRequest += this.OnGatherRequest;
            System.Threading.Thread xcdiagSignalsThread;
            this.diagsignalsThreadInfo = DbusHosts.RunSignalsAsync(out xcdiagSignalsThread, serviceConnectionParams);

            //We're gonna start doing our own thing logs wise...
            if (!EventLog.SourceExists("XenClientGuestService")) EventLog.CreateEventSource("XenClientGuestService", "Application");
            EventLog.WriteEntry("XenClientGuestService", "XenClientGuestService Logs Initialised");
        }