/// <summary> /// Setup the table counters used for gathering statistics /// </summary> public void initializeCounters() { //Initialize row counter int currentRows = 0; TableOperation getRowCount = TableOperation.Retrieve <rowCount>("rowCount", "totalRows"); TableResult retrievedRowCount = stattable.Execute(getRowCount); if (retrievedRowCount.Result != null) { currentRows = (((rowCount)retrievedRowCount.Result).count); } rowCount countStart = new rowCount(currentRows); TableOperation insertCountStart = TableOperation.InsertOrReplace(countStart); stattable.Execute(insertCountStart); //Initialize crawler to stop adminNode stopCrawl = new adminNode("stopCrawl"); TableOperation insertAdminNode = TableOperation.InsertOrReplace(stopCrawl); stattable.Execute(insertAdminNode); //Initialize preformance counters performanceNode newPerformance = new performanceNode("None", "None"); TableOperation insertPerformanceNode = TableOperation.InsertOrReplace(newPerformance); stattable.Execute(insertPerformanceNode); }
/// <summary> /// Setup the table counters used for gathering statistics /// </summary> public void initializeCounters() { //Initialize url row counter int currentUrlRows = 0; rowCount urlCountStart = new rowCount(currentUrlRows); TableOperation insertUrlCountStart = TableOperation.InsertOrReplace(urlCountStart); stattable.Execute(insertUrlCountStart); //Initialize crawler to stop adminNode stopCrawl = new adminNode("stopCrawl"); TableOperation insertAdminNode = TableOperation.InsertOrReplace(stopCrawl); stattable.Execute(insertAdminNode); //Initialize preformance counters performanceNode newPerformance = new performanceNode("None", "None"); TableOperation insertPerformanceNode = TableOperation.InsertOrReplace(newPerformance); stattable.Execute(insertPerformanceNode); }
/// <summary> /// Updates the performance counter table counters for both processor usage and memory usage /// </summary> private void updatePerformanceCounter() { PerformanceCounter cpuCounter = new PerformanceCounter(); PerformanceCounter memProcess = new PerformanceCounter("Memory", "Available MBytes"); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; string cpu = (getCurrentCpuUsage(cpuCounter)); string ram = (getAvailableMBytes(memProcess)); TableOperation getPerformanceNode = TableOperation.Retrieve <performanceNode>("performance", "counter"); TableResult retrievedPerformanceNode = stattable.Execute(getPerformanceNode); performanceNode newPerformanceNode = (performanceNode)retrievedPerformanceNode.Result; if (newPerformanceNode != null) { newPerformanceNode.cpu = cpu; newPerformanceNode.ram = ram; TableOperation updatePerformanceNode = TableOperation.Replace(newPerformanceNode); stattable.Execute(updatePerformanceNode); } }