private PGReplicationStream initializeReplication(String query, CommonOptions options, ReplicationType replicationType) throws SQLException { LOGGER.log(Level.FINEST, " FE=> StartReplication(query: {0})", query); configureSocketTimeout(options); CopyDual copyDual = (CopyDual) queryExecutor.startCopy(query, true); return new V3PGReplicationStream( copyDual, options.getStartLSNPosition(), options.getStatusInterval(), replicationType ); }
private void configureSocketTimeout(CommonOptions options) throws PSQLException { if (options.getStatusInterval() == 0) { return; } try { int previousTimeOut = pgStream.getSocket().getSoTimeout(); int minimalTimeOut; if (previousTimeOut > 0) { minimalTimeOut = Math.min(previousTimeOut, options.getStatusInterval()); } else { minimalTimeOut = options.getStatusInterval(); } pgStream.getSocket().setSoTimeout(minimalTimeOut); } catch (IOException ioe) { throw new PSQLException(GT.tr("The connection attempt failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT, ioe); } }