Java Code Examples for com.mysql.cj.log.Log

The following examples show how to use com.mysql.cj.log.Log. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lams   Source File: XAsyncSocketConnection.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void connect(String hostName, int portNumber, PropertySet propSet, ExceptionInterceptor excInterceptor, Log log, int loginTimeout) {
    this.port = portNumber;
    this.host = hostName;
    this.propertySet = propSet;
    this.socketFactory = new AsyncSocketFactory(); // TODO reuse PNAME_socketFactory

    try {
        this.channel = this.socketFactory.connect(hostName, portNumber, propSet.exposeAsProperties(), loginTimeout);

    } catch (CJCommunicationsException e) {
        throw e;
    } catch (IOException | RuntimeException ex) {
        throw new CJCommunicationsException(ex);
    }
}
 
Example 2
public QueryInterceptor init(MysqlConnection connection, Properties props, Log log) {
    this.conn = (JdbcConnection) connection;

    String autoCommitSwapThresholdAsString = props.getProperty(PropertyDefinitions.PNAME_loadBalanceAutoCommitStatementThreshold, "0");
    try {
        this.matchingAfterStatementThreshold = Integer.parseInt(autoCommitSwapThresholdAsString);
    } catch (NumberFormatException nfe) {
        // nothing here, being handled in LoadBalancedConnectionProxy.
    }
    String autoCommitSwapRegex = props.getProperty(PropertyDefinitions.PNAME_loadBalanceAutoCommitStatementRegex, "");
    if (!"".equals(autoCommitSwapRegex)) {
        this.matchingAfterStatementRegex = autoCommitSwapRegex;
    }
    return this;

}
 
Example 3
Source Project: lams   Source File: CoreSession.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CoreSession(HostInfo hostInfo, PropertySet propSet) {
    this.connectionCreationTimeMillis = System.currentTimeMillis();
    this.hostInfo = hostInfo;
    this.propertySet = propSet;

    this.gatherPerfMetrics = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_gatherPerfMetrics);
    this.characterEncoding = getPropertySet().getModifiableProperty(PropertyDefinitions.PNAME_characterEncoding);
    this.useOldUTF8Behavior = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_useOldUTF8Behavior);
    this.disconnectOnExpiredPasswords = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_disconnectOnExpiredPasswords);
    this.cacheServerConfiguration = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_cacheServerConfiguration);
    this.autoReconnect = getPropertySet().<Boolean> getModifiableProperty(PropertyDefinitions.PNAME_autoReconnect);
    this.autoReconnectForPools = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_autoReconnectForPools);
    this.maintainTimeStats = getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_maintainTimeStats);

    this.log = LogFactory.getLogger(getPropertySet().getStringReadableProperty(PropertyDefinitions.PNAME_logger).getStringValue(),
            Log.LOGGER_INSTANCE_NAME);
    if (getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_profileSQL).getValue()
            || getPropertySet().getBooleanReadableProperty(PropertyDefinitions.PNAME_useUsageAdvisor).getValue()) {
        ProfilerEventHandlerFactory.getInstance(this);
    }
}
 
Example 4
@Override
public QueryInterceptor init(MysqlConnection connection, Properties props, Log log) {
    this.conn = (JdbcConnection) connection;

    String autoCommitSwapThresholdAsString = props.getProperty(PropertyKey.loadBalanceAutoCommitStatementThreshold.getKeyName(), "0");
    try {
        this.matchingAfterStatementThreshold = Integer.parseInt(autoCommitSwapThresholdAsString);
    } catch (NumberFormatException nfe) {
        // nothing here, being handled in LoadBalancedConnectionProxy.
    }
    String autoCommitSwapRegex = props.getProperty(PropertyKey.loadBalanceAutoCommitStatementRegex.getKeyName(), "");
    if (!"".equals(autoCommitSwapRegex)) {
        this.matchingAfterStatementRegex = autoCommitSwapRegex;
    }
    return this;

}
 
Example 5
@Override
public QueryInterceptor init(MysqlConnection conn, Properties props, Log log) {
    String regexFromUser = props.getProperty(PNAME_resultSetScannerRegex);

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ResultSetScannerInterceptor.0"));
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ResultSetScannerInterceptor.1"), t);
    }
    return this;

}
 
