use of com.yahoo.dba.perf.myperf.common.ColumnInfo in project mysql_perf_analyzer by yahoo.
the class InnoDbMutexPostProccessor method process.
@Override
public ResultList process(ResultList rs) {
TreeMap<String, MutexName> mutexMetrics = new TreeMap<String, MutexName>();
if (rs != null && rs.getRows().size() > 0) {
int typeIdx = 0;
int nameIdx = 1;
int statusIdx = 2;
List<ColumnInfo> colList = rs.getColumnDescriptor().getColumns();
for (int i = 0; i < colList.size(); i++) {
if ("Type".equalsIgnoreCase(colList.get(i).getName()))
typeIdx = i;
else if ("Name".equalsIgnoreCase(colList.get(i).getName()))
nameIdx = i;
else if ("Status".equalsIgnoreCase(colList.get(i).getName()))
statusIdx = i;
}
for (ResultRow row : rs.getRows()) {
try {
List<String> sList = row.getColumns();
String type = sList.get(typeIdx);
String name = sList.get(nameIdx);
String status = sList.get(statusIdx);
//split status to name value pair
String[] nv = status.split("=");
String key = type + "|" + name + "|" + nv[0];
int val = Integer.parseInt(nv[1]);
if (!mutexMetrics.containsKey(key)) {
mutexMetrics.put(key, new MutexName(type, name, nv[0]));
}
mutexMetrics.get(key).val += val;
mutexMetrics.get(key).count++;
} catch (Exception ex) {
}
}
}
//now build new List
ResultList rlist = new ResultList();
ColumnDescriptor desc = new ColumnDescriptor();
desc.addColumn("NAME", false, 0);
desc.addColumn("VALUE", true, 1);
desc.addColumn("COUNT", true, 2);
rlist.setColumnDescriptor(desc);
for (MutexName m : mutexMetrics.values()) {
ResultRow row = new ResultRow();
row.setColumnDescriptor(desc);
row.addColumn(m.type + "/" + m.name + "/" + m.waitType);
row.addColumn(String.valueOf(m.val));
row.addColumn(String.valueOf(m.count));
rlist.addRow(row);
}
return rlist;
}
use of com.yahoo.dba.perf.myperf.common.ColumnInfo in project mysql_perf_analyzer by yahoo.
the class MySQLStatusQueryProcessor method querySingle.
@Override
public ResultList querySingle(MyPerfContext context, DBInstanceInfo dbinfo, String appUser, DBConnectionWrapper connWrapper, QueryParameters qps) throws SQLException {
QueryParameters qps2 = new QueryParameters();
qps2.setSql("mysql_show_global_status");
ResultList rList = null;
rList = context.getQueryEngine().executeQueryGeneric(qps2, connWrapper, qps.getMaxRows());
if (rList != null) {
ResultList newList = new ResultList();
ColumnDescriptor desc = rList.getColumnDescriptor();
ColumnDescriptor newDesc = new ColumnDescriptor();
int idx = 0;
int nameIdx = 0;
for (ColumnInfo c : desc.getColumns()) {
if ("VARIABLE_NAME".equalsIgnoreCase(c.getName()))
nameIdx = idx;
if ("VALUE".equalsIgnoreCase(c.getName()))
newDesc.addColumn("VARIABLE_VALUE", c.isNumberType(), idx++);
else
newDesc.addColumn(c.getName().toUpperCase(), c.isNumberType(), idx++);
}
newList.setColumnDescriptor(newDesc);
for (ResultRow row : rList.getRows()) {
ResultRow newRow = new ResultRow();
newRow.setColumnDescriptor(newDesc);
int cols = row.getColumns().size();
for (int i = 0; i < cols; i++) {
String v = row.getColumns().get(i);
if (i == nameIdx) {
newRow.addColumn(v == null ? null : v.toUpperCase());
} else
newRow.addColumn(v);
}
newList.addRow(newRow);
}
return newList;
}
return null;
}
Aggregations