// Token: 0x06000915 RID: 2325 RVA: 0x000416B8 File Offset: 0x0003F8B8 private void CheckItems(object state) { AgentDeploymentWatcher.log.Debug("CheckItems started"); DateTime ExpireTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(120.0)); new List <Action <AgentDeploymentStatus> >(); object obj = AgentDeploymentWatcher.syncLockItems; IEnumerable <AgentDeploymentWatcher.CacheItem> enumerable; IEnumerable <int> enumerable2; lock (obj) { AgentDeploymentWatcher.log.Debug("CheckItems - looking for items to remove"); enumerable = (from item in this.Items where item.Value.DeploymentInfo.StatusInfo.Status == AgentDeploymentStatus.Finished || item.Value.DeploymentInfo.StatusInfo.Status == AgentDeploymentStatus.Failed || item.Value.LastChecked < ExpireTime select item.Value).ToArray <AgentDeploymentWatcher.CacheItem>(); foreach (AgentDeploymentWatcher.CacheItem cacheItem in enumerable) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - removing item, AgentId:{0}", cacheItem.DeploymentInfo.Agent.AgentId); this.Items.Remove(cacheItem.DeploymentInfo.Agent.AgentId); } if (this.Items.Count == 0) { AgentDeploymentWatcher.log.Debug("CheckItems - No remaining items in the cache, stopping Watcher"); this.StopWatcher(); } AgentDeploymentWatcher.log.Debug("CheckItems - looking for items to refresh"); enumerable2 = (from item in this.Items where item.Value.RefreshNeeded || item.Value.LastUpdated < ExpireTime select item.Key).ToArray <int>(); } foreach (int num in enumerable2) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - refreshing item AgentId:{0}", num); AgentDeploymentInfo agentDeploymentInfo = this.LoadAgentDeploymentInfo(num); obj = AgentDeploymentWatcher.syncLockItems; lock (obj) { AgentDeploymentWatcher.CacheItem cacheItem2; if (this.Items.TryGetValue(agentDeploymentInfo.Agent.AgentId, out cacheItem2)) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - updating item AgentId:{0}, Status:{1}", num, agentDeploymentInfo.StatusInfo.Status); cacheItem2.DeploymentInfo = agentDeploymentInfo; cacheItem2.LastUpdated = DateTime.Now; cacheItem2.RefreshNeeded = false; } else { AgentDeploymentWatcher.log.Debug("CheckItems - item not found in the cache"); } } } foreach (AgentDeploymentWatcher.CacheItem cacheItem3 in enumerable) { if (cacheItem3.OnFinishedCallback != null && (cacheItem3.DeploymentInfo.StatusInfo.Status == AgentDeploymentStatus.Finished || cacheItem3.DeploymentInfo.StatusInfo.Status == AgentDeploymentStatus.Failed)) { cacheItem3.OnFinishedCallback(cacheItem3.DeploymentInfo.StatusInfo.Status); } } }
public void AddOrUpdateDeploymentInfo(AgentDeploymentInfo deploymentInfo) { if (deploymentInfo == null) { throw new ArgumentNullException(nameof(deploymentInfo)); } if (deploymentInfo.get_Agent() == null) { throw new ArgumentNullException("deploymentInfo.Agent"); } AgentDeploymentWatcher.log.DebugFormat("AddOrUpdateDeploymentInfo started, agentId:{0}, status:{1}", (object)deploymentInfo.get_Agent().get_AgentId(), (object)deploymentInfo.get_StatusInfo().get_Status()); lock (AgentDeploymentWatcher.syncLockItems) { AgentDeploymentWatcher.CacheItem cacheItem; if (this.Items.TryGetValue(deploymentInfo.get_Agent().get_AgentId(), out cacheItem)) { AgentDeploymentWatcher.log.Debug((object)"AddOrUpdateDeploymentInfo - item found in cache, updating"); cacheItem.DeploymentInfo = deploymentInfo; } else { AgentDeploymentWatcher.log.Debug((object)"AddOrUpdateDeploymentInfo - item not found in cache, creating new item"); cacheItem = new AgentDeploymentWatcher.CacheItem() { DeploymentInfo = deploymentInfo }; cacheItem.LastChecked = DateTime.Now; this.Items[deploymentInfo.get_Agent().get_AgentId()] = cacheItem; } cacheItem.LastUpdated = DateTime.Now; cacheItem.RefreshNeeded = false; this.CheckWatcher(); } }
private void CheckItems(object state) { AgentDeploymentWatcher.log.Debug((object)"CheckItems started"); DateTime ExpireTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(120.0)); List <Action <AgentDeploymentStatus> > actionList = new List <Action <AgentDeploymentStatus> >(); IEnumerable <AgentDeploymentWatcher.CacheItem> array1; IEnumerable <int> array2; lock (AgentDeploymentWatcher.syncLockItems) { AgentDeploymentWatcher.log.Debug((object)"CheckItems - looking for items to remove"); array1 = (IEnumerable <AgentDeploymentWatcher.CacheItem>) this.Items.Where <KeyValuePair <int, AgentDeploymentWatcher.CacheItem> >((Func <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, bool>)(item => item.Value.DeploymentInfo.get_StatusInfo().get_Status() == 1 || item.Value.DeploymentInfo.get_StatusInfo().get_Status() == 2 || item.Value.LastChecked < ExpireTime)).Select <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, AgentDeploymentWatcher.CacheItem>((Func <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, AgentDeploymentWatcher.CacheItem>)(item => item.Value)).ToArray <AgentDeploymentWatcher.CacheItem>(); foreach (AgentDeploymentWatcher.CacheItem cacheItem in array1) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - removing item, AgentId:{0}", (object)cacheItem.DeploymentInfo.get_Agent().get_AgentId()); this.Items.Remove(cacheItem.DeploymentInfo.get_Agent().get_AgentId()); } if (this.Items.Count == 0) { AgentDeploymentWatcher.log.Debug((object)"CheckItems - No remaining items in the cache, stopping Watcher"); this.StopWatcher(); } AgentDeploymentWatcher.log.Debug((object)"CheckItems - looking for items to refresh"); array2 = (IEnumerable <int>) this.Items.Where <KeyValuePair <int, AgentDeploymentWatcher.CacheItem> >((Func <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, bool>)(item => item.Value.RefreshNeeded || item.Value.LastUpdated < ExpireTime)).Select <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, int>((Func <KeyValuePair <int, AgentDeploymentWatcher.CacheItem>, int>)(item => item.Key)).ToArray <int>(); } foreach (int agentId in array2) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - refreshing item AgentId:{0}", (object)agentId); AgentDeploymentInfo agentDeploymentInfo = this.LoadAgentDeploymentInfo(agentId); lock (AgentDeploymentWatcher.syncLockItems) { AgentDeploymentWatcher.CacheItem cacheItem; if (this.Items.TryGetValue(agentDeploymentInfo.get_Agent().get_AgentId(), out cacheItem)) { AgentDeploymentWatcher.log.DebugFormat("CheckItems - updating item AgentId:{0}, Status:{1}", (object)agentId, (object)agentDeploymentInfo.get_StatusInfo().get_Status()); cacheItem.DeploymentInfo = agentDeploymentInfo; cacheItem.LastUpdated = DateTime.Now; cacheItem.RefreshNeeded = false; } else { AgentDeploymentWatcher.log.Debug((object)"CheckItems - item not found in the cache"); } } } foreach (AgentDeploymentWatcher.CacheItem cacheItem in array1) { if (cacheItem.OnFinishedCallback != null && (cacheItem.DeploymentInfo.get_StatusInfo().get_Status() == 1 || cacheItem.DeploymentInfo.get_StatusInfo().get_Status() == 2)) { cacheItem.OnFinishedCallback(cacheItem.DeploymentInfo.get_StatusInfo().get_Status()); } } }
public int StartDeployingAgent(AgentDeploymentSettings settings) { AgentDeployer.log.Debug((object)"StartDeployingAgent entered"); AgentDeploymentWatcher instance = AgentDeploymentWatcher.GetInstance(this.agentInfoDal); instance.Start(); int agentId = this.DeployAgent(settings); instance.AddOrUpdateDeploymentInfo(AgentDeploymentInfo.Calculate(new AgentManager(this.agentInfoDal).GetAgentInfo(agentId), (IEnumerable <string>)settings.get_RequiredPlugins(), (string)null)); this.DeployMissingPlugins(agentId, (IEnumerable <string>)settings.get_RequiredPlugins()); return(agentId); }
// Token: 0x06000901 RID: 2305 RVA: 0x00040F7C File Offset: 0x0003F17C public int StartDeployingAgent(AgentDeploymentSettings settings) { AgentDeployer.log.Debug("StartDeployingAgent entered"); AgentDeploymentWatcher instance = AgentDeploymentWatcher.GetInstance(this.agentInfoDal); instance.Start(); int num = this.DeployAgent(settings); AgentInfo agentInfo = new AgentManager(this.agentInfoDal).GetAgentInfo(num); instance.AddOrUpdateDeploymentInfo(AgentDeploymentInfo.Calculate(agentInfo, settings.RequiredPlugins, null)); this.DeployMissingPlugins(num, settings.RequiredPlugins); return(num); }
// Token: 0x06000902 RID: 2306 RVA: 0x00040FE4 File Offset: 0x0003F1E4 public void StartDeployingPlugins(int agentId, IEnumerable <string> requiredPlugins, Action <AgentDeploymentStatus> onFinishedCallback = null) { AgentDeployer.log.Debug("StartDeployingPlugins entered"); AgentDeploymentInfo agentDeploymentInfo = AgentDeploymentInfo.Calculate(new AgentManager(this.agentInfoDal).GetAgentInfo(agentId), requiredPlugins, null); agentDeploymentInfo.StatusInfo = new AgentDeploymentStatusInfo(agentId, AgentDeploymentStatus.InProgress); AgentDeploymentWatcher instance = AgentDeploymentWatcher.GetInstance(this.agentInfoDal); instance.AddOrUpdateDeploymentInfo(agentDeploymentInfo); if (onFinishedCallback != null) { instance.SetOnFinishedCallback(agentId, onFinishedCallback); } this.DeployMissingPlugins(agentId, requiredPlugins); }
private AgentDeploymentInfo LoadAgentDeploymentInfo(int agentId) { AgentInfo agentInfo1 = new AgentManager(this.AgentInfoDal).GetAgentInfo(agentId); if (agentInfo1 != null) { string[] discoveryPluginIds = DiscoveryHelper.GetAgentDiscoveryPluginIds(); return(AgentDeploymentInfo.Calculate(agentInfo1, (IEnumerable <string>)discoveryPluginIds, (string)null)); } AgentDeploymentInfo agentDeploymentInfo = new AgentDeploymentInfo(); AgentInfo agentInfo2 = new AgentInfo(); agentInfo2.set_AgentId(agentId); agentDeploymentInfo.set_Agent(agentInfo2); agentDeploymentInfo.set_StatusInfo(new AgentDeploymentStatusInfo(agentId, (AgentDeploymentStatus)2, "Agent not found.")); return(agentDeploymentInfo); }
// Token: 0x06000917 RID: 2327 RVA: 0x00041AB0 File Offset: 0x0003FCB0 private AgentDeploymentInfo LoadAgentDeploymentInfo(int agentId) { AgentInfo agentInfo = new AgentManager(this.AgentInfoDal).GetAgentInfo(agentId); if (agentInfo != null) { string[] agentDiscoveryPluginIds = DiscoveryHelper.GetAgentDiscoveryPluginIds(); return(AgentDeploymentInfo.Calculate(agentInfo, agentDiscoveryPluginIds, null)); } return(new AgentDeploymentInfo { Agent = new AgentInfo { AgentId = agentId }, StatusInfo = new AgentDeploymentStatusInfo(agentId, AgentDeploymentStatus.Failed, "Agent not found.") }); }
public AgentDeploymentInfo GetAgentDeploymentInfo(int agentId) { AgentDeploymentWatcher.log.DebugFormat("GetAgentDeploymentInfo started, agentId:{0}", (object)agentId); AgentDeploymentInfo agentDeploymentInfo = (AgentDeploymentInfo)null; lock (AgentDeploymentWatcher.syncLockItems) { AgentDeploymentWatcher.CacheItem cacheItem; if (this.Items.TryGetValue(agentId, out cacheItem)) { agentDeploymentInfo = cacheItem.DeploymentInfo; cacheItem.LastChecked = DateTime.Now; AgentDeploymentWatcher.log.DebugFormat("GetAgentDeploymentInfo - item found in cache, agentId:{0}, status:{1}", (object)agentId, (object)agentDeploymentInfo.get_StatusInfo().get_Status()); } } if (agentDeploymentInfo == null) { agentDeploymentInfo = this.LoadAgentDeploymentInfo(agentId); AgentDeploymentWatcher.log.DebugFormat("GetAgentDeploymentInfo - item not found in cache, loading from db, agentId:{0}, status:{1}", (object)agentId, (object)agentDeploymentInfo.get_StatusInfo().get_Status()); } return(agentDeploymentInfo); }