Example 6
@Override
public void connect(String hostName, int portNumber, PropertySet propSet, ExceptionInterceptor excInterceptor, Log log, int loginTimeout) {
    this.port = portNumber;
    this.host = hostName;
    this.propertySet = propSet;
    this.socketFactory = new AsyncSocketFactory(); // TODO reuse PNAME_socketFactory

    try {
        this.channel = this.socketFactory.connect(hostName, portNumber, propSet, loginTimeout);

    } catch (CJCommunicationsException e) {
        throw e;
    } catch (IOException | RuntimeException ex) {
        throw new CJCommunicationsException(ex);
    }
}
 
Example 7
Source Project: FoxTelem   Source File: CoreSession.java    License: GNU General Public License v3.0 6 votes vote down vote up
public CoreSession(HostInfo hostInfo, PropertySet propSet) {
    this.connectionCreationTimeMillis = System.currentTimeMillis();
    this.hostInfo = hostInfo;
    this.propertySet = propSet;

    this.gatherPerfMetrics = getPropertySet().getBooleanProperty(PropertyKey.gatherPerfMetrics);
    this.characterEncoding = getPropertySet().getStringProperty(PropertyKey.characterEncoding);
    this.disconnectOnExpiredPasswords = getPropertySet().getBooleanProperty(PropertyKey.disconnectOnExpiredPasswords);
    this.cacheServerConfiguration = getPropertySet().getBooleanProperty(PropertyKey.cacheServerConfiguration);
    this.autoReconnect = getPropertySet().getBooleanProperty(PropertyKey.autoReconnect);
    this.autoReconnectForPools = getPropertySet().getBooleanProperty(PropertyKey.autoReconnectForPools);
    this.maintainTimeStats = getPropertySet().getBooleanProperty(PropertyKey.maintainTimeStats);

    this.log = LogFactory.getLogger(getPropertySet().getStringProperty(PropertyKey.logger).getStringValue(), Log.LOGGER_INSTANCE_NAME);
    if (getPropertySet().getBooleanProperty(PropertyKey.profileSQL).getValue()
            || getPropertySet().getBooleanProperty(PropertyKey.useUsageAdvisor).getValue()) {
        ProfilerEventHandlerFactory.getInstance(this);
    }
}
 
Example 8
public ExceptionInterceptor init(Properties properties, Log log) {
    if (this.interceptors != null) {
        Iterator<ExceptionInterceptor> iter = this.interceptors.iterator();

        while (iter.hasNext()) {
            iter.next().init(properties, log);
        }
    }
    return this;
}
 
Example 9
public QueryInterceptor init(MysqlConnection conn, Properties props, Log log) {
    String regexFromUser = props.getProperty(PropertyDefinitions.PNAME_resultSetScannerRegex);

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ResultSetScannerInterceptor.0"));
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ResultSetScannerInterceptor.1"), t);
    }
    return this;

}
 
Example 10
public ExceptionInterceptor init(Properties properties, Log log) {
    if (this.interceptors != null) {
        Iterator<ExceptionInterceptor> iter = this.interceptors.iterator();

        while (iter.hasNext()) {
            iter.next().init(properties, log);
        }
    }
    return this;
}
 
Example 11
Source Project: brave   Source File: TracingExceptionInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
@Override public ExceptionInterceptor init(Properties properties, Log log) {
  String queryInterceptors = properties.getProperty("queryInterceptors");
  if (queryInterceptors == null ||
    !queryInterceptors.contains(TracingQueryInterceptor.class.getName())) {
    throw new IllegalStateException(
      "TracingQueryInterceptor must be enabled to use TracingExceptionInterceptor.");
  }
  return new TracingExceptionInterceptor();
}
 
Example 12
Source Project: brave   Source File: TracingQueryInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public QueryInterceptor init(MysqlConnection mysqlConnection, Properties properties,
  Log log) {
  String exceptionInterceptors = properties.getProperty("exceptionInterceptors");
  TracingQueryInterceptor interceptor = new TracingQueryInterceptor();
  interceptor.connection = mysqlConnection;
  interceptor.interceptingExceptions = exceptionInterceptors != null &&
    exceptionInterceptors.contains(TracingExceptionInterceptor.class.getName());
  if (!interceptor.interceptingExceptions) {
    log.logWarn("TracingExceptionInterceptor not enabled. It is highly recommended to "
      + "enable it for error logging to Zipkin.");
  }
  return interceptor;
}
 
Example 13
Source Project: lams   Source File: ReadAheadInputStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ReadAheadInputStream(InputStream toBuffer, boolean debug, Log logTo) {
    this(toBuffer, DEFAULT_BUFFER_SIZE, debug, logTo);
}
 
