H
- the container type, created by this builder, ChronicleMap
or
ChronicleSet
public interface ChronicleHashInstanceBuilder<H extends ChronicleHash>
ChronicleHash
instances, allowing to set unique configurations
using "chaining" pattern.
Usage example:
ChronicleMap<LongValue, Order> = ChronicleMap
.of(LongValue.class, Order.class)
.entries(10_000_000)
.instance() // a ChronicleHashInstanceBuilder is returned from this method
// continue "chaining"
.replicated(...)
.name(...)
.persistedTo(...)
.create();
ChronicleHashBuilder.instance()
Modifier and Type | Method and Description |
---|---|
H |
create()
Creates (or opens existing, if
persistedTo(File) is configured with the existing
file) and returns a Chronicle Hash from this builder. |
ChronicleHashInstanceBuilder<H> |
name(String name)
Configures the name for the Chronicle Hash, which is going to be created by this builder.
|
ChronicleHashInstanceBuilder<H> |
persistedTo(File file)
Configures the file, the Chronicle Hash, which is going to be created by this builder, should
be persisted to.
|
H |
recover(boolean sameBuilderConfig)
Recovers and returns a Chronicle Hash instance, persisted to the file, configured via
persistedTo(File) method. |
ChronicleHashInstanceBuilder<H> |
replicated(byte identifier,
TcpTransportAndNetworkConfig tcpTransportAndNetwork) |
ChronicleHashInstanceBuilder<H> |
replicated(SingleChronicleHashReplication replication) |
ChronicleHashInstanceBuilder<H> |
replicatedViaChannel(ReplicationChannel channel)
Configures replication of the hash container, which is going to be created by this builder,
via so called "channels".
|
ChronicleHashInstanceBuilder<H> replicated(byte identifier, TcpTransportAndNetworkConfig tcpTransportAndNetwork)
ChronicleHashInstanceBuilder<H> replicated(SingleChronicleHashReplication replication)
ChronicleHashInstanceBuilder<H> replicatedViaChannel(ReplicationChannel channel)
Another way to establish replication is replicated(SingleChronicleHashReplication)
method or it's shortcut: replicated(byte, TcpTransportAndNetworkConfig)
.
By default, hash containers, created by this builder doesn't replicate their data.
This method call overrides all previous replication configurations of this builder, made
either by means of this method, replicated(SingleChronicleHashReplication)
or replicated(byte, TcpTransportAndNetworkConfig)
method calls.
channel
- the channel responsible for gathering updates of hash containers,
created by this builder, and replicating them over networkreplicated(SingleChronicleHashReplication)
ChronicleHashInstanceBuilder<H> name(String name)
name
- the name for the Chronicle Hash is going to be created by this builderChronicleHashInstanceBuilder<H> persistedTo(File file)
ChronicleHashBuilder.createPersistedTo(File)
for more
information on Chronicle Hash persistence. If the given file is null
, in-memory
Chronicle Hash is created, like by ChronicleHashBuilder.create()
.
By default, persistence file is configured to null
, i. e. the in-memory Chronicle
Hash instance is created.
file
- the file the Chronicle Hash, which is going to be created by this builder, should
be persisted to, to null
, if the Chronicle Hash should be purely
in-memoryH create() throws IOException
persistedTo(File)
is configured with the existing
file) and returns a Chronicle Hash from this builder. After this method is called once the
builder couldn't be used to create new Chronicle Hash instances, a new ChronicleHashInstanceBuilder
should be created via ChronicleHashBuilder.instance()
.IOException
- if any IO error, related to off-heap memory allocation or file mapping,
or establishing replication connections, occursIllegalStateException
- if create()
or recover(boolean)
method has
already been called on this
ChronicleHashInstanceBuilder
ChronicleHashBuilder.create()
,
ChronicleHashBuilder.createPersistedTo(File)
H recover(boolean sameBuilderConfig) throws IOException
persistedTo(File)
method. See documentation to ChronicleHashBuilder.recoverPersistedTo(File, boolean)
for more information of Chronicle
Hash instance recovery.sameBuilderConfig
- if the ChronicleHashBuilder
, from which this ChronicleHashInstanceBuilder
inherits (i. e. this ChronicleHashInstanceBuilder
is
created via calling ChronicleHashBuilder.instance()
on that ChronicleHashBuilder
) is configured with the same configurations, as the builder, which
created the persistence file (the persisted Chronicle Hash instance) for the first time, and
with the same version of the Chronicle Map library. In this case, the header of the file is
overridden (with presumably the same configurations), protecting from ChronicleHashRecoveryFailedException
, if the header is corrupted.IllegalStateException
- if persistence file is not configured (or explicitly configured
to null
) for this ChronicleHashInstanceBuilder
, using persistedTo(File)
method, or if create()
or recover()
method has already
been called on this builderFileNotFoundException
- if the specified persistence file doesn't existIOException
- if any IO error occurs on reading data from the file, or related to
off-heap memory allocation or file mapping, or establishing replication connections. Probably
the file is corrupted on OS level, and should be recovered on that level first, before
calling this procedure.ChronicleHashRecoveryFailedException
- if recovery is impossibleChronicleHashBuilder.recoverPersistedTo(File, boolean)
Copyright © 2016. All rights reserved.