public class SingleTableStore extends Object implements TableStore
Constructor and Description |
---|
SingleTableStore(net.openhft.chronicle.wire.WireType wireType,
net.openhft.chronicle.bytes.MappedBytes mappedBytes,
StoreRecovery recovery) |
Modifier and Type | Method and Description |
---|---|
net.openhft.chronicle.core.values.LongValue |
acquireValueFor(CharSequence key)
Acquire
LongValue mapped to underlying file, providing atomic operations on the value that is shared
across threads and/or JVMs. |
net.openhft.chronicle.bytes.MappedBytes |
bytes() |
void |
close() |
<R> R |
doWithExclusiveLock(Function<TableStore,? extends R> code)
Acquires file-system level lock on the underlying file, to prevent concurrent access from multiple processes.
|
String |
dump() |
File |
file() |
boolean |
isClosed() |
long |
refCount() |
void |
release() |
void |
reserve() |
String |
toString() |
long |
tryWriteHeader(net.openhft.chronicle.wire.Wire wire,
int safeLength) |
net.openhft.chronicle.wire.WireType |
wireType() |
long |
writeHeader(net.openhft.chronicle.wire.Wire wire,
int safeLength,
long timeoutMS) |
void |
writeMarshallable(net.openhft.chronicle.wire.WireOut wire) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public SingleTableStore(@NotNull net.openhft.chronicle.wire.WireType wireType, @NotNull net.openhft.chronicle.bytes.MappedBytes mappedBytes, @NotNull StoreRecovery recovery)
wireType
- the wire type that is being usedmappedBytes
- used to mapped the data store filerecovery
- used to recover from concurrent modificationspublic boolean isClosed()
@NotNull public net.openhft.chronicle.wire.WireType wireType()
wireType
in interface CommonStore
@NotNull public File file()
file
in interface CommonStore
@NotNull public String dump()
dump
in interface CommonStore
public void reserve() throws IllegalStateException
reserve
in interface net.openhft.chronicle.core.ReferenceCounted
IllegalStateException
public void release() throws IllegalStateException
release
in interface net.openhft.chronicle.core.ReferenceCounted
IllegalStateException
public long refCount()
refCount
in interface net.openhft.chronicle.core.ReferenceCounted
public void close()
close
in interface Closeable
close
in interface AutoCloseable
@NotNull public net.openhft.chronicle.bytes.MappedBytes bytes()
bytes
in interface CommonStore
public void writeMarshallable(@NotNull net.openhft.chronicle.wire.WireOut wire)
writeMarshallable
in interface net.openhft.chronicle.wire.WriteMarshallable
public long writeHeader(@NotNull net.openhft.chronicle.wire.Wire wire, int safeLength, long timeoutMS) throws EOFException, net.openhft.chronicle.wire.UnrecoverableTimeoutException
writeHeader
in interface CommonStore
EOFException
net.openhft.chronicle.wire.UnrecoverableTimeoutException
public long tryWriteHeader(@NotNull net.openhft.chronicle.wire.Wire wire, int safeLength)
tryWriteHeader
in interface CommonStore
public net.openhft.chronicle.core.values.LongValue acquireValueFor(CharSequence key)
LongValue
mapped to underlying file, providing atomic operations on the value that is shared
across threads and/or JVMs.
Note: The implementation of this method is not required to guarantee that if the value does not exist in the file,
it will create one and only one value in the file in case of concurrent access. On the contrary, it's possible
that different threads or processes acquire LongValue
s pointing to different fields in the underlying
file. To prevent this, it is advised to use TableStore.doWithExclusiveLock(Function)
to wrap calls to this method,
which will ensure exclusive access to file while initially acquiring values.acquireValueFor
in interface TableStore
key
- the key of the valueLongValue
object pointing to particular location in mapped underlying filepublic <R> R doWithExclusiveLock(Function<TableStore,? extends R> code)
TableStore.acquireValueFor(CharSequence)
calls, to atomically acquire
multiple values.doWithExclusiveLock
in interface TableStore
R
- result typecode
- code block to execute using locked table storeCopyright © 2018. All rights reserved.