| | |
| | | } |
| | | |
| | | /** Decorates an {@link ReadableTransaction} with additional trace logging. */ |
| | | private final class TracedReadableStorage implements ReadableTransaction |
| | | private final class TracedReadableTransaction implements ReadableTransaction |
| | | { |
| | | private final ReadableTransaction txn; |
| | | |
| | | private TracedReadableStorage(final ReadableTransaction txn) |
| | | private TracedReadableTransaction(final ReadableTransaction txn) |
| | | { |
| | | this.txn = txn; |
| | | } |
| | |
| | | public long getRecordCount(TreeName name) |
| | | { |
| | | final long count = txn.getRecordCount(name); |
| | | logger.trace("Storage@%s.ReadableStorage@%s.getRecordCount(%s, %s) = %d", |
| | | logger.trace("Storage@%s.ReadableTransaction@%s.getRecordCount(%s, %s) = %d", |
| | | storageId(), id(), backendId, name, count); |
| | | return count; |
| | | } |
| | |
| | | public Cursor<ByteString, ByteString> openCursor(final TreeName name) |
| | | { |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(name); |
| | | logger.trace("Storage@%s.ReadableStorage@%s.openCursor(%s, %s)", |
| | | logger.trace("Storage@%s.ReadableTransaction@%s.openCursor(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | return cursor; |
| | | } |
| | |
| | | public ByteString read(final TreeName name, final ByteSequence key) |
| | | { |
| | | final ByteString value = txn.read(name, key); |
| | | logger.trace("Storage@%s.ReadableStorage@%s.read(%s, %s, %s) = %s", |
| | | logger.trace("Storage@%s.ReadableTransaction@%s.read(%s, %s, %s) = %s", |
| | | storageId(), id(), backendId, name, hex(key), hex(value)); |
| | | return value; |
| | | } |
| | |
| | | } |
| | | |
| | | /** Decorates an {@link WriteableTransaction} with additional trace logging. */ |
| | | private final class TracedWriteableStorage implements WriteableTransaction |
| | | private final class TracedWriteableTransaction implements WriteableTransaction |
| | | { |
| | | private final WriteableTransaction txn; |
| | | |
| | | private TracedWriteableStorage(final WriteableTransaction txn) |
| | | private TracedWriteableTransaction(final WriteableTransaction txn) |
| | | { |
| | | this.txn = txn; |
| | | } |
| | |
| | | public void put(final TreeName name, final ByteSequence key, final ByteSequence value) |
| | | { |
| | | txn.put(name, key, value); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.create(%s, %s, %s, %s)", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.create(%s, %s, %s, %s)", |
| | | storageId(), id(), backendId, name, hex(key), hex(value)); |
| | | } |
| | | |
| | |
| | | public boolean delete(final TreeName name, final ByteSequence key) |
| | | { |
| | | final boolean isDeleted = txn.delete(name, key); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.delete(%s, %s, %s) = %s", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.delete(%s, %s, %s) = %s", |
| | | storageId(), id(), backendId, name, hex(key), isDeleted); |
| | | return isDeleted; |
| | | } |
| | |
| | | public void deleteTree(final TreeName name) |
| | | { |
| | | txn.deleteTree(name); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.deleteTree(%s, %s)", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.deleteTree(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | } |
| | | |
| | |
| | | public long getRecordCount(TreeName name) |
| | | { |
| | | final long count = txn.getRecordCount(name); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.getRecordCount(%s, %s) = %d", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.getRecordCount(%s, %s) = %d", |
| | | storageId(), id(), backendId, name, count); |
| | | return count; |
| | | } |
| | |
| | | public Cursor<ByteString, ByteString> openCursor(final TreeName name) |
| | | { |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(name); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.openCursor(%s, %s)", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.openCursor(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | return cursor; |
| | | } |
| | |
| | | public void openTree(final TreeName name) |
| | | { |
| | | txn.openTree(name); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.openTree(%s, %s)", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.openTree(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | } |
| | | |
| | |
| | | public ByteString read(final TreeName name, final ByteSequence key) |
| | | { |
| | | final ByteString value = txn.read(name, key); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.read(%s, %s, %s) = %s", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.read(%s, %s, %s) = %s", |
| | | storageId(), id(), backendId, name, hex(key), hex(value)); |
| | | return value; |
| | | } |
| | |
| | | public void renameTree(final TreeName oldName, final TreeName newName) |
| | | { |
| | | txn.renameTree(oldName, newName); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.renameTree(%s, %s, %s)", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.renameTree(%s, %s, %s)", |
| | | storageId(), id(), backendId, oldName, newName); |
| | | } |
| | | |
| | |
| | | public boolean update(final TreeName name, final ByteSequence key, final UpdateFunction f) |
| | | { |
| | | final boolean isUpdated = txn.update(name, key, f); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.update(%s, %s, %s, %s) = %s", |
| | | logger.trace("Storage@%s.WriteableTransaction@%s.update(%s, %s, %s, %s) = %s", |
| | | storageId(), id(), backendId, name, hex(key), f, isUpdated); |
| | | return isUpdated; |
| | | } |
| | |
| | | @Override |
| | | public T run(final ReadableTransaction txn) throws Exception |
| | | { |
| | | return readOperation.run(new TracedReadableStorage(txn)); |
| | | return readOperation.run(new TracedReadableTransaction(txn)); |
| | | } |
| | | }; |
| | | } |
| | |
| | | @Override |
| | | public void run(final WriteableTransaction txn) throws Exception |
| | | { |
| | | writeOperation.run(new TracedWriteableStorage(txn)); |
| | | writeOperation.run(new TracedWriteableTransaction(txn)); |
| | | } |
| | | }; |
| | | } |