Exemple #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cache">The cache object.</param>
 /// <param name="resourceMonitor">Resource monitor</param>
 /// <param name="testGroups">The test groups resource.</param>
 public TestGroupsDataSetLoader(ICache cache, IResourceMonitor resourceMonitor, IResource testGroups)
     : base(cache, resourceMonitor)
 {
     Initialize(new List <IResource> {
         testGroups
     });
 }
Exemple #2
0
            public async Task <bool?> Register()
            {
                var logger = Utility.CreateLogger(nameof(KamajiClient), nameof(Register));

                try
                {
                    NodeRegisterModel model = new NodeRegisterModel();
                    model.Address = DataSources.Jsons.AppSettings.Config.Address;

                    IResourceMonitor resourceMonitor = SystemInfo.CreateResourceMonitor();
                    model.ThreadCount  = SystemInfo.ProcessorCount;
                    model.TotalMemory  = resourceMonitor.GetTotalMemory().ConvertTo <int>();
                    model.ComputerName = SystemInfo.ComputerName();
                    model.IpAddress    = SystemInfo.GetIpv4Address()?.ToString();

                    string[] arr = model.Address.Split(':');
                    if (arr.Length > 1 && int.TryParse(arr[arr.Length - 1], out int port))
                    {
                        model.Port = port;
                    }

                    bool success = await RestClient.Instance.PostAsync <bool>($"{KamajiNodeActions.Register}", model);

                    await logger.Code(1).Info("A token has been taken and conected to Kamaji").SaveAsync();

                    return(success);
                }
                catch (Exception ex)
                {
                    await logger.Code(1).Error(ex).SaveAsync();

                    return(null);
                }
            }
 public Synchronizer(TeamMailboxSyncJob job, MailboxSession mailboxSession, IResourceMonitor resourceMonitor, string siteUrl, ICredentials credential, bool isOAuthCredential, bool enableHttpDebugProxy, Stream syncCycleLogStream)
 {
     if (mailboxSession == null)
     {
         throw new ArgumentNullException("mailboxSession");
     }
     if (resourceMonitor == null)
     {
         throw new ArgumentNullException("resourceMonitor");
     }
     if (string.IsNullOrEmpty(siteUrl))
     {
         throw new ArgumentNullException("siteUrl");
     }
     try
     {
         this.siteUri = new Uri(siteUrl);
     }
     catch (UriFormatException innerException)
     {
         throw new ArgumentException(string.Format("Invalid format for siteUrl: {0}", siteUrl), innerException);
     }
     if (!this.siteUri.IsAbsoluteUri)
     {
         throw new ArgumentException(string.Format("Expect siteUrl: {0} to be absolute Uri", siteUrl));
     }
     this.mailboxSession       = mailboxSession;
     this.Job                  = job;
     this.credential           = credential;
     this.isOAuthCredential    = isOAuthCredential;
     this.resourceMonitor      = resourceMonitor;
     this.enableHttpDebugProxy = enableHttpDebugProxy;
     this.loggingContext       = new LoggingContext(this.mailboxSession.MailboxGuid, this.siteUri.ToString(), (job != null) ? job.ClientString : string.Empty, syncCycleLogStream);
 }
Exemple #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="cache">The cache object.</param>
        /// <param name="resourceMonitor">Resource Watcher instance</param>
        /// <param name="dataSetOverride">The data set override.</param>
        protected ConfigurationDataSetLoader(ICache cache, IResourceMonitor resourceMonitor, T dataSetOverride = null)
        {
            Cache             = Code.ExpectsArgument(cache, nameof(cache), TaggingUtilities.ReserveTag(0x238208d9 /* tag_9669z */));
            m_resourceMonitor = Code.ExpectsArgument(resourceMonitor, nameof(resourceMonitor), TaggingUtilities.ReserveTag(0x23821000 /* tag_967aa */));

            DataSetOverride = dataSetOverride;
        }
