Search in sources :

Example 11 with ResultList

use of com.yahoo.dba.perf.myperf.common.ResultList in project mysql_perf_analyzer by yahoo.

the class InnoController method buildSemapList.

private ResultList buildSemapList(List<SemaphoreEntry> semapList) {
    ResultList rList = new ResultList();
    ColumnDescriptor desc = new ColumnDescriptor();
    int idx = 1;
    desc.addColumn("THREAD_ID", false, idx++);
    desc.addColumn("LOCK_TYPE", false, idx++);
    desc.addColumn("LOCK_NAME", false, idx++);
    desc.addColumn("MODE", false, idx++);
    desc.addColumn("LOCATION", false, idx++);
    desc.addColumn("TIME_SEC", false, idx++);
    desc.addColumn("HOLDER", false, idx++);
    desc.addColumn("HODL_MODE", false, idx++);
    desc.addColumn("WAITED_AT", false, idx++);
    rList.setColumnDescriptor(desc);
    for (SemaphoreEntry tx : semapList) {
        if (tx.thread_id == null)
            continue;
        ResultRow row = new ResultRow();
        rList.addRow(row);
        row.setColumnDescriptor(desc);
        List<String> cols = new ArrayList<String>(16);
        row.setColumns(cols);
        cols.add(tx.thread_id);
        cols.add(tx.lock_type);
        cols.add(tx.lock_name);
        cols.add(tx.request_mode);
        cols.add(tx.lock_loc);
        cols.add(tx.waited_time);
        cols.add(tx.lock_holder);
        cols.add(tx.hold_mode);
        cols.add(tx.waited_at);
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) ArrayList(java.util.ArrayList)

Example 12 with ResultList

use of com.yahoo.dba.perf.myperf.common.ResultList in project mysql_perf_analyzer by yahoo.

the class InnoController method buildDeadlockList.

private static ResultList buildDeadlockList(List<String> infoList) {
    ResultList rList = new ResultList();
    ColumnDescriptor desc = new ColumnDescriptor();
    int idx = 1;
    desc.addColumn("INFO", false, idx++);
    //TODO lock strcuts
    rList.setColumnDescriptor(desc);
    for (String tx : infoList) {
        ResultRow row = new ResultRow();
        rList.addRow(row);
        row.setColumnDescriptor(desc);
        List<String> cols = new ArrayList<String>(1);
        row.setColumns(cols);
        cols.add(tx);
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) ArrayList(java.util.ArrayList)

Example 13 with ResultList

use of com.yahoo.dba.perf.myperf.common.ResultList in project mysql_perf_analyzer by yahoo.

the class InnoController method createHeader.

private ResultList createHeader(Map<String, String> valMap) {
    ResultList rList = new ResultList();
    ColumnDescriptor desc = new ColumnDescriptor();
    desc.addColumn("NAME", false, 1);
    desc.addColumn("VALUE", false, 2);
    rList.setColumnDescriptor(desc);
    for (Map.Entry<String, String> e : valMap.entrySet()) {
        ResultRow row = new ResultRow();
        List<String> vals = new ArrayList<String>(2);
        vals.add(e.getKey());
        vals.add(e.getValue());
        row.setColumnDescriptor(desc);
        row.setColumns(vals);
        rList.addRow(row);
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 14 with ResultList

use of com.yahoo.dba.perf.myperf.common.ResultList in project mysql_perf_analyzer by yahoo.

the class AlertReportRunner method run.

@Override
public void run() {
    AlertEntry alertEntry = new AlertEntry(timestamp, alertReason, alertValue, dbInfo.getDbGroupName(), dbInfo.getHostName());
    this.context.getAlerts().addAlert(alertEntry);
    ResultSet rs = null;
    Statement stmt = null;
    long reportTimestamp = System.currentTimeMillis();
    List<ProcessListEntry> prList = new ArrayList<ProcessListEntry>();
    java.util.LinkedHashMap<String, String> repMap = new java.util.LinkedHashMap<String, String>();
    String innodbStatus = null;
    ResultList rList = null;
    ResultList clientList = null;
    try {
        stmt = connection.getConnection().createStatement();
        stmt.setFetchSize(5000);
        //stmt.setMaxRows(5000);
        //rs = stmt.executeQuery("select * from information_schema.processlist limit 5000");
        //remove limit to handle the case of very large connections
        rs = stmt.executeQuery("select * from information_schema.processlist");
        boolean hasRowInfo = rs != null && hasRowInfo(rs);
        boolean hasRowRead = rs != null && hasRowsRead(rs);
        while (rs != null && rs.next()) {
            ProcessListEntry ps = new ProcessListEntry(rs, hasRowInfo, hasRowRead);
            prList.add(ps);
        }
        if ("REPLLAG".equalsIgnoreCase(this.alertReason) || "REPLDOWN".equalsIgnoreCase(this.alertReason)) {
            DBUtils.close(rs);
            rs = stmt.executeQuery("show slave status");
            int i = 0;
            int cnt = rs.getMetaData().getColumnCount();
            while (rs != null && rs.next()) {
                String suffix = "";
                if (i > 0)
                    suffix = "_" + i;
                for (int k = 0; k < cnt; k++) repMap.put(rs.getMetaData().getColumnName(k + 1) + suffix, rs.getString(k + 1));
                i++;
            }
        }
        //if ("CPU".equalsIgnoreCase(alertReason) ||"THREAD".equalsIgnoreCase(alertReason)||"REPLLAG".equalsIgnoreCase(this.alertReason))
        {
            DBUtils.close(rs);
            rs = stmt.executeQuery("show engine innodb status");
            if (rs != null && rs.next()) {
                innodbStatus = rs.getString("Status");
            }
            DBUtils.close(rs);
            rs = stmt.executeQuery("select * from information_schema.innodb_locks");
            if (rs != null) {
                rList = ResultListUtil.fromSqlResultSet(rs, 5000);
            }
        }
        //TODO we need two snapshot to get useful data			
        if ("CONNECT_FAILURE".equalsIgnoreCase(alertReason)) {
            //dump summary of processlist if possible
            String sql = "select user, host, command, count(*) conns from information_schema.processlist group by user, host, command";
            DBUtils.close(rs);
            rs = stmt.executeQuery(sql);
            if (rs != null) {
                clientList = ResultListUtil.fromSqlResultSet(rs, 5000);
            }
            DBUtils.close(rs);
        }
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Error when retrieve alert detail", ex);
    } finally {
        DBUtils.close(rs);
        DBUtils.close(stmt);
    }
    if (prList.size() > 0 || repMap.size() > 0) {
        //sort by sql text
        java.util.Collections.sort(prList);
        ProcessListSummary prSum = new ProcessListSummary();
        prSum.setProcessList(prList);
        prSum.setInnodbStatus(innodbStatus);
        prSum.setLockList(rList);
        //prSum.setClientList(clientList);
        prSum.setReportTimestamp(reportTimestamp);
        prSum.summarize();
        AlertReport ar = this.context.createAlertReport(reportTimestamp, alertEntry);
        ar.setProcessListSummary(prSum);
        if (repMap.size() > 0)
            ar.setReplicationSummary(repMap);
        ar.saveAsText();
    }
    if (this.dbInfo.isAlertEnabled())
        this.context.emailAlert(alertEntry);
}
Also used : ResultList(com.yahoo.dba.perf.myperf.common.ResultList) AlertEntry(com.yahoo.dba.perf.myperf.common.AlertEntry) Statement(java.sql.Statement) AlertReport(com.yahoo.dba.perf.myperf.common.AlertReport) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) ProcessListSummary(com.yahoo.dba.perf.myperf.common.ProcessListSummary) ResultSet(java.sql.ResultSet) ProcessListEntry(com.yahoo.dba.perf.myperf.common.ProcessListEntry)

Example 15 with ResultList

use of com.yahoo.dba.perf.myperf.common.ResultList in project mysql_perf_analyzer by yahoo.

the class SNMPQueryProcessor method queryNetwork.

private ResultList queryNetwork(SNMPClient client, QueryParameters qps) throws Exception {
    boolean diff = "1".equalsIgnoreCase(qps.getSqlParams().get("p_2"));
    Map<String, List<SNMPTriple>> snmpData = client.getNetIfData(null);
    if (snmpData == null)
        return null;
    ColumnDescriptor desc = new ColumnDescriptor();
    desc.addColumn("NAME", false, 0);
    desc.addColumn("OID", false, 1);
    desc.addColumn("VALUE", false, 2);
    ResultList rList = new ResultList();
    rList.setColumnDescriptor(desc);
    for (Map.Entry<String, List<SNMPTriple>> e : snmpData.entrySet()) {
        String net = e.getKey();
        for (SNMPTriple t : e.getValue()) {
            if (diff) {
                try {
                    BigDecimal bd = new BigDecimal(t.value);
                } catch (Exception ex) {
                    continue;
                }
            }
            ResultRow row = new ResultRow();
            row.addColumn(net + "." + t.name);
            row.addColumn(t.oid);
            row.addColumn(t.value);
            row.setColumnDescriptor(desc);
            rList.addRow(row);
        }
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) SNMPTriple(com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple) List(java.util.List) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) Map(java.util.Map) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Aggregations

ResultList (com.yahoo.dba.perf.myperf.common.ResultList)31 ResultRow (com.yahoo.dba.perf.myperf.common.ResultRow)22 ColumnDescriptor (com.yahoo.dba.perf.myperf.common.ColumnDescriptor)21 SQLException (java.sql.SQLException)17 ArrayList (java.util.ArrayList)10 Map (java.util.Map)9 ResultSet (java.sql.ResultSet)8 SNMPTriple (com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple)7 Connection (java.sql.Connection)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 DBInstanceInfo (com.yahoo.dba.perf.myperf.common.DBInstanceInfo)6 QueryParameters (com.yahoo.dba.perf.myperf.common.QueryParameters)6 PreparedStatement (java.sql.PreparedStatement)6 BigDecimal (java.math.BigDecimal)5 List (java.util.List)5 HashMap (java.util.HashMap)4 Statement (java.sql.Statement)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 ColumnInfo (com.yahoo.dba.perf.myperf.common.ColumnInfo)2