/** {@inheritDoc} */ @Override public void setBufferSize(long bufferSize) throws IOException { synchronized (mInternalLock) { Preconditions.checkState(mState == State.OPEN, "Cannot set buffer size of BufferedWriter instance %s in state %s.", this, mState); Preconditions.checkArgument(bufferSize > 0, "Buffer size cannot be negative, got %s.", bufferSize); mMaxWriteBufferSize = bufferSize; if (mCurrentWriteBufferSize > mMaxWriteBufferSize) { flush(); } SchemaPlatformBridge.get().setWriteBufferSize(mHTable, bufferSize); } }
/** * Add a Delete to the buffer and update the current buffer size. * * @param d A delete to add to the buffer. * @throws IOException in case of an error on flush. */ private void updateBuffer(Delete d) throws IOException { synchronized (mInternalLock) { mDeleteBuffer.add(d); long heapSize = mDeleteSize; heapSize += ClassSize.align(ClassSize.ARRAY + d.getRow().length); mCurrentWriteBufferSize += heapSize; if (mCurrentWriteBufferSize > mMaxWriteBufferSize) { flush(); } } }
/** {@inheritDoc} */ @Override public void close() throws IOException { synchronized (mInternalLock) { flush(); Preconditions.checkState(mState == State.OPEN, "Cannot close BufferedWriter instance %s in state %s.", this, mState); mState = State.CLOSED; ResourceTracker.get().unregisterResource(this); mLayoutConsumerRegistration.close(); mHTable.close(); mTable.release(); } } }
LOG.info("Flushing buffer from HBaseFijiBufferedWriter for table: {} in preparation for" + " layout update.", mTable.getURI()); flush();