Exemple #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="resourceMonitor">Resource monitor</param>
 /// <param name="dataSet">data set</param>
 public UnitTestTestGroupsDataSetLoader(IResourceMonitor resourceMonitor, TestGroupsDataSet dataSet = null)
     : base(new LocalCache(), resourceMonitor, dataSet ?? new TestGroupsDataSet(ResourceNames.TestGroups))
 {
     Initialize(new List <IResource>
     {
         new FileResource(new UnitTestTextFile(true, true, ValidDataRaw),
                          TestResourceFolder, TestResourceName)
     });
 }
        /// <summary>
        /// Waits for a file resource monitor to become enabled.
        /// </summary>
        /// <param name="monitor">The monitor on which to wait.</param>
        private void WaitForEnabled(IResourceMonitor monitor)
        {
            int counter = 0;

            while (!monitor.IsEnabled && counter < 5)
            {
                Thread.Sleep(500);
                counter++;
            }

            Assert.True(monitor.IsEnabled);
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="ResourceCurrentState"/> class.
            /// </summary>
            /// <param name="resourceMonitor">The resource monitor.</param>
            /// <param name="maxStatePerResource">The maximum state per resource.</param>
            /// <exception cref="ArgumentNullException"></exception>
            public ResourceCurrentState(IResourceMonitor resourceMonitor, int maxStatePerResource)
            {
                var boundedQueue = new BoundedQueue <ResourceMonitorEventArgs>(maxStatePerResource);

                if (resourceMonitor == null)
                {
                    throw new ArgumentNullException(nameof(resourceMonitor));
                }
                ResourceMonitor = resourceMonitor;
                _boundedQueue   = boundedQueue;

                _handler = (sender, @event) =>
                {
                    _boundedQueue.Enqueue(@event);
                };
            }
Exemple #8
0
            public async Task HeartBeat()
            {
                NodeHeartBeatModel model = new NodeHeartBeatModel();

                model.Address = DataSources.Jsons.AppSettings.Config.Address;

                IResourceMonitor resourceMonitor = SystemInfo.CreateResourceMonitor();

                model.CpuUsage    = resourceMonitor.GetCpuUsage();
                model.MemoryUsage = resourceMonitor.GetMemoryUsage();

                model.TotalExecutingJobCount = WorkerServiceList.Instance.Count(p => p.IsRunning);  //Workers.Instance.TotalWorkerCount;//şu an için. Node' ların wırker execute yapısı ortaya çıkınca burasıu güncellenecek.
                model.TotalQueuedJobCount    = Queue.Instance.Count();

                await RestClient.Instance.PostAsync <bool>($"{KamajiNodeActions.HeartBeat}", model);
            }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GateDataSetLoader" /> class.
        /// </summary>
        /// <param name="cache">The cache object.</param>
        /// <param name="resourceMonitor">Resource monitor</param>
        /// <param name="gates">The gates.</param>
        /// <param name="testGroups">The test groups.</param>
        public GateDataSetLoader(ICache cache, IResourceMonitor resourceMonitor, IResource gates, IResource testGroups)
            : base(cache, resourceMonitor)
        {
            List <IResource> resources = new List <IResource>();

            if (gates != null)
            {
                resources.Add(gates);
            }

            if (testGroups != null)
            {
                resources.Add(testGroups);
            }

            Initialize(resources);
        }
        /// <summary>
        /// Adds a new Monitor to the Collector
        /// </summary>
        /// <param name="resourceMonitor">The monitor.</param>
        public void AddMonitor(IResourceMonitor resourceMonitor)
        {
            var resourceState = new ResourceCurrentState(resourceMonitor, MaxStatePerResource);

            if (!_resourceStates.TryAdd(resourceMonitor, resourceState))
            {
                _logger.LogError("Couldn't add {Monitor} to collector.", resourceMonitor);
                return;
            }

            if (IsRunning)
            {
                resourceState.Start();
            }

            _logger.LogTrace("Added Resource Monitor {Monitor}. Collector running state: {IsCollectorRunning}, Resource running state: {IsResourceRunning}",
                             resourceMonitor, IsRunning, resourceMonitor.IsRunning);
        }
        /// <summary>
        /// Removes a monitor from the Collector
        /// </summary>
        /// <param name="resourceMonitor">The monitor.</param>
        public void RemoveMonitor(IResourceMonitor resourceMonitor)
        {
            ResourceCurrentState resourceState;

            if (_resourceStates.TryRemove(resourceMonitor, out resourceState))
            {
                if (IsRunning) // No need to Stop it if we are not running
                {
                    resourceState.Stop();
                }

                _logger.LogTrace("Removed Resource Monitor {Monitor}. Collector running state: {IsCollectorRunning}, Resource running state: {IsResourceRunning}",
                                 resourceMonitor, IsRunning, resourceMonitor.IsRunning);
            }
            else
            {
                _logger.LogWarning("Tried to remove a Resource Monitor with no Resource State being collected.");
            }
        }
 public MainViewModel(IResourceMonitor resourceMonitor)
 {
     Should.NotBeNull(resourceMonitor, nameof(resourceMonitor));
     BindingMonitor = resourceMonitor;
     Items          = new[]
     {
         Tuple.Create("GC.Collect", typeof(object)),
         Tuple.Create("Binding mode", typeof(BindingModeViewModel)),
         Tuple.Create("Relative binding", typeof(RelativeBindingViewModel)),
         Tuple.Create("Command binding", typeof(CommandBindingViewModel)),
         Tuple.Create("Validation binding", typeof(BindingValidationViewModel)),
         Tuple.Create("Binding to dynamic object", typeof(DynamicObjectViewModel)),
         Tuple.Create("Binding expressions", typeof(BindingExpressionViewModel)),
         Tuple.Create("Binding resources", typeof(BindingResourcesViewModel)),
         Tuple.Create("Attached members", typeof(AttachedMemberViewModel)),
         Tuple.Create("Localizable binding", typeof(LocalizableViewModel)),
         Tuple.Create("Collection binding", typeof(CollectionBindingViewModel)),
         Tuple.Create("Performance", typeof(PerformanceViewModel))
     };
     ShowCommand = new AsyncRelayCommand <Type>(ShowAsync, false);
     resourceMonitor.PropertyChanged += ReflectionExtensions.MakeWeakPropertyChangedHandler(this,
                                                                                            (model, o, arg3) => model.OnPropertyChanged(() => vm => vm.ResourceUsageInfo));
 }
 public MainViewModel(IResourceMonitor resourceMonitor)
 {
     Should.NotBeNull(resourceMonitor, "ResourceMonitor");
     _resourceMonitor = resourceMonitor;
     Items = new[]
     {
         Tuple.Create("GC.Collect", typeof (object)),
         Tuple.Create("Binding mode", typeof (BindingModeViewModel)),
         Tuple.Create("Relative binding", typeof (RelativeBindingViewModel)),
         Tuple.Create("Command binding", typeof (CommandBindingViewModel)),
         Tuple.Create("Validation binding", typeof (BindingValidationViewModel)),
         Tuple.Create("Binding to dynamic object", typeof (DynamicObjectViewModel)),
         Tuple.Create("Binding expressions", typeof (BindingExpressionViewModel)),
         Tuple.Create("Binding resources", typeof (BindingResourcesViewModel)),
         Tuple.Create("Attached members", typeof (AttachedMemberViewModel)),
         Tuple.Create("Localizable binding", typeof (LocalizableViewModel)),
         Tuple.Create("Collection binding", typeof (CollectionBindingViewModel)),
         Tuple.Create("Performance", typeof (PerformanceViewModel))
     };
     ShowCommand = new RelayCommand<Type>(Show);
     resourceMonitor.PropertyChanged += ReflectionExtensions.MakeWeakPropertyChangedHandler(this,
         (model, o, arg3) => model.OnPropertyChanged(() => vm => vm.ResourceUsageInfo));
 }
 public SiteSynchronizer(DocumentSyncJob job, MailboxSession mailboxSession, IResourceMonitor resourceMonitor, string siteUrl, ICredentials credential, bool isOAuthCredential, bool enableHttpDebugProxy, Stream syncCycleLogStream) : base(job, mailboxSession, resourceMonitor, siteUrl, credential, isOAuthCredential, enableHttpDebugProxy, syncCycleLogStream)
 {
     this.loggingComponent = ProtocolLog.Component.DocumentSync;
 }
Exemple #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cache">The cache object.</param>
 /// <param name="resourceMonitor">Resource Monitor instance</param>
 /// <param name="dataSetOverride">The data set override.</param>
 public UnitTestDataSetLoader(ICache cache, IResourceMonitor resourceMonitor, T dataSetOverride = null)
 {
     UnitTestLoader = new UnitTestConfigurationDataSetLoader <T>(cache, resourceMonitor, dataSetOverride, UnitTestOnResourceUpdated);
     UnitTestLoader.DataSetLoaded += OnDataSetLoadedByInternalLoader;
 }
Exemple #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cache">The cache object.</param>
 /// <param name="resourceMonitor">Resource Monitor instance</param>
 /// <param name="dataSetOverride">The data set override.</param>
 /// <param name="resourceUpdatedHandler">Handler to be called when the resource is updates</param>
 public UnitTestConfigurationDataSetLoader(ICache cache, IResourceMonitor resourceMonitor, TConfigurationDataSet dataSetOverride = null, ResourceUpdatedHandler resourceUpdatedHandler = null)
     : base(cache, resourceMonitor, dataSetOverride) => m_resourceUpdatedHandler = resourceUpdatedHandler;
Exemple #17
0
 public MembershipSynchronizer(TeamMailboxSyncJob job, MailboxSession mailboxSession, OrganizationId orgId, ITeamMailboxSecurityRefresher teamMailboxSecurityRefresher, IResourceMonitor resourceMonitor, string siteUrl, ICredentials credential, bool isOAuthCredential, bool enableHttpDebugProxy, Stream syncCycleLogStream) : base(job, mailboxSession, resourceMonitor, siteUrl, credential, isOAuthCredential, enableHttpDebugProxy, syncCycleLogStream)
 {
     if (teamMailboxSecurityRefresher == null)
     {
         throw new ArgumentNullException("teamMailboxSecurityRefresher");
     }
     if (orgId == null)
     {
         throw new ArgumentNullException("orgId");
     }
     this.orgId = orgId;
     this.teamMailboxSecurityRefresher = teamMailboxSecurityRefresher;
     this.workLoadSize     = 20;
     this.loggingComponent = ProtocolLog.Component.MembershipSync;
 }
 public MaintenanceSynchronizer(TeamMailboxSyncJob job, MailboxSession mailboxSession, OrganizationId orgId, Uri webCollectionUrl, Guid webId, string siteUrl, string displayName, IResourceMonitor resourceMonitor, ICredentials credential, bool isOAuthCredential, bool enableHttpDebugProxy, Stream syncCycleLogStream) : base(job, mailboxSession, resourceMonitor, siteUrl, credential, isOAuthCredential, enableHttpDebugProxy, syncCycleLogStream)
 {
     if (orgId == null)
     {
         throw new ArgumentNullException("orgId");
     }
     this.orgId            = orgId;
     this.webCollectionUrl = webCollectionUrl;
     this.webId            = webId;
     this.recordedSiteUrl  = (string.IsNullOrEmpty(siteUrl) ? null : new Uri(siteUrl));
     this.displayName      = displayName;
     this.loggingComponent = ProtocolLog.Component.Maintenance;
 }
Exemple #19
0
 public TeamMailboxSyncInfo(Guid mailboxGuid, TeamMailboxLifecycleState lifeCycleState, MailboxSession mailboxSession, ExchangePrincipal mailboxPrincipal, string displayName, Uri webCollectionUrl, Guid webId, string siteUrl, IResourceMonitor resourceMonitor, UserConfiguration logger)
 {
     this.MailboxGuid            = mailboxGuid;
     this.LifeCycleState         = lifeCycleState;
     this.MailboxSession         = mailboxSession;
     this.DisplayName            = displayName;
     this.WebCollectionUrl       = webCollectionUrl;
     this.WebId                  = webId;
     this.SiteUrl                = siteUrl;
     this.NextAllowedSyncUtcTime = ExDateTime.UtcNow;
     this.LastSyncUtcTime        = ExDateTime.MinValue;
     this.SyncErrors             = new SortedList <ExDateTime, Exception>();
     this.ResourceMonitor        = resourceMonitor;
     this.MailboxPrincipal       = mailboxPrincipal;
     this.Logger                 = logger;
     this.WhenCreatedUtcTime     = ExDateTime.UtcNow;
 }