Package com.mysql.jdbc.profiler

Examples of com.mysql.jdbc.profiler.ProfilerEvent


    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.connection.getId(), this
                .getId(), -1, System.currentTimeMillis(), 0,
            null, this.pointOfOrigin, message));
      }
View Full Code Here


   
      if (this.useUsageAdvisor) {
        if (this.numberOfExecutions <= 1) {
          String message = Messages.getString("PreparedStatement.43"); //$NON-NLS-1$
 
          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_WARN, "", this.currentCatalog, //$NON-NLS-1$
              this.connectionId, this.getId(), -1, System
                  .currentTimeMillis(), 0, Constants.MILLIS_I18N,
                  null,
              this.pointOfOrigin, message));
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[] {
                                  Integer.valueOf(
                                      this.rowData
                                          .size()),
                                  Integer.valueOf(
                                      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[] {
                                  Integer.valueOf(
                                      getRow()),
                                  Integer.valueOf(
                                      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

            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

      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

              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

        if (getUseUsageAdvisor()) {
          if (!calledExplicitly) {
            String message = "Connection implicitly closed by Driver. You should call Connection.close() from your code to free resources more efficiently and avoid resource leaks.";

            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
                this.getCatalog(), this.getId(), -1, -1, System
                    .currentTimeMillis(), 0, Constants.MILLIS_I18N,
                    null,
                this.pointOfOrigin, message));
          }

          long connectionLifeTime = System.currentTimeMillis()
              - this.connectionCreationTimeMillis;

          if (connectionLifeTime < 500) {
            String message = "Connection lifetime of < .5 seconds. You might be un-necessarily creating short-lived connections and should investigate connection pooling to be more efficient.";

            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
                this.getCatalog(), this.getId(), -1, -1, System
                    .currentTimeMillis(), 0, Constants.MILLIS_I18N,
                    null,
                this.pointOfOrigin, message));
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,
                        LogUtils.findCallingClassAndMethod(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(), mysql
                  .getCurrentTimeNanosOrMillis() - begin,
              mysql.getQueryTimingUnits(), null, LogUtils.findCallingClassAndMethod(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.