package chronicle_test;
import java.io.IOException;
import net.openhft.chronicle.ExcerptTailer;import net.openhft.chronicle.IndexedChronicle;
public class ChronicleReader { private final IndexedChronicle indexedChronicle; private final ExcerptTailer tailer;
public ChronicleReader(String chronicleFilePath) throws IOException { indexedChronicle = new IndexedChronicle(chronicleFilePath); tailer = indexedChronicle.createTailer(); }
public static void main(String[] args) throws IOException { String chronicleFilePath = args[0]; ChronicleReader chronicleWriter = new ChronicleReader(chronicleFilePath); chronicleWriter.startReading();
}
private void startReading() { while (true) { while (tailer.nextIndex()) { int readInt = tailer.readInt(); System.out.println("Readint=" + readInt); } } }}
package chronicle_test;
import java.io.IOException;
import net.openhft.chronicle.ExcerptAppender;import net.openhft.chronicle.IndexedChronicle;
public class ChronicleWriter implements Runnable {
private final IndexedChronicle indexedChronicle; private final ExcerptAppender createAppender; private Thread thread;
public ChronicleWriter(String chronicleFilePath) throws IOException { indexedChronicle = new IndexedChronicle(chronicleFilePath); createAppender = indexedChronicle.createAppender(); }
public static void main(String[] args) throws IOException { String chronicleFilePath = args[0]; ChronicleWriter chronicleWriter = new ChronicleWriter(chronicleFilePath); chronicleWriter.startWriting(); }
private void startWriting() { writeEvent(1); thread = new Thread(this); thread.start(); try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } }
private void writeEvent(int v) { createAppender.startExcerpt(); createAppender.writeInt(v); createAppender.finish(); }
@Override public void run() { int i = 0; while (true) { i++; writeEvent(i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }}
This is not a configuration we have tested. NFS can do some strange things with caching of files. For now I suggest you use the TCP replication even if this means you have two copies on the same NFS server.
--
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.