Package com.mysql.jdbc.profiler

Examples of com.mysql.jdbc.profiler.ProfilerEventHandler


   * @param conn
   *            the connection to handle events for
   * @return the ProfilerEventHandlerFactory that handles profiler events
   */
  public static synchronized ProfilerEventHandler getInstance(MySQLConnection conn) throws SQLException {
    ProfilerEventHandler handler = CONNECTIONS_TO_SINKS
        .get(conn);

    if (handler == null) {
      handler = (ProfilerEventHandler)Util.getInstance(conn.getProfilerEventHandler(), new Class[0], new Object[0], conn.getExceptionInterceptor());
     
View Full Code Here


    return handler;
  }

  public static synchronized void removeInstance(Connection conn) {
    ProfilerEventHandler handler = CONNECTIONS_TO_SINKS.remove(conn);
   
    if (handler != null) {
      handler.destroy();
    }
  }
View Full Code Here

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

            ProfilerEventHandler eventSink = ProfilerEventHandlerFactory
            .getInstance(conn);

            eventSink
            .consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN,
                "", //$NON-NLS-1$
                this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, //$NON-NLS-1$
                this.owner.connectionId,
View Full Code Here

                  " 95% of all queries " : this.slowQueryThreshold),
              queryTimingUnits,
              Long.valueOf(queryEndTime - queryStartTime)}));
          mesgBuf.append(profileQueryToLog);

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_SLOW_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (int) (queryEndTime - queryStartTime), queryTimingUnits, null,
                  LogUtils.findCallingClassAndMethod(new Throwable()), mesgBuf.toString()));

          if (this.connection.getExplainSlowQueries()) {
            if (oldPacketPosition < MAX_QUERY_SIZE_TO_EXPLAIN) {
              explainSlowQuery(queryPacket.getBytes(5,
                  (oldPacketPosition - 5)), profileQueryToLog);
            } else {
              this.connection.getLog().logWarn(Messages.getString(
                  "MysqlIO.28") //$NON-NLS-1$
                  +MAX_QUERY_SIZE_TO_EXPLAIN +
                  Messages.getString("MysqlIO.29")); //$NON-NLS-1$
            }
          }
        }

        if (this.logSlowQueries) {

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          if (this.queryBadIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.33") //$NON-NLS-1$
                    +profileQueryToLog));
          }

          if (this.queryNoIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.35") //$NON-NLS-1$
                    +profileQueryToLog));
          }
         
          if (this.serverQueryWasSlow && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.ServerSlowQuery") //$NON-NLS-1$
                    +profileQueryToLog));
          }
        }

        if (this.profileSql) {
          fetchEndTime = getCurrentTimeNanosOrMillis();

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (queryEndTime - queryStartTime), this.queryTimingUnits,
                  null,
                  LogUtils.findCallingClassAndMethod(new Throwable()), profileQueryToLog));

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_FETCH,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (fetchEndTime - fetchBeginTime), this.queryTimingUnits,
                  null,
View Full Code Here

              new Object[] {new Long(this.slowQueryThreshold),
              queryTimingUnits,
              new Long(queryEndTime - queryStartTime)}));
          mesgBuf.append(profileQueryToLog);

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_SLOW_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (int) (queryEndTime - queryStartTime), queryTimingUnits, null,
                  new Throwable(), mesgBuf.toString()));

          if (this.connection.getExplainSlowQueries()) {
            if (oldPacketPosition < MAX_QUERY_SIZE_TO_EXPLAIN) {
              explainSlowQuery(queryPacket.getBytes(5,
                  (oldPacketPosition - 5)), profileQueryToLog);
            } else {
              this.connection.getLog().logWarn(Messages.getString(
                  "MysqlIO.28") //$NON-NLS-1$
                  +MAX_QUERY_SIZE_TO_EXPLAIN +
                  Messages.getString("MysqlIO.29")); //$NON-NLS-1$
            }
          }
        }

        if (this.logSlowQueries) {

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          if (this.queryBadIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    new Throwable(),
                    Messages.getString("MysqlIO.33") //$NON-NLS-1$
                    +profileQueryToLog));
          }

          if (this.queryNoIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    new Throwable(),
                    Messages.getString("MysqlIO.35") //$NON-NLS-1$
                    +profileQueryToLog));
          }
         
          if (this.serverQueryWasSlow && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    new Throwable(),
                    Messages.getString("MysqlIO.ServerSlowQuery") //$NON-NLS-1$
                    +profileQueryToLog));
          }
        }

        if (this.profileSql) {
          fetchEndTime = getCurrentTimeNanosOrMillis();

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (queryEndTime - queryStartTime), this.queryTimingUnits,
                  null,
                  new Throwable(), profileQueryToLog));

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_FETCH,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (fetchEndTime - fetchBeginTime), this.queryTimingUnits,
                  null,
