diff --git a/pom.xml b/pom.xml
index 781999196..5bb26408b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
4.0.0
chronicle-map
- 2.0.22rc3-SNAPSHOT
+ 2.0.22rc6-SNAPSHOT
OpenHFT/Chronicle-Map
Chronicle-Map
@@ -47,7 +47,7 @@
net.openhft
lang
- 6.4.22-SNAPSHOT
+ 6.4.22
@@ -142,6 +142,24 @@
+
+
+
+ src/main/resources
+ true
+
+ **/map.version
+
+
+
+ src/main/resources
+ false
+
+ **/map.version
+
+
+
+
diff --git a/src/main/java/net/openhft/chronicle/map/BuildVersion.java b/src/main/java/net/openhft/chronicle/map/BuildVersion.java
index f1539d072..1912296a7 100644
--- a/src/main/java/net/openhft/chronicle/map/BuildVersion.java
+++ b/src/main/java/net/openhft/chronicle/map/BuildVersion.java
@@ -21,16 +21,14 @@ package net.openhft.chronicle.map;
import shaded.org.apache.maven.model.Model;
import shaded.org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
+import java.io.*;
/**
* gets the version of the current build
*/
class BuildVersion {
- private static String version = null;
+ private static String version = null;
/**
* @return version of ChronicleMap being used, or NULL if its not known
@@ -41,7 +39,23 @@ class BuildVersion {
return version;
}
- // the best way to get the version is to read it from the manifest
+ try {
+ // the best way to get the version is to read the map.version file
+ InputStream resource = BuildVersion.class.getClassLoader().getResourceAsStream("map" +
+ ".version");
+ BufferedReader in = new BufferedReader(new InputStreamReader(resource));
+
+ version = in.readLine().trim();
+ if (!"${project.version}".equals(version()))
+ return version;
+
+ return version;
+ } catch (Exception e) {
+ // do nothing
+ }
+
+
+ // another way to get the version is to read it from the manifest
final String versionFromManifest = getVersionFromManifest();
if (versionFromManifest != null) {
diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java
index 9a3eebdfe..bc3d29419 100644
--- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java
+++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java
@@ -39,6 +39,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.*;
import java.util.*;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.nio.channels.SelectionKey.*;
@@ -70,7 +71,8 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo
private static final byte NOT_SET = (byte) HEARTBEAT.ordinal();
private static final Logger LOG = LoggerFactory.getLogger(TcpReplicator.class.getName());
private static final int BUFFER_SIZE = 0x100000; // 1MB
- private static final int SPIN_LOOP_COUNT = 100000;
+
+ public static final long SPIN_LOOP_TIME_IN_NONOSECONDS = TimeUnit.MICROSECONDS.toNanos(500);
private final SelectionKey[] selectionKeysStore = new SelectionKey[Byte.MAX_VALUE + 1];
// used to instruct the selector thread to set OP_WRITE on a key correlated by the bit index
// in the bitset
@@ -269,13 +271,14 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo
/**
* spin loops 100000 times first before calling the selector with timeout
*
- * @return
+ * @return The number of keys, possibly zero, whose ready-operation sets were updated
* @throws IOException
*/
private int select() throws IOException {
- // spin loop 100000 times
- for (int i = 0; i < SPIN_LOOP_COUNT; i++) {
+ long start = System.nanoTime();
+
+ while (System.nanoTime() < start + SPIN_LOOP_TIME_IN_NONOSECONDS) {
final int keys = selector.selectNow();
if (keys != 0)
return keys;
@@ -1632,7 +1635,7 @@ class StatelessServerConnector {
final Function function = (Function) reader.readObject();
try {
Object result = map.getMapped(key, function);
- writeObject(writer,result);
+ writeObject(writer, result);
} catch (Throwable e) {
LOG.info("", e);
return sendException(writer, sizeLocation, e);
@@ -1649,7 +1652,7 @@ class StatelessServerConnector {
final UnaryOperator unaryOperator = (UnaryOperator) reader.readObject();
try {
Object result = map.putMapped(key, unaryOperator);
- writeObject(writer,result);
+ writeObject(writer, result);
} catch (Throwable e) {
LOG.info("", e);
return sendException(writer, sizeLocation, e);
@@ -1756,7 +1759,7 @@ class StatelessServerConnector {
final long remaining = writer.in().remaining();
try {
String result = map.persistedDataVersion();
- writeObject(writer,result);
+ writeObject(writer, result);
} catch (Throwable e) {
return sendException(writer, sizeLocation, e);
}
diff --git a/src/main/resources/map.version b/src/main/resources/map.version
new file mode 100644
index 000000000..f2ab45c3b
--- /dev/null
+++ b/src/main/resources/map.version
@@ -0,0 +1 @@
+${project.version}
\ No newline at end of file
diff --git a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java
index 6ac2e3b72..44924b1c1 100644
--- a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java
+++ b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java
@@ -87,6 +87,7 @@ public class MapByNameTest {
ChronicleMap myMap2 = mapByName.from("myMap");
}
+ @Ignore("causing issues on windows")
@Test
public void testReplicationHubSerialization() throws IOException, InterruptedException,
TimeoutException {
diff --git a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java
index 7b1aaee1e..13a4bbf25 100644
--- a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java
+++ b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java
@@ -96,7 +96,6 @@ public class TcpReplicationSoakTest {
}
- @Ignore
@Test
public void testSoakTestWithRandomData() throws IOException, InterruptedException {
try {