public boolean isActive() { synchronized (queryExecutor) { return queryExecutor.hasLock(this); } }
public boolean isActive() { synchronized(queryExecutor) { return queryExecutor.hasLock(this); } }
/** * Finishes writing to copy and unlocks connection. * * @param op the copy operation presumably currently holding lock on this connection * @return number of rows updated for server versions 8.2 or newer * @throws SQLException on failure */ public synchronized long endCopy(CopyOperationImpl op) throws SQLException { if (!hasLock(op)) { throw new PSQLException(GT.tr("Tried to end inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); } try { LOGGER.log(Level.FINEST, " FE=> CopyDone"); pgStream.sendChar('c'); // CopyDone pgStream.sendInteger4(4); pgStream.flush(); do { processCopyResults(op, true); } while (hasLock(op)); return op.getHandledRowCount(); } catch (IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when ending copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
public synchronized void flushCopy(CopyInImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); try { pgStream.flush(); processCopyResults(op, false); // collect any pending notifications without blocking } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
/** * Blocks to wait for a row of data to be received from server on an active copy operation * Connection gets unlocked by processCopyResults() at end of operation * @param op the copy operation presumably currently holding lock on this connection * @throws SQLException on any failure */ synchronized void readFromCopy(CopyOutImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to read from inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); try { processCopyResults(op, true); // expect a call to handleCopydata() to store the data } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when reading from copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
public synchronized void flushCopy(CopyOperationImpl op) throws SQLException { if (!hasLock(op)) { throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); } try { pgStream.flush(); processCopyResults(op, false); // collect any pending notifications without blocking } catch (IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
/** * Wait for a row of data to be received from server on an active copy operation * Connection gets unlocked by processCopyResults() at end of operation. * * @param op the copy operation presumably currently holding lock on this connection * @param block whether to block waiting for input * @throws SQLException on any failure */ synchronized void readFromCopy(CopyOperationImpl op, boolean block) throws SQLException { if (!hasLock(op)) { throw new PSQLException(GT.tr("Tried to read from inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); } try { processCopyResults(op, block); // expect a call to handleCopydata() to store the data } catch (IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when reading from copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
/** * Sends data during a live COPY IN operation. Only unlocks the connection if server suddenly * returns CommandComplete, which should not happen * * @param op the CopyIn operation presumably currently holding lock on this connection * @param data bytes to send * @param off index of first byte to send (usually 0) * @param siz number of bytes to send (usually data.length) * @throws SQLException on failure */ public synchronized void writeToCopy(CopyOperationImpl op, byte[] data, int off, int siz) throws SQLException { if (!hasLock(op)) { throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); } LOGGER.log(Level.FINEST, " FE=> CopyData({0})", siz); try { pgStream.sendChar('d'); pgStream.sendInteger4(siz + 4); pgStream.send(data, off, siz); processCopyResults(op, false); // collect any pending notifications without blocking } catch (IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
if (hasLock(op)) { unlock(op);
/** * Sends data during a live COPY IN operation. Only unlocks the connection if server * suddenly returns CommandComplete, which should not happen * @param op the CopyIn operation presumably currently holding lock on this connection * @param data bytes to send * @param off index of first byte to send (usually 0) * @param siz number of bytes to send (usually data.length) * @throws SQLException on failure */ public synchronized void writeToCopy(CopyInImpl op, byte[] data, int off, int siz) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); if (logger.logDebug()) logger.debug(" FE=> CopyData(" + siz + ")"); try { pgStream.SendChar('d'); pgStream.SendInteger4(siz + 4); pgStream.Send(data, off, siz); processCopyResults(op, false); // collect any pending notifications without blocking } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
/** * Finishes writing to copy and unlocks connection * @param op the copy operation presumably currently holding lock on this connection * @return number of rows updated for server versions 8.2 or newer * @throws SQLException on failure */ public synchronized long endCopy(CopyInImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to end inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); try { if (logger.logDebug()) logger.debug(" FE=> CopyDone"); pgStream.SendChar('c'); // CopyDone pgStream.SendInteger4(4); pgStream.flush(); processCopyResults(op, true); return op.getHandledRowCount(); } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when ending copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
if(hasLock(op)) unlock(op); op = null;
public boolean isActive() { synchronized(queryExecutor) { return queryExecutor.hasLock(this); } }
public boolean isActive() { synchronized(queryExecutor) { return queryExecutor.hasLock(this); } }
/** * Blocks to wait for a row of data to be received from server on an active copy operation * Connection gets unlocked by processCopyResults() at end of operation * @param op the copy operation presumably currently holding lock on this connection * @throws SQLException on any failure */ synchronized void readFromCopy(CopyOutImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to read from inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); try { processCopyResults(op, true); // expect a call to handleCopydata() to store the data } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when reading from copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
/** * Blocks to wait for a row of data to be received from server on an active copy operation * Connection gets unlocked by processCopyResults() at end of operation * @param op the copy operation presumably currently holding lock on this connection * @throws SQLException on any failure */ synchronized void readFromCopy(CopyOutImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to read from inactive copy"), PSQLState.OBJECT_NOT_IN_STATE); try { processCopyResults(op, true); // expect a call to handleCopydata() to store the data } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when reading from copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
public synchronized void flushCopy(CopyInImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); try { pgStream.flush(); processCopyResults(op, false); // collect any pending notifications without blocking } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }
public synchronized void flushCopy(CopyInImpl op) throws SQLException { if(!hasLock(op)) throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE); try { pgStream.flush(); processCopyResults(op, false); // collect any pending notifications without blocking } catch(IOException ioe) { throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe); } }