View Full Code Here

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

            ProfilerEventHandler eventSink = ProfilerEventHandlerFactory
            .getInstance(conn);

            eventSink
            .consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN,
                "", //$NON-NLS-1$
                this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, //$NON-NLS-1$
                this.owner.connectionId,
View Full Code Here

   * @param conn
   *            the connection to handle events for
   * @return the ProfilerEventHandlerFactory that handles profiler events
   */
  public static synchronized ProfilerEventHandler getInstance(MySQLConnection conn) throws SQLException {
    ProfilerEventHandler handler = (ProfilerEventHandler) CONNECTIONS_TO_SINKS
        .get(conn);

    if (handler == null) {
      handler = (ProfilerEventHandler)Util.getInstance(conn.getProfilerEventHandler(), new Class[0], new Object[0], conn.getExceptionInterceptor());
     
View Full Code Here

    return handler;
  }

  public static synchronized void removeInstance(Connection conn) {
    ProfilerEventHandler handler = (ProfilerEventHandler) CONNECTIONS_TO_SINKS.remove(conn);
   
    if (handler != null) {
      handler.destroy();
    }
  }
View Full Code Here

                  " 95% of all queries " : this.slowQueryThreshold),
              queryTimingUnits,
              Long.valueOf(queryEndTime - queryStartTime)}));
          mesgBuf.append(profileQueryToLog);

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_SLOW_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (int) (queryEndTime - queryStartTime), queryTimingUnits, null,
                  LogUtils.findCallingClassAndMethod(new Throwable()), mesgBuf.toString()));

          if (this.connection.getExplainSlowQueries()) {
            if (oldPacketPosition < MAX_QUERY_SIZE_TO_EXPLAIN) {
              explainSlowQuery(queryPacket.getBytes(5,
                  (oldPacketPosition - 5)), profileQueryToLog);
            } else {
              this.connection.getLog().logWarn(Messages.getString(
                  "MysqlIO.28") //$NON-NLS-1$
                  +MAX_QUERY_SIZE_TO_EXPLAIN +
                  Messages.getString("MysqlIO.29")); //$NON-NLS-1$
            }
          }
        }

        if (this.logSlowQueries) {

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          if (this.queryBadIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.33") //$NON-NLS-1$
                    +profileQueryToLog));
          }

          if (this.queryNoIndexUsed && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.35") //$NON-NLS-1$
                    +profileQueryToLog));
          }
         
          if (this.serverQueryWasSlow && this.profileSql) {
            eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
                this.connection.getId(),
                (callingStatement != null) ? callingStatement.getId()
                    : 999, ((ResultSetImpl)rs).resultId,
                    System.currentTimeMillis(),
                    (queryEndTime - queryStartTime), this.queryTimingUnits,
                    null,
                    LogUtils.findCallingClassAndMethod(new Throwable()),
                    Messages.getString("MysqlIO.ServerSlowQuery") //$NON-NLS-1$
                    +profileQueryToLog));
          }
        }

        if (this.profileSql) {
          fetchEndTime = getCurrentTimeNanosOrMillis();

          ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_QUERY,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (queryEndTime - queryStartTime), this.queryTimingUnits,
                  null,
                  LogUtils.findCallingClassAndMethod(new Throwable()), profileQueryToLog));

          eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_FETCH,
              "", catalog, this.connection.getId(), //$NON-NLS-1$
              (callingStatement != null) ? callingStatement.getId() : 999,
                  ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
                  (fetchEndTime - fetchBeginTime), this.queryTimingUnits,
                  null,
View Full Code Here

   * @param conn
   *            the connection to handle events for
   * @return the ProfilerEventHandlerFactory that handles profiler events
   */
  public static synchronized ProfilerEventHandler getInstance(MySQLConnection conn) throws SQLException {
    ProfilerEventHandler handler = (ProfilerEventHandler) CONNECTIONS_TO_SINKS
        .get(conn);

    if (handler == null) {
      handler = (ProfilerEventHandler)Util.getInstance(conn.getProfilerEventHandler(), new Class[0], new Object[0], conn.getExceptionInterceptor());
     
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.profiler.ProfilerEventHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.