|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.storage.dht.spi.util.AbstractWriteBuffer
org.eclipse.jgit.storage.dht.spi.cache.CacheBuffer
public class CacheBuffer
WriteBuffer implementation for a CacheDatabase
.
Constructor Summary | |
---|---|
CacheBuffer(WriteBuffer dbBuffer,
CacheService client,
CacheOptions options)
Initialize a new buffer. |
Method Summary | |
---|---|
void |
abort()
Abort pending writes, and wait for acknowledgment. |
void |
flush()
Flush any pending writes, and wait for them to complete. |
WriteBuffer |
getWriteBuffer()
|
void |
modify(CacheService.Change op)
Schedule any cache change. |
void |
put(CacheKey key,
byte[] value)
Schedule storing (or replacing) a key in the cache. |
void |
remove(CacheKey key)
Schedule removal of a key from the cache. |
void |
removeAfterFlush(CacheKey key)
Schedule a removal only after the underlying database flushes. |
protected void |
startQueuedOperations(int bytes)
Start all queued operations. |
Methods inherited from class org.eclipse.jgit.storage.dht.spi.util.AbstractWriteBuffer |
---|
add, queued, start, wrap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheBuffer(WriteBuffer dbBuffer, CacheService client, CacheOptions options)
dbBuffer
- the underlying database's own buffer.client
- connection to the cache service.options
- options controlling cache operations.Method Detail |
---|
public void remove(CacheKey key) throws DhtException
Unlike removeAfterFlush(CacheKey)
, these removals can be flushed
when the cache buffer is full, potentially before any corresponding
removal is written to the underlying database.
key
- key to remove.
DhtException
- a prior flush failed.public void removeAfterFlush(CacheKey key)
Unlike remove(CacheKey)
, these removals are buffered until the
application calls flush()
and aren't sent to the cache service
until after the underlying database flush() operation is completed
successfully.
key
- key to remove.public void put(CacheKey key, byte[] value) throws DhtException
key
- key to store.value
- new value to store.
DhtException
- a prior flush failed.public void modify(CacheService.Change op) throws DhtException
op
- the cache operation.
DhtException
- a prior flush failed.public WriteBuffer getWriteBuffer()
protected void startQueuedOperations(int bytes) throws DhtException
AbstractWriteBuffer
This method is invoked by AbstractWriteBuffer.queued(int)
or by AbstractWriteBuffer.flush()
when there is a non-zero number of bytes already enqueued as a result of
prior AbstractWriteBuffer.add(int)
and {#link AbstractWriteBuffer.queued(int)
calls.
Implementors should use AbstractWriteBuffer.start(Callable, int)
to begin their
mutation tasks in the background.
startQueuedOperations
in class AbstractWriteBuffer
bytes
- number of bytes that were already enqueued. This count should
be passed to AbstractWriteBuffer.start(Callable, int)
.
DhtException
- a previously started operation completed and failed.public void flush() throws DhtException
WriteBuffer
flush
in interface WriteBuffer
flush
in class AbstractWriteBuffer
DhtException
- one or more writes failed. As writes may occur in any order,
the exact state of the database is unspecified.public void abort() throws DhtException
WriteBuffer
Once a buffer has been aborted, it cannot be reused. Application code must discard the buffer instance and use a different buffer to issue subsequent operations.
If writes have not been started yet, they should be discarded and not submitted to the storage system.
If writes have already been started asynchronously in the background, this method may try to cancel them, but must wait for the operation to either complete or abort before returning. This allows callers to clean up by scanning the storage system and making corrections to clean up any partial writes.
abort
in interface WriteBuffer
abort
in class AbstractWriteBuffer
DhtException
- one or more already started writes failed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |