On a server if you have a number of Java processes and then within each Java process you create an instance of a ChronicleMap which binds to the same underline 'file', they exchange data via shared memory rather than TCP or UDP replication. So if a ChronicleMap which is not performing TCP Replication is updated, this update can be picked up by another ChronicleMap. This other ChronicleMap could be a TCP replicated ChronicleMap. In such an example the TCP replicated ChronicleMap would then push the update to the remote nodes.
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am working with Chronicle Map for a monitoring setup, and have a question about good- or best-practice for setting up replication.My base case uses two processes. The first listens to my event stream and updates the value objects in my map, the second reads the map and updates an operator (GUI) display. So far in my development, I have been doing this on the same machine using a persisted file, and it works swimmingly. I am now ready to split them up so the operator display can run remote from the actual data collection.The Technical Guide suggests that one may run two maps on the same server, only one of which is replicated:On a server if you have a number of Java processes and then within each Java process you create an instance of a ChronicleMap which binds to the same underline 'file', they exchange data via shared memory rather than TCP or UDP replication. So if a ChronicleMap which is not performing TCP Replication is updated, this update can be picked up by another ChronicleMap. This other ChronicleMap could be a TCP replicated ChronicleMap. In such an example the TCP replicated ChronicleMap would then push the update to the remote nodes.I assume the reason to do this is to split out the replication processing (which may be servicing a throttled consumer) from more critical processing operating at full speed, operating it as service to the other map users. Indeed, this is exactly what I would like to do. Which brings me to two questions:1. Am I reading the Technical Guide correctly, setting up a replication service is reasonable?
Kent--- some code, pretty much boilerplatepublic static void main(String[] args) {final ChronicleMap<Integer, Double> map;String remoteAddress = args[0];ChronicleMapBuilder<Integer, Double> builder = ChronicleMapBuilder.of(Integer.class, Double.class).entries(100_000).replication(configureReplication(1234, 5678, remoteAddress));
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig .of(8076, new InetSocketAddress("localhost", 8077)) .heartBeatInterval(1L, TimeUnit.SECONDS); ChronicleMapBuilder<Integer, CharSequence> map1Builder = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 1, tcpConfig);
map = builder.create();//start replicating -- *** what to do here? ***
//Thread.Sleep() doesn’t seem like the right thing
To follow up on your question above, I am trying to run 2 services on one machine, and one service on the other. I would welcome any pointers you had for handling this case.
TcpTransportAndNetworkConfig tcpConfig1 = …
TcpTransportAndNetworkConfig tcpConfig2 = ...
byte server1Identifier =1;
byte server2Identifier =2
map1Server1 = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .replication(server1Identifier, tcpConfig1) // used to provide just the servers port .createPersistedTo(file); // must be the same file as used by map2Server2
map2Server1 = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .replication(server1Identifier) // notice NO tcpConfig, so this will get the updates via map1Server1 using the file, the server1Identifier ** must ** be the same as map1Server1 .createPersistedTo(file); // must be the same file as used by map1Server1
map3Server2 = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .replication(server2Identifier, tcpConfig2) // used to connect to server1 .createPersistedTo(file); // must be the same file as used by map1Server2
On 26 Feb 2015, at 16:20, Rob Austin <rob.a...@higherfrequencytrading.com> wrote:map2Server1 = ChronicleMapBuilder .of(Integer.class, CharSequence.class) .replication(server1Identifier) // notice NO tcpConfig, so this will get the updates via map1Server1 using the file, the server1Identifier ** must ** be the same as map1Server1 .createPersistedTo(file); // must be the same file as used by map1Server1
TcpTransportAndNetworkConfig tcpConfig = !isProducer
? TcpTransportAndNetworkConfig.of(8111, new InetSocketAddress("localhost", 8222))
: TcpTransportAndNetworkConfig.of(8222);
<Main.java>
try (WriteContext wc = map.acquireUsingLocked("1", using)) {
assertTrue(using instanceof StringBuilder);
((StringBuilder) using).append("Hello World");
} // dirty flag triggered here, lock also released
@Test
public void testAcquireUsingWithCharSequence() throws IOException {
if (typeOfMap == TypeOfMap.STATELESS)
return; // getUsingLocked supported by the STATELESS client
ChronicleMapBuilder<CharSequence, CharSequence> builder = ChronicleMapBuilder
.of(CharSequence.class, CharSequence.class);
try (ChronicleMap<CharSequence, CharSequence> map = newInstance(builder)) {
CharSequence using = map.newValueInstance();
try (WriteContext wc = map.acquireUsingLocked("1", using)) {
assertTrue(using instanceof StringBuilder);
((StringBuilder) using).append("Hello World");
}
assertEquals("Hello World", map.get("1"));
mapChecks();
}
}
<Main.java>