Beispiel #1
0
 public EventLogCollector(string sessionId, EventLogCollectorDetail detail)
 {
     _sessionID          = sessionId;
     _resourceDefinition = detail;
     _lastItemLogged     = new Dictionary <string, DateTime>();
     _components         = _resourceDefinition.Components;
     _entryTypes         = _resourceDefinition.EntryTypesBitwise;
     _interval           = new TimeSpan(0, _resourceDefinition.PollingInterval, 0);
     _dataLogger         = new DataLogger(GlobalSettings.WcfHosts[WcfService.DataLog]);
 }
 /// <summary>
 /// Creates resource detail and inserts it into the manifest.
 /// </summary>
 /// <param name="resources">The resources.</param>
 /// <param name="manifest">The manifest.</param>
 internal override void AddToManifest(Collection <VirtualResource> resources, SystemManifest manifest)
 {
     foreach (VirtualResource resource in resources)
     {
         EventLogCollectorDetail detail = manifest.Resources.GetResource <EventLogCollectorDetail>(resource.VirtualResourceId);
         if (detail == null)
         {
             detail = CreateDetail(resource);
             manifest.Resources.Add(detail);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Starts this instance of the <see cref=" VirtualClientController"/> to work with the Dispatcher,
        /// then creates the virtual resources based on the provided <see cref="SystemManifest"/>.
        /// </summary>
        /// <remarks>
        /// Creates a <see cref="SessionProxyBackendConnection"/> that is used to communicate with the
        /// Dispatcher to provide status updates.  Loads the <see cref="SystemManifest"/>  into
        /// the <see cref="GlobalDataStore"/> and into the <see cref="GlobalSettings"/>.
        /// </remarks>
        public void Start(string sessionId)
        {
            _sessionId = sessionId;

            // Contact the dispatcher and register.
            string manifestData = string.Empty;

            TraceFactory.Logger.Debug("Registering with Dispatcher {0}, SessionId: {1}".FormatWith(_dispatcherAddress, _sessionId));
            using (var proxyClient = SessionProxyBackendConnection.Create(_dispatcherAddress, _sessionId))
            {
                manifestData = proxyClient.Channel.RegisterMachine(Environment.MachineName);
            }

            _manifest = SystemManifest.Deserialize(manifestData);
            string resourceInstanceId = string.Empty;

            switch (_manifest.ResourceType)
            {
            case VirtualResourceType.AdminWorker:
            case VirtualResourceType.OfficeWorker:
            case VirtualResourceType.SolutionTester:
                // These types don't use the resource instance Id as there can be multiple instances
                // of the worker within the client controller process.
                _manifest.PushToGlobalDataStore();

                //The following code monitors the local host VM client event logs.
                if (_manifest.CollectEventLogs)
                {
                    EventLogCollectorDetail detail = new EventLogCollectorDetail();
                    detail.ComponentsData  = Resources.ClientEventLogComponents;
                    detail.EntryTypesData  = Resources.ClientEventLogEntryTypes;
                    detail.Description     = "Client VM Event Collector";
                    detail.Enabled         = true;
                    detail.HostName        = Environment.MachineName;
                    detail.Name            = Environment.MachineName;
                    detail.ResourceType    = VirtualResourceType.EventLogCollector;
                    detail.PollingInterval = 15;
                    _manifest.Resources.Add(detail);
                    resourceInstanceId = _manifest.Resources.OfType <EventLogCollectorDetail>().First().HostName;
                    _manifest.PushToGlobalDataStore(resourceInstanceId);
                }

                break;

            case VirtualResourceType.CitrixWorker:
            case VirtualResourceType.LoadTester:
                // These resources use credentials like the workers above, but run in the
                // client controller process, so the data store needs the resource instance Id set.
                resourceInstanceId = _manifest.Resources.Credentials.First().ResourceInstanceId;
                _manifest.PushToGlobalDataStore(resourceInstanceId);
                break;

            case VirtualResourceType.EventLogCollector:
                // This resource is unique as it uses the hostname as its unique name.  It also
                // runs within the client controller process so it needs its instance Id set.
                // This event log collector monitors target machines rather than the local VM running the client controller
                resourceInstanceId = _manifest.Resources.OfType <EventLogCollectorDetail>().First().HostName;
                _manifest.PushToGlobalDataStore(resourceInstanceId);
                break;

            default:
                // All other resources also run in the client controller process, but they use Name
                // as their unique id.
                var type = GetDetailType(_manifest.ResourceType);
                resourceInstanceId = _manifest.Resources.Where(x => x.GetType().Equals(type)).First().Name;
                TraceFactory.Logger.Debug("Resource Instance Id: {0}".FormatWith(resourceInstanceId));
                _manifest.PushToGlobalDataStore(resourceInstanceId);
                break;
            }

            TraceFactory.Logger.Debug("Resource Instance Id: {0}".FormatWith(resourceInstanceId));

            _manifest.PushToGlobalSettings();

            GlobalSettings.SetDispatcher(_dispatcherAddress);

            TraceFactory.Logger.Debug(_manifest.ToString());

            InstallPrintingCertficates();
            InstallClientSoftware();

            // Creates all the virtual resources specified in the provided manifest.
            _handlers = VirtualResourceHandlerFactory.Create(_manifest);
            foreach (var handler in _handlers)
            {
                handler.Start();
            }
        }