public SystemSummary GetSystemSummary() { // calculate total number of executors ExecutorStorageView[] executors = GetExecutors(); ApplicationStorageView[] applications = GetApplications(); ThreadStorageView[] threads = GetThreads(); int totalExecutors = executors != null ? executors.Length : 0; // calculate number of unfinished applications int unfinishedApps = 0; foreach (ApplicationStorageView application in applications) { if (application.State == ApplicationState.AwaitingManifest || application.State == ApplicationState.Ready) { unfinishedApps++; } } int unfinishedThreads = 0; foreach (ThreadStorageView thread in threads) { if (thread.State != ThreadState.Dead && thread.State != ThreadState.Finished) { unfinishedThreads++; } } float maxPowerValue = 0; int powerUsage = 0; int powerAvailable = 0; float totalUsageValue = 0; int connectedExecutorCount = 0; foreach (ExecutorStorageView executor in executors) { if (executor.Connected) { connectedExecutorCount++; maxPowerValue += executor.MaxCpu; powerAvailable += executor.AvailableCpu; powerUsage += executor.CpuUsage; totalUsageValue += executor.TotalCpuUsage * executor.MaxCpu / (3600 * 1000); } } if (connectedExecutorCount != 0) { powerAvailable /= connectedExecutorCount; powerUsage /= connectedExecutorCount; } else { powerAvailable = 0; powerUsage = 0; } string powerTotalUsage = String.Format("{0} GHz*Hr", Math.Round(totalUsageValue, 6)); string maxPower = String.Format("{0} GHz", Math.Round(maxPowerValue / 1000, 6)); SystemSummary summary = new SystemSummary( maxPower, totalExecutors, powerUsage, powerAvailable, powerTotalUsage, unfinishedApps, unfinishedThreads); return summary; }
public SystemSummary GetSystemSummary() { // calculate total number of executors Int32 totalExecutors = m_executors != null ? m_executors.Count : 0; // calculate number of unfinished applications Int32 unfinishedApps = 0; if (m_applications != null) { foreach(ApplicationStorageView application in m_applications) { if (application.State == ApplicationState.AwaitingManifest || application.State == ApplicationState.Ready) { unfinishedApps++; } } } Int32 unfinishedThreads = 0; if (m_threads != null) { foreach(ThreadStorageView thread in m_threads) { if (thread.State != ThreadState.Dead && thread.State != ThreadState.Finished) { unfinishedThreads++; } } } float maxPowerValue = 0; Int32 powerUsage = 0; Int32 powerAvailable = 0; float totalUsageValue = 0; if (m_executors != null) { int connectedExecutorCount = 0; foreach(ExecutorStorageView executor in m_executors) { if (executor.Connected) { connectedExecutorCount++; maxPowerValue += executor.MaxCpu; powerAvailable += executor.AvailableCpu; powerUsage += executor.CpuUsage; totalUsageValue += executor.TotalCpuUsage * executor.MaxCpu / (3600 * 1000); } } powerAvailable /= connectedExecutorCount; powerUsage /= connectedExecutorCount; } String powerTotalUsage = String.Format("{0} GHz*Hr", Math.Round(totalUsageValue, 6)); String maxPower = String.Format("{0} GHz", Math.Round(maxPowerValue / 1000, 6)); SystemSummary summary = new SystemSummary( maxPower, totalExecutors, powerUsage, powerAvailable, powerTotalUsage, unfinishedApps, unfinishedThreads); return summary; }
/// <summary> /// GetSystemSummary implementation for RDBMS. /// </summary> /// <returns></returns> public SystemSummary GetSystemSummary() { //build the System_Summary SQLs string powerUsageSqlQuery = this.GetPowerUsageSqlQuery(); string unfinishedThreadCountSqlQuery = this.GetUnfinishedThreadCountSqlQuery(); string unfinishedApplicationCountSqlQuery = this.GetUnfinishedApplicationCountSqlQuery(); SystemSummary summary = null; string maxPower= null; int totalExecutors = 0; int powerUsage = 0; int powerAvailable = 0; string powerTotalUsage = null; int unfinishedApps = 0; int unfinishedThreads = 0; try { using (IDataReader dataReader = RunSqlReturnDataReader(powerUsageSqlQuery)) { if (dataReader.Read()) { maxPower = String.Format("{0} GHz", (double)dataReader.GetInt32(dataReader.GetOrdinal("max_power")) / 1000); totalExecutors = dataReader.GetInt32(dataReader.GetOrdinal("total_executors")); powerUsage = dataReader.GetInt32(dataReader.GetOrdinal("power_usage")); powerAvailable = dataReader.GetInt32(dataReader.GetOrdinal("power_avail")); powerTotalUsage = String.Format("{0} GHz*Hr", Math.Round(dataReader.GetDouble(dataReader.GetOrdinal("power_totalusage")), 6)); } dataReader.Close(); } unfinishedThreads = Convert.ToInt32(RunSqlReturnScalar(unfinishedThreadCountSqlQuery)); unfinishedApps = Convert.ToInt32(RunSqlReturnScalar(unfinishedApplicationCountSqlQuery)); } catch (Exception ex) { logger.Debug("Error getting system summary:",ex); } summary = new SystemSummary( maxPower, totalExecutors, powerUsage, powerAvailable, powerTotalUsage, unfinishedApps, unfinishedThreads); return summary; }
/// <summary> /// GetSystemSummary implementation for RDBMS. /// </summary> /// <returns></returns> public SystemSummary GetSystemSummary() { //build the System_Summary SQLs string sqlQuery1 = String.Format( "select count(*) as total_executors, "+ "{0}(sum(cpu_max), 0) as max_power,"+ "{0}(avg(cpu_usage), 0) as power_usage, {0}(avg(cpu_avail), 0) as power_avail,"+ "{0}(sum(cpu_totalusage * cpu_max / (3600 * 1000)), 0) as power_totalusage "+ "from executor where is_connected = 1 ", IsNullOperator); string sqlQuery2 = "select count(*) as unfinished_threads from thread where state not in (3, 4)"; string sqlQuery3 = "select count(*) as unfinished_apps " + "from application " + "where state not in (0,1) "; SystemSummary summary = null; String maxPower= null; Int32 totalExecutors = 0; Int32 powerUsage = 0; Int32 powerAvailable = 0; String powerTotalUsage = null; Int32 unfinishedApps = 0; Int32 unfinishedThreads = 0; try { //query1, to get power usage and other details using (IDataReader dataReader = RunSqlReturnDataReader(sqlQuery1)) { if (dataReader.Read()) { maxPower = String.Format("{0} GHz", (double)dataReader.GetInt32(dataReader.GetOrdinal("max_power")) / 1000); totalExecutors = dataReader.GetInt32(dataReader.GetOrdinal("total_executors")); powerUsage = dataReader.GetInt32(dataReader.GetOrdinal("power_usage")); powerAvailable = dataReader.GetInt32(dataReader.GetOrdinal("power_avail")); powerTotalUsage = String.Format("{0} GHz*Hr", Math.Round(dataReader.GetDouble(dataReader.GetOrdinal("power_totalusage")), 6)); } dataReader.Close(); } //query2 to get thread count unfinishedThreads = Convert.ToInt32(RunSqlReturnScalar(sqlQuery2)); //query3 to get app count unfinishedApps = Convert.ToInt32(RunSqlReturnScalar(sqlQuery3)); } catch (Exception ex) { logger.Debug("Error getting system summary:",ex); } summary = new SystemSummary( maxPower, totalExecutors, powerUsage, powerAvailable, powerTotalUsage, unfinishedApps, unfinishedThreads); return summary; }