introduced NativeBytesI to allow us to checks if the buffer has been closed, if the buffer is accessed after it is closed an exception is thrown, This class should be used to investigate JVM crashes, it should not be used in production code ( as its slow )

This commit is contained in:
Rob Austin
2015-02-01 22:19:41 +00:00
parent 938b9dca7b
commit bec5b2a3c5
3 changed files with 27 additions and 25 deletions
@@ -30,7 +30,7 @@ import net.openhft.lang.Maths;
import net.openhft.lang.collection.ATSDirectBitSet;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.MultiStoreBytes;
import net.openhft.lang.io.NativeBytes;
import net.openhft.lang.io.NativeBytesI;
import net.openhft.lang.threadlocal.ThreadLocalCopies;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -126,7 +126,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
@Override
VanillaChronicleMap<K, KI, MKI, V, VI, MVI>.Segment createSegment(
NativeBytes segmentHeader, NativeBytes bytes, int index) {
NativeBytesI segmentHeader, NativeBytesI bytes, int index) {
return new Segment(segmentHeader, bytes, index);
}
@@ -678,7 +678,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
class Segment extends VanillaChronicleMap<K, KI, MKI, V, VI, MVI>.Segment {
Segment(NativeBytes segmentHeader, NativeBytes bytes, int index) {
Segment(NativeBytesI segmentHeader, NativeBytesI bytes, int index) {
super(segmentHeader, bytes, index);
}
@@ -993,7 +993,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
* @param identifier the unique identifier relating to this map
* @return true if the entry should not be processed
*/
private boolean shouldIgnore(@NotNull final NativeBytes entry, final long timestamp,
private boolean shouldIgnore(@NotNull final NativeBytesI entry, final long timestamp,
final byte identifier) {
final long lastModifiedTimeStamp = entry.readLong();
@@ -1262,7 +1262,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
hashLookup().forEach(new MultiMap.EntryConsumer() {
@Override
public void accept(long hash, long pos) {
final NativeBytes entry = reuse(tmpBytes, offsetFromPos(pos));
final NativeBytesI entry = reuse(tmpBytes, offsetFromPos(pos));
long keySize = keySizeMarshaller.readSize(entry);
entry.skip(keySize);
@@ -1335,7 +1335,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
Segment segment = (Segment) seg;
final long offset = segment.offsetFromPos(pos);
final NativeBytes entry = segment.reuse(this.entry, offset);
final NativeBytesI entry = segment.reuse(this.entry, offset);
final long keySize = keySizeMarshaller.readSize(entry);
long keyPosition = entry.position();
@@ -1490,7 +1490,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
entryCallback.onBeforeEntry();
final long segmentPos = position & posMask;
final NativeBytes entry =
final NativeBytesI entry =
segment.reuse(tmpBytes, segment.offsetFromPos(segmentPos));
// if the entry should be ignored, we'll move the next entry