Example 14
Source Project: lams   Source File: ReadAheadInputStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ReadAheadInputStream(InputStream toBuffer, int bufferSize, boolean debug, Log logTo) {
    this.underlyingStream = toBuffer;
    this.buf = new byte[bufferSize];
    this.doDebug = debug;
    this.log = logTo;
}
 
Example 15
public NativeAuthenticationProvider(Log log) {
    this.log = log;
}
 
Example 16
Source Project: lams   Source File: TracingPacketReader.java    License: GNU General Public License v2.0 4 votes vote down vote up
public TracingPacketReader(MessageReader<NativePacketHeader, NativePacketPayload> packetReader, Log log) {
    this.packetReader = packetReader;
    this.log = log;
}
 
Example 17
Source Project: lams   Source File: NativeProtocol.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static NativeProtocol getInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log,
        TransactionEventHandler transactionManager) {
    NativeProtocol protocol = new NativeProtocol(log);
    protocol.init(session, socketConnection, propertySet, transactionManager);
    return protocol;
}
 
Example 18
Source Project: lams   Source File: NativeProtocol.java    License: GNU General Public License v2.0 4 votes vote down vote up
public NativeProtocol(Log logger) {
    this.log = logger;
    this.metricsHolder = new BaseMetricsHolder();
}
 
Example 19
Source Project: lams   Source File: TracingPacketSender.java    License: GNU General Public License v2.0 4 votes vote down vote up
public TracingPacketSender(MessageSender<NativePacketPayload> packetSender, Log log, String host, long serverThreadId) {
    this.packetSender = packetSender;
    this.host = host;
    this.serverThreadId = serverThreadId;
    this.log = log;
}
 
Example 20
Source Project: lams   Source File: NoSubInterceptorWrapper.java    License: GNU General Public License v2.0 4 votes vote down vote up
public QueryInterceptor init(MysqlConnection conn, Properties props, Log log) {
    this.underlyingInterceptor.init(conn, props, log);
    return this;
}
 
Example 21
public ExceptionInterceptorChain(String interceptorClasses, Properties props, Log log) {
    this.interceptors = Util.<ExceptionInterceptor> loadClasses(interceptorClasses, "Connection.BadExceptionInterceptor", this).stream()
            .map(o -> o.init(props, log)).collect(Collectors.toList());
}
 
Example 22
@Override
public QueryInterceptor init(MysqlConnection conn, Properties props, Log log) {
    this.connection = (JdbcConnection) conn;
    return this;
}
 
Example 23
public QueryInterceptor init(MysqlConnection conn, Properties props, Log l) {
    this.connection = (JdbcConnection) conn;
    this.log = l;
    return this;
}
 
Example 24
@Override
public QueryInterceptor init(MysqlConnection conn, Properties props, Log log) {
    this.connection = (JdbcConnection) conn;
    return this;
}
 
Example 25
@Override
public QueryInterceptor init(MysqlConnection conn, Properties props, Log l) {
    this.connection = (JdbcConnection) conn;
    this.log = l;
    return this;
}
 
Example 26
Source Project: FoxTelem   Source File: TracingPacketReader.java    License: GNU General Public License v3.0 4 votes vote down vote up
public TracingPacketReader(MessageReader<NativePacketHeader, NativePacketPayload> packetReader, Log log) {
    this.packetReader = packetReader;
    this.log = log;
}
 
Example 27
Source Project: FoxTelem   Source File: NativeProtocol.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static NativeProtocol getInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log,
        TransactionEventHandler transactionManager) {
    NativeProtocol protocol = new NativeProtocol(log);
    protocol.init(session, socketConnection, propertySet, transactionManager);
    return protocol;
}
 
Example 28
Source Project: FoxTelem   Source File: NativeProtocol.java    License: GNU General Public License v3.0 4 votes vote down vote up
public NativeProtocol(Log logger) {
    this.log = logger;
    this.metricsHolder = new BaseMetricsHolder();
}
 
Example 29
Source Project: FoxTelem   Source File: TracingPacketSender.java    License: GNU General Public License v3.0 4 votes vote down vote up
public TracingPacketSender(MessageSender<NativePacketPayload> packetSender, Log log, String host, long serverThreadId) {
    this.packetSender = packetSender;
    this.host = host;
    this.serverThreadId = serverThreadId;
    this.log = log;
}
 
Example 30
public ExceptionInterceptorChain(String interceptorClasses, Properties props, Log log) {
    this.interceptors = Util.<ExceptionInterceptor> loadClasses(interceptorClasses, "Connection.BadExceptionInterceptor", this).stream()
            .map(o -> o.init(props, log)).collect(Collectors.toList());
}