Standardize how ReferenceCounted resources are managed and traced, https://github.com/OpenHFT/Chronicle-Core/issues/121

This commit is contained in:
Peter Lawrey
2020-06-11 19:51:48 +01:00
parent 558860a051
commit 12e286f9ec
15 changed files with 79 additions and 39 deletions
@@ -524,11 +524,11 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
key.writeTo(destination, destination.writePosition());
destination.writeSkip(key.size());
boolean debugEnabled = LOG.isDebugEnabled();
boolean traceEnabled = LOG.isTraceEnabled();
String message = null;
if (debugEnabled) {
if (traceEnabled) {
if (isDeleted) {
LOG.debug("WRITING ENTRY TO DEST - into local-id={}, remove(key={})",
LOG.trace("WRITING ENTRY TO DEST - into local-id={}, remove(key={})",
identifier(), key);
} else {
message = String.format(
@@ -545,7 +545,7 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
value.writeTo(destination, destination.writePosition());
destination.writeSkip(value.size());
if (debugEnabled) {
if (traceEnabled) {
LOG.debug(message + "value=" + value + ")");
}
}
@@ -19,6 +19,7 @@ package net.openhft.chronicle.map.impl.stage.data;
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.bytes.RandomDataInput;
import net.openhft.chronicle.core.OS;
import net.openhft.chronicle.core.io.ReferenceOwner;
import org.jetbrains.annotations.Nullable;
import java.nio.BufferOverflowException;
@@ -37,6 +38,7 @@ public enum ZeroBytesStore implements BytesStore<ZeroBytesStore, Void> {
throw new UnsupportedOperationException("Cannot get the address of nothing");
}
@Override
public int peekUnsignedByte(long offset) {
return 0;
@@ -155,24 +157,34 @@ public enum ZeroBytesStore implements BytesStore<ZeroBytesStore, Void> {
return true;
}
@Override
public void reserve() throws IllegalStateException {
public void reserve(ReferenceOwner id) throws IllegalStateException {
}
@Override
public void release() throws IllegalStateException {
public boolean tryReserve(ReferenceOwner id) throws IllegalStateException {
return false;
}
@Override
public long refCount() {
public boolean reservedBy(ReferenceOwner owner) {
return true;
}
@Override
public void release(ReferenceOwner id) throws IllegalStateException {
}
@Override
public void releaseLast(ReferenceOwner id) throws IllegalStateException {
}
@Override
public int refCount() {
return 0;
}
@Override
public boolean tryReserve() {
throw new UnsupportedOperationException("todo");
}
@Override
public ZeroBytesStore writeByte(long l, byte b) {
throw new UnsupportedOperationException();