当前位置: 首页>>代码示例>>Java>>正文


Java ProfilerEventHandler.consumeEvent方法代码示例

本文整理汇总了Java中com.mysql.jdbc.profiler.ProfilerEventHandler.consumeEvent方法的典型用法代码示例。如果您正苦于以下问题:Java ProfilerEventHandler.consumeEvent方法的具体用法?Java ProfilerEventHandler.consumeEvent怎么用?Java ProfilerEventHandler.consumeEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mysql.jdbc.profiler.ProfilerEventHandler的用法示例。


在下文中一共展示了ProfilerEventHandler.consumeEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: close

import com.mysql.jdbc.profiler.ProfilerEventHandler; //导入方法依赖的package包/类
/**
 * We're done.
 * 
 * @throws SQLException
 *             if a database error occurs
 */
public void close() throws SQLException {
    // Belt and suspenders here - if we don't have a reference to the connection it's more than likely dead/gone and we won't be able to consume rows anyway

    Object mutex = this;

    MySQLConnection conn = null;

    if (this.owner != null) {
        conn = this.owner.connection;

        if (conn != null) {
            mutex = conn.getConnectionMutex();
        }
    }

    boolean hadMore = false;
    int howMuchMore = 0;

    synchronized (mutex) {
        // drain the rest of the records.
        while (next() != null) {
            hadMore = true;
            howMuchMore++;

            if (howMuchMore % 100 == 0) {
                Thread.yield();
            }
        }

        if (conn != null) {
            if (!conn.getClobberStreamingResults() && conn.getNetTimeoutForStreamingResults() > 0) {
                String oldValue = conn.getServerVariable("net_write_timeout");

                if (oldValue == null || oldValue.length() == 0) {
                    oldValue = "60"; // the current default
                }

                this.io.clearInputStream();

                java.sql.Statement stmt = null;

                try {
                    stmt = conn.createStatement();
                    ((com.mysql.jdbc.StatementImpl) stmt).executeSimpleNonQuery(conn, "SET net_write_timeout=" + oldValue);
                } finally {
                    if (stmt != null) {
                        stmt.close();
                    }
                }
            }

            if (conn.getUseUsageAdvisor()) {
                if (hadMore) {

                    ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(conn);

                    eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN, "",
                            this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, this.owner.connectionId,
                            this.owner.owningStatement == null ? -1 : this.owner.owningStatement.getId(), -1, System.currentTimeMillis(), 0,
                            Constants.MILLIS_I18N, null, null,
                            Messages.getString("RowDataDynamic.2") + howMuchMore + Messages.getString("RowDataDynamic.3")
                                    + Messages.getString("RowDataDynamic.4") + Messages.getString("RowDataDynamic.5")
                                    + Messages.getString("RowDataDynamic.6") + this.owner.pointOfOrigin));
                }
            }
        }
    }

    this.metadata = null;
    this.owner = null;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:78,代码来源:RowDataDynamic.java

示例2: close

import com.mysql.jdbc.profiler.ProfilerEventHandler; //导入方法依赖的package包/类
/**
 * We're done.
 * 
 * @throws SQLException
 *             if a database error occurs
 */
public void close() throws SQLException {
    // Belt and suspenders here - if we don't have a reference to the connection it's more than likely dead/gone and we won't be able to consume rows anyway

    Object mutex = this;

    MySQLConnection conn = null;

    if (this.owner != null) {
        conn = this.owner.connection;

        if (conn != null) {
            mutex = conn.getConnectionMutex();
        }
    }

    boolean hadMore = false;
    int howMuchMore = 0;

    synchronized (mutex) {
        // drain the rest of the records.
        while (next() != null) {
            hadMore = true;
            howMuchMore++;

            if (howMuchMore % 100 == 0) {
                Thread.yield();
            }
        }

        if (conn != null) {
            if (!conn.getClobberStreamingResults() && conn.getNetTimeoutForStreamingResults() > 0) {
                String oldValue = conn.getServerVariable("net_write_timeout");

                if (oldValue == null || oldValue.length() == 0) {
                    oldValue = "60"; // the current default
                }

                this.io.clearInputStream();

                java.sql.Statement stmt = null;

                try {
                    stmt = conn.createStatement();
                    ((com.mysql.jdbc.StatementImpl) stmt).executeSimpleNonQuery(conn, "SET net_write_timeout=" + oldValue);
                } finally {
                    if (stmt != null) {
                        stmt.close();
                    }
                }
            }

            if (conn.getUseUsageAdvisor()) {
                if (hadMore) {

                    ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(conn);

                    eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN, "", this.owner.owningStatement == null ? "N/A"
                            : this.owner.owningStatement.currentCatalog, this.owner.connectionId, this.owner.owningStatement == null ? -1
                            : this.owner.owningStatement.getId(), -1, System.currentTimeMillis(), 0, Constants.MILLIS_I18N, null, null, Messages
                            .getString("RowDataDynamic.2")
                            + howMuchMore
                            + Messages.getString("RowDataDynamic.3")
                            + Messages.getString("RowDataDynamic.4")
                            + Messages.getString("RowDataDynamic.5") + Messages.getString("RowDataDynamic.6") + this.owner.pointOfOrigin));
                }
            }
        }
    }

    this.metadata = null;
    this.owner = null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:79,代码来源:RowDataDynamic.java


注:本文中的com.mysql.jdbc.profiler.ProfilerEventHandler.consumeEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。