Skip to content

Commit

Permalink
HCOLL-103 Remove the builder() method in shared hash map
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Austin committed Jul 9, 2014
1 parent 77d88bc commit bdb97f8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 34 deletions.
Expand Up @@ -52,11 +52,6 @@ public Object acquireUsing(Object key, Object value) {
return delegate.acquireUsing(key, value);
}

@Override
public SharedHashMapBuilder builder() {
return delegate.builder();
}

@Override
public File file() {
return delegate.file();
Expand Down
Expand Up @@ -47,13 +47,6 @@ public interface SharedHashMap<K, V> extends ConcurrentMap<K, V>, Closeable {
*/
V acquireUsing(K key, V value);

/**
* Obtain the builder settings for this SharedHashMap
*
* @return a builder which would configure a map the same as this one.
*/
SharedHashMapBuilder builder();

/**
* @return The file or directory for this SharedHashMap
*/
Expand Down
Expand Up @@ -141,10 +141,6 @@ public AbstractVanillaSharedHashMap(SharedHashMapBuilder builder,
this.segments = ss;
}

public SharedHashMapBuilder builder() {
return builder.clone();
}

Class segmentType() {
return Segment.class;
}
Expand Down
Expand Up @@ -257,11 +257,6 @@ public V acquireUsing(K key, V value) {
return map1.acquireUsing(key, value);
}

@Override
public SharedHashMapBuilder builder() {
throw new UnsupportedOperationException();
}

@Override
public File file() {
throw new UnsupportedOperationException();
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.junit.runners.Parameterized;

import java.io.IOException;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Expand Down Expand Up @@ -354,13 +353,6 @@ public static boolean waitTimeEqual(long timeMs, Object expected,
return false;
}

public static void main(String... args) {
BigDecimal bd = BigDecimal.ONE;
bd = bd.divide(BigDecimal.valueOf(49));
/* final BigDecimal a = BigDecimal.valueOf(49).multiply(BigDecimal.valueOf(2));
bd = bd.multiply(a);*/
System.out.println("bd=" + bd);
}
}


Expand Down
Expand Up @@ -26,6 +26,8 @@
import java.io.IOException;
import java.net.InetSocketAddress;

import static java.util.concurrent.TimeUnit.SECONDS;
import static net.openhft.collections.Builder.getPersistenceFile;
import static org.junit.Assert.assertEquals;

/**
Expand All @@ -43,9 +45,20 @@ public class TCPSocketReplicationBootStrapTests {
public void testBootstrap() throws IOException, InterruptedException {

map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8079);

final TcpReplicatorBuilder tcpReplicatorBuilder =
new TcpReplicatorBuilder(8076, new InetSocketAddress("localhost", 8079))
.heartBeatInterval(1, SECONDS);


final SharedHashMapBuilder builder = new SharedHashMapBuilder()
.entries(1000)
.identifier((byte) 2)
.tcpReplicatorBuilder(tcpReplicatorBuilder)
.entries(20000);
final VanillaSharedReplicatedHashMap<Integer,
CharSequence> map2a = TCPSocketReplication4WayMapTest
.newTcpSocketShmIntString((byte) 2, 8076, new InetSocketAddress("localhost", 8079));
CharSequence> map2a = (VanillaSharedReplicatedHashMap<Integer, CharSequence>) builder
.create(getPersistenceFile(), Integer.class, CharSequence.class);
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2

long lastModificationTime;
Expand All @@ -72,7 +85,7 @@ public void testBootstrap() throws IOException, InterruptedException {
}

// now restart map2a and doConnect it to map1, map1 should bootstrap the missing entry
map2 = map2a.builder().create(map2File, Integer.class, CharSequence.class);
map2 = builder.create(map2File, Integer.class, CharSequence.class);

// add data into it
waitTillEqual(5000);
Expand All @@ -87,7 +100,19 @@ public void testBootstrap() throws IOException, InterruptedException {
public void testBootstrapAndHeartbeat() throws IOException, InterruptedException {

map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8079, new InetSocketAddress("localhost", 8076));
final VanillaSharedReplicatedHashMap<Integer, CharSequence> map2a = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, 8076);

final TcpReplicatorBuilder tcpReplicatorBuilder =
new TcpReplicatorBuilder(8076)
.heartBeatInterval(1, SECONDS);


final SharedHashMapBuilder builder = new SharedHashMapBuilder()
.entries(1000)
.identifier((byte) 2)
.tcpReplicatorBuilder(tcpReplicatorBuilder)
.entries(20000);
final VanillaSharedReplicatedHashMap<Integer, CharSequence> map2a = (VanillaSharedReplicatedHashMap<Integer, CharSequence>) builder
.create(getPersistenceFile(), Integer.class, CharSequence.class);

map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2

Expand Down Expand Up @@ -115,7 +140,7 @@ public void testBootstrapAndHeartbeat() throws IOException, InterruptedException
}

// now restart map2a and doConnect it to map1, map1 should bootstrap the missing entry
map2 = map2a.builder().create(map2File, Integer.class, CharSequence.class);
map2 = builder.create(map2File, Integer.class, CharSequence.class);

// add data into it
waitTillEqual(20000);
Expand Down

0 comments on commit bdb97f8

Please sign in to comment.