private V createValueIfNull(V value) { if (value == null) { if (generatedValueType) value = DataValueClasses.newDirectReference(vClass); else try { value = vClass.newInstance(); } catch (Exception e) { throw new AssertionError(e); } } return value; }
@Before public void setup() throws IOException { value = DataValueClasses.newDirectReference(IntValue.class); ((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0); final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1); timeProvider = new TimeProvider() { Random rnd = new Random(4); @Override public long currentTime() { if (rnd.nextBoolean()) return t++; else return t; } }; { final TcpTransportAndNetworkConfig tcpConfig1 = TcpTransportAndNetworkConfig.of(s_port, endpoint); map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(Builder.SIZE) .timeProvider(timeProvider) .replication((byte) 1, tcpConfig1) .create(); } { final TcpTransportAndNetworkConfig tcpConfig2 = TcpTransportAndNetworkConfig.of(s_port + 1); map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(Builder.SIZE) .timeProvider(timeProvider) .replication((byte) 2, tcpConfig2) .create(); } s_port += 2; }