Package com.mysql.jdbc.profiler

Examples of com.mysql.jdbc.profiler.ProfilerEvent


      this.connection.incrementNumberOfPreparedExecutes();

      if (this.connection.getProfileSql()) {
        this.eventSink = ProfileEventSink.getInstance(this.connection);

        this.eventSink.consumeEvent(new ProfilerEvent(
            ProfilerEvent.TYPE_EXECUTE, "", this.currentCatalog, //$NON-NLS-1$
            this.connection.getId(), this.statementId, -1, System
                .currentTimeMillis(), (int) (System
                .currentTimeMillis() - begin), null,
            new Throwable(), truncateQueryToLog(asSql(true))));
View Full Code Here


        if (this.connection.getProfileSql()) {
          this.eventSink = ProfileEventSink
              .getInstance(this.connection);

          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_PREPARE,
              "", this.currentCatalog, //$NON-NLS-1$
              this.connection.getId(), this.statementId, -1,
              System.currentTimeMillis(), (int) (System
                  .currentTimeMillis() - begin), null,
View Full Code Here

    if (this.useUsageAdvisor) {
      if (!calledExplicitly) {
        String message = Messages.getString("Statement.63") //$NON-NLS-1$
            + Messages.getString("Statement.64"); //$NON-NLS-1$

        this.eventSink.consumeEvent(new ProfilerEvent(
            ProfilerEvent.TYPE_WARN,
            "", //$NON-NLS-1$
            this.currentCatalog, this.connectionId, this.getId(),
            -1, System.currentTimeMillis(), 0,
            Constants.MILLIS_I18N, null, this.pointOfOrigin,
View Full Code Here

      Object possibleProfilerEvent) {

    if (possibleProfilerEvent instanceof ProfilerEvent) {
      StringBuffer msgBuf = new StringBuffer();

      ProfilerEvent evt = (ProfilerEvent) possibleProfilerEvent;

      Throwable locationException = evt.getEventCreationPoint();

      if (locationException == null) {
        locationException = new Throwable();
      }

      msgBuf.append("Profiler Event: [");

      boolean appendLocationInfo = false;
     
      switch (evt.getEventType()) {
      case ProfilerEvent.TYPE_EXECUTE:
        msgBuf.append("EXECUTE");

        break;

      case ProfilerEvent.TYPE_FETCH:
        msgBuf.append("FETCH");

        break;

      case ProfilerEvent.TYPE_OBJECT_CREATION:
        msgBuf.append("CONSTRUCT");

        break;

      case ProfilerEvent.TYPE_PREPARE:
        msgBuf.append("PREPARE");

        break;

      case ProfilerEvent.TYPE_QUERY:
        msgBuf.append("QUERY");

        break;

      case ProfilerEvent.TYPE_WARN:
        msgBuf.append("WARN");
        appendLocationInfo = true;
       
        break;
       
      case ProfilerEvent.TYPE_SLOW_QUERY:
        msgBuf.append("SLOW QUERY");
        appendLocationInfo = false;
       
        break;
       
      default:
        msgBuf.append("UNKNOWN");
      }

      msgBuf.append("] ");
      msgBuf.append(findCallingClassAndMethod(locationException));
      msgBuf.append(" duration: ");
      msgBuf.append(evt.getEventDuration());
      msgBuf.append(" ");
      msgBuf.append(evt.getDurationUnits());
      msgBuf.append(", connection-id: ");
      msgBuf.append(evt.getConnectionId());
      msgBuf.append(", statement-id: ");
      msgBuf.append(evt.getStatementId());
      msgBuf.append(", resultset-id: ");
      msgBuf.append(evt.getResultSetId());

      String evtMessage = evt.getMessage();

      if (evtMessage != null) {
        msgBuf.append(", message: ");
        msgBuf.append(evtMessage);
      }
View Full Code Here

              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

            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,
                this.owner.owningStatement == null ? -1
View Full Code Here

            fieldInfo.isBinary() || fieldInfo.isBlob(),
            fieldInfo.isOpaqueBinary()),
        MysqlDefs.typeToName(fieldInfo.getMysqlType()),
        convertibleTypesBuf.toString()});
       
    this.eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN,
        "", (this.owningStatement == null) ? "N/A"
            : this.owningStatement.currentCatalog,
        this.connectionId, (this.owningStatement == null) ? (-1)
            : this.owningStatement.getId(), this.resultId, System
            .currentTimeMillis(), 0, Constants.MILLIS_I18N, null,
View Full Code Here

       
        // Report on result set closed by driver instead of application
       
        if (!calledExplicitly) {   
          this.eventSink
              .consumeEvent(new ProfilerEvent(
                  ProfilerEvent.TYPE_WARN,
                  "",
                  (this.owningStatement == null) ? "N/A"
                      : this.owningStatement.currentCatalog,
                  this.connectionId,
                  (this.owningStatement == null) ? (-1)
                      : this.owningStatement.getId(),
                  this.resultId,
                  System.currentTimeMillis(),
                  0,
                  Constants.MILLIS_I18N,
                  null,
                  this.pointOfOrigin,
                  Messages
                      .getString("ResultSet.ResultSet_implicitly_closed_by_driver"))); //$NON-NLS-1$
        }

        if (this.rowData instanceof RowDataStatic) {
         
          // Report on possibly too-large result sets
         
          if (this.rowData.size() > this.connection
              .getResultSetSizeThreshold()) {
            this.eventSink
                .consumeEvent(new ProfilerEvent(
                    ProfilerEvent.TYPE_WARN,
                    "",
                    (this.owningStatement == null) ? Messages
                        .getString("ResultSet.N/A_159")
                        : this.owningStatement.currentCatalog, //$NON-NLS-1$
                    this.connectionId,
                    (this.owningStatement == null) ? (-1)
                        : this.owningStatement.getId(),
                    this.resultId,
                    System.currentTimeMillis(),
                    0,
                    Constants.MILLIS_I18N,
                    null,
                    this.pointOfOrigin,
                    Messages
                        .getString(
                            "ResultSet.Too_Large_Result_Set",
                            new Object[] {
                                new Integer(
                                    this.rowData
                                        .size()),
                                new Integer(
                                    this.connection
                                        .getResultSetSizeThreshold()) })));
          }
         
          if (!isLast() && !isAfterLast() && (this.rowData.size() != 0)) {

            this.eventSink
                .consumeEvent(new ProfilerEvent(
                    ProfilerEvent.TYPE_WARN,
                    "",
                    (this.owningStatement == null) ? Messages
                        .getString("ResultSet.N/A_159")
                        : this.owningStatement.currentCatalog, //$NON-NLS-1$
                    this.connectionId,
                    (this.owningStatement == null) ? (-1)
                        : this.owningStatement.getId(),
                    this.resultId,
                    System.currentTimeMillis(),
                    0,
                    Constants.MILLIS_I18N,
                    null,
                    this.pointOfOrigin,
                    Messages
                        .getString(
                            "ResultSet.Possible_incomplete_traversal_of_result_set", //$NON-NLS-1$
                            new Object[] {
                                new Integer(
                                    getRow()),
                                new Integer(
                                    this.rowData
                                        .size()) })));
          }
        }

        //
        // Report on any columns that were selected but
        // not referenced
        //
       
        if (this.columnUsed.length > 0 && !this.rowData.wasEmpty()) {
          StringBuffer buf = new StringBuffer(
              Messages
                  .getString("ResultSet.The_following_columns_were_never_referenced")); //$NON-NLS-1$

          boolean issueWarn = false;

          for (int i = 0; i < this.columnUsed.length; i++) {
            if (!this.columnUsed[i]) {
              if (!issueWarn) {
                issueWarn = true;
              } else {
                buf.append(", ");
              }

              buf.append(this.fields[i].getFullName());
            }
          }

          if (issueWarn) {
            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "",
                (this.owningStatement == null) ? "N/A"
                    : this.owningStatement.currentCatalog,
                this.connectionId,
                (this.owningStatement == null) ? (-1)
View Full Code Here

            mesgBuf.append(this.originalSql);
            mesgBuf.append("\n\n with parameters bound:\n\n");
            mesgBuf.append(asSql(true));

            this.eventSink
                .consumeEvent(new ProfilerEvent(
                    ProfilerEvent.TYPE_SLOW_QUERY,
                    "", this.currentCatalog, this.connection.getId(), //$NON-NLS-1$
                    getId(), 0, System.currentTimeMillis(),
                    elapsedTime, mysql
                        .getQueryTimingUnits(), null,
                    new Throwable(), mesgBuf.toString()));
          }

          if (gatherPerformanceMetrics) {
            this.connection.registerQueryExecutionTime(elapsedTime);
          }
        }

        this.connection.incrementNumberOfPreparedExecutes();

        if (this.profileSQL) {
          this.eventSink = ProfilerEventHandlerFactory
              .getInstance(this.connection);

          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_EXECUTE,
              "", this.currentCatalog, //$NON-NLS-1$
              this.connectionId, this.statementId, -1, System
                  .currentTimeMillis(), (int) (mysql
                  .getCurrentTimeNanosOrMillis() - begin),
              mysql.getQueryTimingUnits(), null, new Throwable(),
              truncateQueryToLog(asSql(true))));
        }
 
        com.mysql.jdbc.ResultSetInternalMethods rs = mysql.readAllResults(this,
            maxRowsToRetrieve, this.resultSetType,
            this.resultSetConcurrency, createStreamingResultSet,
            this.currentCatalog, resultPacket, true, this.fieldCount,
            metadataFromCache);
       
        if (mysql.shouldIntercept()) {
          ResultSetInternalMethods interceptedResults =
              mysql.invokeStatementInterceptorsPost(this.originalSql, this, rs, true, null);
   
            if (interceptedResults != null) {
              rs = interceptedResults;
            }
        }
       
        if (this.profileSQL) {
          long fetchEndTime = mysql.getCurrentTimeNanosOrMillis();

          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_FETCH,
              "", this.currentCatalog, this.connection.getId(), //$NON-NLS-1$
              getId(), 0 /* FIXME rs.resultId */, System.currentTimeMillis(),
              (fetchEndTime - queryEndTime), mysql
                  .getQueryTimingUnits(), null,
View Full Code Here

        }

        this.connection.incrementNumberOfPrepares();

        if (this.profileSQL) {
          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_PREPARE,
              "", this.currentCatalog, //$NON-NLS-1$
              this.connectionId, this.statementId, -1,
              System.currentTimeMillis(),
              mysql.getCurrentTimeNanosOrMillis() - begin,
View Full Code Here

TOP

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

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.