diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 563e38bc5..1dee27fc5 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -2031,10 +2031,6 @@ class VanillaChronicleMap, return ret; } - private void setBlocks(long pos, int blocks) { - freeList.set(pos, pos + blocks); - } - private void updateNextPosToSearchFrom(long allocated, int blocks) { if ((nextPosToSearchFrom = allocated + blocks) >= entriesPerSegment) nextPosToSearchFrom = 0L; @@ -2165,12 +2161,12 @@ class VanillaChronicleMap, // update segment state if (removeFromMultiMap) { hashLookup.removePrevPos(); + long entrySizeInBytes = entry.positionAddr() + valueSize - entry.startAddr(); + free(pos, inBlocks(entrySizeInBytes)); } else { hashLookup.removePosition(pos); } decrementSize(); - long entrySizeInBytes = entry.positionAddr() + valueSize - entry.startAddr(); - free(pos, inBlocks(entrySizeInBytes)); // remove callbacks if (!remote) @@ -2383,9 +2379,6 @@ class VanillaChronicleMap, // But if these blocks will be taken by that time, // this entry will need to be relocated. } - } else { - // todo investivate when we are able to avoid this assignment - setBlocks(pos, oldSizeInBlocks); } // Common code for all cases entry.position(valueSizePos); @@ -2595,11 +2588,11 @@ class VanillaChronicleMap, final long entryEndAddr = entry.positionAddr() + valueSize; if (removeFromMultiMap) { segment.hashLookup().remove(segmentHash, pos); + segment.free(pos, segment.inBlocks(entryEndAddr - entry.address())); } else { segment.hashLookup().removePosition(pos); } segment.decrementSize(); - segment.free(pos, segment.inBlocks(entryEndAddr - entry.address())); // remove callbacks onRemove(segment, pos); diff --git a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java index db18f47a4..bc538fdf5 100644 --- a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java +++ b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java @@ -1,15 +1,11 @@ package net.openhft.chronicle.map; -import junit.framework.Assert; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.lang.io.ByteBufferBytes; import net.openhft.lang.model.Byteable; import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.values.IntValue; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.*; import java.io.Closeable; import java.io.IOException; @@ -92,11 +88,8 @@ public class TcpReplicationSoakTest { // TODO test this with larger sizes. @Test(timeout = 20000) - @Ignore("Doesn't work, maps need to check equality.") public void testSoakTestWithRandomData() throws IOException, InterruptedException { - - System.out.print("SoakTesting "); for (int j = 1; j < 2 * Builder.SIZE; j++) { if (j % 100 == 0) @@ -116,7 +109,7 @@ public class TcpReplicationSoakTest { System.out.println("\nwaiting till equal"); - waitTillEqual(1000); + waitTillEqual(10000); Assert.assertEquals(map1, map2);