Search in sources :

Example 1 with ReadAheadInputStream

use of com.mysql.cj.protocol.ReadAheadInputStream in project JavaSegundasQuintas by ecteruel.

the class NativeSocketConnection method connect.

@Override
public void connect(String hostName, int portNumber, PropertySet propSet, ExceptionInterceptor excInterceptor, Log log, int loginTimeout) {
    try {
        this.port = portNumber;
        this.host = hostName;
        this.propertySet = propSet;
        this.exceptionInterceptor = excInterceptor;
        this.socketFactory = createSocketFactory(propSet.getStringProperty(PropertyKey.socketFactory).getStringValue());
        this.mysqlSocket = this.socketFactory.connect(this.host, this.port, propSet, loginTimeout);
        int socketTimeout = propSet.getIntegerProperty(PropertyKey.socketTimeout).getValue();
        if (socketTimeout != 0) {
            try {
                this.mysqlSocket.setSoTimeout(socketTimeout);
            } catch (Exception ex) {
            /* Ignore if the platform does not support it */
            }
        }
        this.socketFactory.beforeHandshake();
        InputStream rawInputStream;
        if (propSet.getBooleanProperty(PropertyKey.useReadAheadInput).getValue()) {
            rawInputStream = new ReadAheadInputStream(this.mysqlSocket.getInputStream(), 16384, propSet.getBooleanProperty(PropertyKey.traceProtocol).getValue(), log);
        } else if (propSet.getBooleanProperty(PropertyKey.useUnbufferedInput).getValue()) {
            rawInputStream = this.mysqlSocket.getInputStream();
        } else {
            rawInputStream = new BufferedInputStream(this.mysqlSocket.getInputStream(), 16384);
        }
        this.mysqlInput = new FullReadInputStream(rawInputStream);
        this.mysqlOutput = new BufferedOutputStream(this.mysqlSocket.getOutputStream(), 16384);
    } catch (IOException ioEx) {
        throw ExceptionFactory.createCommunicationsException(propSet, null, new PacketSentTimeHolder() {
        }, null, ioEx, getExceptionInterceptor());
    }
}
Also used : FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) InputStream(java.io.InputStream) PacketSentTimeHolder(com.mysql.cj.protocol.PacketSentTimeHolder) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) SSLParamsException(com.mysql.cj.exceptions.SSLParamsException) FeatureNotAvailableException(com.mysql.cj.exceptions.FeatureNotAvailableException)

Example 2 with ReadAheadInputStream

use of com.mysql.cj.protocol.ReadAheadInputStream in project aws-mysql-jdbc by awslabs.

the class NativeSocketConnection method connect.

@Override
public void connect(String hostName, int portNumber, PropertySet propSet, ExceptionInterceptor excInterceptor, Log log, int loginTimeout) {
    try {
        this.port = portNumber;
        this.host = hostName;
        this.propertySet = propSet;
        this.exceptionInterceptor = excInterceptor;
        this.socketFactory = createSocketFactory(propSet.getStringProperty(PropertyKey.socketFactory).getStringValue());
        this.mysqlSocket = this.socketFactory.connect(this.host, this.port, propSet, loginTimeout);
        int socketTimeout = propSet.getIntegerProperty(PropertyKey.socketTimeout).getValue();
        if (socketTimeout != 0) {
            try {
                this.mysqlSocket.setSoTimeout(socketTimeout);
            } catch (Exception ex) {
            /* Ignore if the platform does not support it */
            }
        }
        this.socketFactory.beforeHandshake();
        InputStream rawInputStream;
        if (propSet.getBooleanProperty(PropertyKey.useReadAheadInput).getValue()) {
            rawInputStream = new ReadAheadInputStream(this.mysqlSocket.getInputStream(), 16384, propSet.getBooleanProperty(PropertyKey.traceProtocol).getValue(), log);
        } else if (propSet.getBooleanProperty(PropertyKey.useUnbufferedInput).getValue()) {
            rawInputStream = this.mysqlSocket.getInputStream();
        } else {
            rawInputStream = new BufferedInputStream(this.mysqlSocket.getInputStream(), 16384);
        }
        this.mysqlInput = new FullReadInputStream(rawInputStream);
        this.mysqlOutput = new BufferedOutputStream(this.mysqlSocket.getOutputStream(), 16384);
    } catch (IOException ioEx) {
        throw ExceptionFactory.createCommunicationsException(propSet, null, new PacketSentTimeHolder() {
        }, null, ioEx, getExceptionInterceptor());
    }
}
Also used : FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) InputStream(java.io.InputStream) PacketSentTimeHolder(com.mysql.cj.protocol.PacketSentTimeHolder) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) SSLParamsException(com.mysql.cj.exceptions.SSLParamsException) FeatureNotAvailableException(com.mysql.cj.exceptions.FeatureNotAvailableException)

Example 3 with ReadAheadInputStream

use of com.mysql.cj.protocol.ReadAheadInputStream in project ABC by RuiPinto96274.

the class NativeSocketConnection method connect.

@Override
public void connect(String hostName, int portNumber, PropertySet propSet, ExceptionInterceptor excInterceptor, Log log, int loginTimeout) {
    try {
        this.port = portNumber;
        this.host = hostName;
        this.propertySet = propSet;
        this.exceptionInterceptor = excInterceptor;
        this.socketFactory = createSocketFactory(propSet.getStringProperty(PropertyKey.socketFactory).getStringValue());
        this.mysqlSocket = this.socketFactory.connect(this.host, this.port, propSet, loginTimeout);
        int socketTimeout = propSet.getIntegerProperty(PropertyKey.socketTimeout).getValue();
        if (socketTimeout != 0) {
            try {
                this.mysqlSocket.setSoTimeout(socketTimeout);
            } catch (Exception ex) {
            /* Ignore if the platform does not support it */
            }
        }
        this.socketFactory.beforeHandshake();
        InputStream rawInputStream;
        if (propSet.getBooleanProperty(PropertyKey.useReadAheadInput).getValue()) {
            rawInputStream = new ReadAheadInputStream(this.mysqlSocket.getInputStream(), 16384, propSet.getBooleanProperty(PropertyKey.traceProtocol).getValue(), log);
        } else if (propSet.getBooleanProperty(PropertyKey.useUnbufferedInput).getValue()) {
            rawInputStream = this.mysqlSocket.getInputStream();
        } else {
            rawInputStream = new BufferedInputStream(this.mysqlSocket.getInputStream(), 16384);
        }
        this.mysqlInput = new FullReadInputStream(rawInputStream);
        this.mysqlOutput = new BufferedOutputStream(this.mysqlSocket.getOutputStream(), 16384);
    } catch (IOException ioEx) {
        throw ExceptionFactory.createCommunicationsException(propSet, null, new PacketSentTimeHolder() {
        }, null, ioEx, getExceptionInterceptor());
    }
}
Also used : FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) FullReadInputStream(com.mysql.cj.protocol.FullReadInputStream) InputStream(java.io.InputStream) PacketSentTimeHolder(com.mysql.cj.protocol.PacketSentTimeHolder) ReadAheadInputStream(com.mysql.cj.protocol.ReadAheadInputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) SSLParamsException(com.mysql.cj.exceptions.SSLParamsException) FeatureNotAvailableException(com.mysql.cj.exceptions.FeatureNotAvailableException)

Aggregations

FeatureNotAvailableException (com.mysql.cj.exceptions.FeatureNotAvailableException)3 SSLParamsException (com.mysql.cj.exceptions.SSLParamsException)3 FullReadInputStream (com.mysql.cj.protocol.FullReadInputStream)3 PacketSentTimeHolder (com.mysql.cj.protocol.PacketSentTimeHolder)3 ReadAheadInputStream (com.mysql.cj.protocol.ReadAheadInputStream)3 BufferedInputStream (java.io.BufferedInputStream)3 BufferedOutputStream (java.io.BufferedOutputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3