mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Full proof read and edit
This commit is contained in:
@@ -12,45 +12,44 @@ toc::[]
|
||||
|
||||
You could customize `ChronicleMap` behaviour on several levels:
|
||||
|
||||
- `ChronicleMapBuilder.entryOperations()` define the "inner" listening level, all operations with
|
||||
- `ChronicleMapBuilder.entryOperations()` define the "inner" listening level. All operations with
|
||||
entries, either during ordinary map method calls, remote calls, replication or modifications during
|
||||
iteration over the map, operate via this configured SPI.
|
||||
iteration over the map, operate using this configured SPI.
|
||||
|
||||
- `ChronicleMapBuilder.mapMethods()` is the higher-level of listening for local calls of Map
|
||||
methods. Methods in `MapMethods` interface correspond to `Map` interface methods with the same
|
||||
methods. Methods in the `MapMethods` interface correspond to `Map` interface methods with the same
|
||||
names, and define their implementations for `ChronicleMap`.
|
||||
|
||||
- `ChronicleMapBuilder.remoteOperations()` is for listening and customizing behaviour of remote
|
||||
calls, and replication events.
|
||||
|
||||
All executions around `ChronicleMap` go through the three tiers (or the two bottom):
|
||||
All executions around `ChronicleMap` go through all three tiers, or just the last two):
|
||||
|
||||
1. Query tier: `MapQueryContext` interface
|
||||
2. Entry tier: `MapEntry` and `MapAbsentEntry` interfaces
|
||||
3. Data tier: `Data` interface
|
||||
|
||||
`MapMethods` and `MapRemoteOperations` methods accept *query context*, i. e. these SPI is above
|
||||
the Query tier. `MapEntryOperations` methods accept `MapEntry` or `MapAbsentEntry`, i. e. this SPI
|
||||
is between Query and Entry tiers.
|
||||
`MapMethods` and `MapRemoteOperations` methods accept *query context*; SPI is above
|
||||
the Query tier.
|
||||
|
||||
Combined, interception SPI interfaces and `ChronicleMap.queryContext()` API are powerful enough to
|
||||
`MapEntryOperations` methods accept `MapEntry` or `MapAbsentEntry`; SPI is between Query and Entry tiers.
|
||||
|
||||
- Log all operations of some kind on `ChronicleMap` (e. g. all remove, insert or update operations)
|
||||
- Log some specific operations on `ChronicleMap` (e. g. log only acquireUsing() calls, which has
|
||||
created a new entry)
|
||||
- Forbid performing operations of some kind on the `ChronicleMap` instance
|
||||
- Backup all changes to `ChronicleMap` to some alternative storage, e. g. SQL database
|
||||
When combined, interception SPI interfaces and the `ChronicleMap.queryContext()` API are powerful enough to:
|
||||
|
||||
- Log all operations of some kind on `ChronicleMap` (for example, all remove, insert, or update operations).
|
||||
- Log some specific operations on `ChronicleMap` (for example, log only `acquireUsing()` calls, which has created a new entry).
|
||||
- Inhibit operations of some kind on the `ChronicleMap` instance.
|
||||
- Backup all changes to `ChronicleMap` to some alternative storage; for example, an SQL database.
|
||||
- Perform multi-Chronicle Map operations correctly in concurrent environment, by acquiring locks on
|
||||
all ChronicleMaps before updating them.
|
||||
- Perform multi-key operations on a single `ChronicleMap` correctly in concurrent environment, by
|
||||
acquiring locks on all keys before updating the entries
|
||||
- Define own replication/reconciliation logic for distributed Chronicle Maps
|
||||
- Dump statistics of the Chronicle Map instance -- each segment's load, size in bytes of each
|
||||
all ChronicleMaps, before updating them.
|
||||
- Perform multi-key operations on a single `ChronicleMap` correctly in a concurrent environment, by acquiring locks on all keys before updating the entries.
|
||||
- Define your own replication/reconciliation logic for distributed Chronicle Maps.
|
||||
- Dump statistics of the Chronicle Map instance; each segment's load, size in bytes of each
|
||||
entry, etc.
|
||||
|
||||
== Example - Simple logging
|
||||
|
||||
Just log all modification operations on `ChronicleMap`
|
||||
To log all modification operations on `ChronicleMap`:
|
||||
|
||||
```java
|
||||
class SimpleLoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
|
||||
@@ -101,7 +100,7 @@ ChronicleMap<IntValue, IntValue> map = ChronicleMap
|
||||
|
||||
== Example - BiMap
|
||||
|
||||
Possible bidirectional map (i. e. a map that preserves the uniqueness of its values as well
|
||||
Possible bi-directional map (that is, a map that preserves the uniqueness of its values, as well
|
||||
as that of its keys) implementation over Chronicle Maps.
|
||||
|
||||
```java
|
||||
@@ -293,6 +292,7 @@ class BiMapEntryOperations<K, V> implements MapEntryOperations<K, V, DualLockSuc
|
||||
```
|
||||
|
||||
Usage:
|
||||
|
||||
```java
|
||||
BiMapEntryOperations<Integer, CharSequence> biMapOps1 = new BiMapEntryOperations<>();
|
||||
ChronicleMap<Integer, CharSequence> map1 = ChronicleMapBuilder
|
||||
|
||||
Reference in New Issue
Block a user