This commit is contained in:
Rob Austin
2015-01-15 15:37:29 +00:00
6 changed files with 51 additions and 15 deletions
+20 -2
View File
@@ -29,7 +29,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>chronicle-map</artifactId>
<version>2.0.22rc3-SNAPSHOT</version>
<version>2.0.22rc6-SNAPSHOT</version>
<name>OpenHFT/Chronicle-Map</name>
<description>Chronicle-Map</description>
@@ -47,7 +47,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>lang</artifactId>
<version>6.4.22-SNAPSHOT</version>
<version>6.4.22</version>
</dependency>
<dependency>
@@ -142,6 +142,24 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/map.version</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/map.version</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
@@ -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) {
@@ -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<K, V> 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<K, V> 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<K, V> {
final Function<V, ?> function = (Function<V, ?>) 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<K, V> {
final UnaryOperator<V> unaryOperator = (UnaryOperator<V>) 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<K, V> {
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);
}
+1
View File
@@ -0,0 +1 @@
${project.version}
@@ -87,6 +87,7 @@ public class MapByNameTest {
ChronicleMap<CharSequence, CharSequence> myMap2 = mapByName.from("myMap");
}
@Ignore("causing issues on windows")
@Test
public void testReplicationHubSerialization() throws IOException, InterruptedException,
TimeoutException {
@@ -96,7 +96,6 @@ public class TcpReplicationSoakTest {
}
@Ignore
@Test
public void testSoakTestWithRandomData() throws IOException, InterruptedException {
try {