本文整理汇总了Java中net.openhft.chronicle.ExcerptAppender类的典型用法代码示例。如果您正苦于以下问题:Java ExcerptAppender类的具体用法?Java ExcerptAppender怎么用?Java ExcerptAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExcerptAppender类属于net.openhft.chronicle包,在下文中一共展示了ExcerptAppender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAppend
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testAppend() throws IOException {
final int RUNS = 1000;
final String baseDir = getTestPath();
assertNotNull(baseDir);
VanillaChronicleConfig config = new VanillaChronicleConfig();
config.defaultMessageSize(128);
config.indexBlockSize(1024);
config.dataBlockSize(1024);
VanillaChronicle chronicle = new VanillaChronicle(baseDir, config);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
for (int i = 0; i < RUNS; i++) {
appender.startExcerpt();
appender.append(1000000000 + i);
appender.finish();
chronicle.checkCounts(1, 2);
}
appender.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:36,代码来源:VanillaChronicleTest.java
示例2: testTailerToEnd1
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerToEnd1() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
// test a vanilla tailer, wind to end
ExcerptTailer tailer = chronicle.createTailer().toEnd();
assertEquals(2, tailer.readLong());
assertFalse(tailer.nextIndex());
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:33,代码来源:VanillaChronicleTest.java
示例3: testTailerToEnd2
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerToEnd2() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle wchronicle = new VanillaChronicle(baseDir);
wchronicle.clear();
try {
ExcerptAppender appender = wchronicle.createAppender();
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
// test a vanilla tailer, wind to end
final VanillaChronicle rchronicle = new VanillaChronicle(baseDir);
final ExcerptTailer tailer = rchronicle.createTailer().toEnd();
assertEquals(2, tailer.readLong());
assertFalse(tailer.nextIndex());
appender.close();
tailer.close();
rchronicle.checkCounts(1, 1);
rchronicle.close();
wchronicle.checkCounts(1, 1);
} finally {
wchronicle.close();
wchronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:38,代码来源:VanillaChronicleTest.java
示例4: createAppender
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
public ExcerptAppender createAppender() {
try {
return queue.createAppender();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:terzerm,项目名称:fx-highway,代码行数:8,代码来源:ChronicleSource.java
示例5: appendValues
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
private static void appendValues(final ExcerptAppender appender, final long startValue, final long endValue) {
long counter = startValue;
while (counter < endValue) {
appender.startExcerpt(20);
appender.writeUTF("data-" + counter);
appender.finish();
counter++;
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:10,代码来源:VanillaChronicleTest.java
示例6: createAppendTask
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
private static Callable<Void> createAppendTask(final VanillaChronicle chronicle, final long startValue,
final long endValue) {
return new Callable<Void>() {
@Override
public Void call() throws Exception {
final ExcerptAppender appender = chronicle.createAppender();
try {
appendValues(appender, startValue, endValue);
} finally {
appender.close();
}
return null;
}
};
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:16,代码来源:VanillaChronicleTest.java
示例7: testTailerToEnd1
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerToEnd1() throws IOException {
final String baseDir = "build/vanilla";
assertNotNull(baseDir);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
appender.close();
// test a vanilla tailer, wind to end
ExcerptTailer tailer = chronicle.createTailer().toEnd();
assertEquals(2, tailer.readLong());
assertFalse(tailer.nextIndex());
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:30,代码来源:VanillaChronicleUnitTest.java
示例8: testAppender
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testAppender() throws Exception {
String dataDir = "build/chronicle";
FileUtil.removeIfExist(dataDir, true);
System.out.println("data dir: " + dataDir);
IndexedChronicle chronicle = new IndexedChronicle(dataDir + "/data", ChronicleConfig.SMALL);
ExcerptAppender appender = chronicle.createAppender();
appender.startExcerpt(8);
appender.writeLong(10l);
appender.finish();
for(int i = 0; i < 10; i++) {
String string = "test " + i ;
byte[] data = string.getBytes() ;
appender.startExcerpt(data.length);
appender.write(data);
appender.finish();
}
ExcerptTailer reader = chronicle.createTailer();
reader.index(1) ;
while (reader.nextIndex()) {
System.out.println("Read string by reader: " + reader.readLine());
}
Excerpt excerpt = chronicle.createExcerpt() ;
excerpt.index(1);
while(excerpt.nextIndex()) {
System.out.println("Read string by exerpt: " + excerpt.readLine());
}
appender.close();
reader.close();
excerpt.close();
excerpt = chronicle.createExcerpt() ;
long longNumber = excerpt.readLong() ;
System.out.println("Long number = " + longNumber);
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:40,代码来源:IndexedChronicleUnitTest.java
示例9: getAppender
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
public ExcerptAppender getAppender() {
return appender;
}
开发者ID:terzerm,项目名称:fx-highway,代码行数:4,代码来源:ChronicleRemoteAppender.java
示例10: ChronicleSender
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
public ChronicleSender(final ExcerptAppender appender) {
this.appender = Objects.requireNonNull(appender);
}
开发者ID:terzerm,项目名称:hover-raft,代码行数:4,代码来源:ChronicleSender.java
示例11: testAppend4
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testAppend4() throws IOException, InterruptedException {
final int RUNS = 5000000; // increase to 25 million for a proper test. Can be
// 50% faster.
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicleConfig config = new VanillaChronicleConfig().defaultMessageSize(64);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir, config);
chronicle.clear();
try {
long start = System.nanoTime();
ExecutorService es = Executors.newFixedThreadPool(N_THREADS);
for (int t = 0; t < N_THREADS; t++) {
final int finalT = t;
es.submit(new Runnable() {
@Override
public void run() {
try {
ExcerptAppender appender = chronicle.createAppender();
for (int i = 0; i < RUNS; i++) {
appender.startExcerpt();
appender.appendDateMillis(System.currentTimeMillis())
.append(" - ")
.append(finalT)
.append(" / ")
.append(i)
.append('\n');
appender.finish();
}
appender.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
});
}
es.shutdown();
es.awaitTermination(30, TimeUnit.SECONDS);
long time = System.nanoTime() - start;
System.out.printf("Throughput was %.0f per milli-second%n", 1e6 * (RUNS * N_THREADS) / time);
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:59,代码来源:VanillaChronicleTest.java
示例12: testTailer
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailer() throws IOException {
final int RUNS = 1000000; // 5000000;
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicleConfig config = new VanillaChronicleConfig();
config.defaultMessageSize(128);
config.indexBlockSize(256 << 10);
config.dataBlockSize(512 << 10);
final VanillaChronicle chronicle1 = new VanillaChronicle(baseDir, config);
chronicle1.clear();
final VanillaChronicle chronicle2 = new VanillaChronicle(baseDir, config);
try {
ExcerptAppender appender = chronicle1.createAppender();
ExcerptTailer tailer = chronicle2.createTailer();
assertEquals(-1L, tailer.index());
for (int i = 0; i < RUNS; i++) {
// if ((i & 65535) == 0)
// System.err.println("i: " + i);
// if (i == 88000)
// Thread.yield();
assertFalse(tailer.nextIndex());
appender.startExcerpt();
int value = 1000000000 + i;
appender.append(value).append(' ');
appender.finish();
chronicle1.checkCounts(1, 2);
assertTrue("i: " + i, tailer.nextIndex());
chronicle2.checkCounts(1, 2);
assertTrue("i: " + i + " remaining: " + tailer.remaining(), tailer.remaining() > 0);
assertEquals("i: " + i, value, tailer.parseLong());
assertEquals("i: " + i, 0, tailer.remaining());
tailer.finish();
chronicle2.checkCounts(1, 2);
}
appender.close();
tailer.close();
chronicle2.checkCounts(1, 1);
chronicle1.checkCounts(1, 1);
} finally {
chronicle2.close();
chronicle1.close();
chronicle1.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:57,代码来源:VanillaChronicleTest.java
示例13: testTailerPerf
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerPerf() throws IOException {
final int WARMUP = 50000;
final int RUNS = 5000000;
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir);
chronicle.clear();
try {
final ExcerptAppender appender = chronicle.createAppender();
final ExcerptTailer tailer = chronicle.createTailer();
long start = 0;
assertEquals(-1L, tailer.index());
for (int i = -WARMUP; i < RUNS; i++) {
if (i == 0)
start = System.nanoTime();
boolean condition0 = tailer.nextIndex();
if (condition0)
assertFalse("i: " + i, condition0);
appender.startExcerpt();
int value = 1000000000 + i;
appender.append(value).append(' ');
appender.finish();
boolean condition = tailer.nextIndex();
long actual = tailer.parseLong();
if (i < 0) {
assertTrue("i: " + i, condition);
assertEquals("i: " + i, value, actual);
}
tailer.finish();
}
long time = System.nanoTime() - start;
System.out.printf("Average write/read times was %.3f us%n", time / RUNS / 1e3);
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:50,代码来源:VanillaChronicleTest.java
示例14: testFindRange
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Ignore
@Test(expected = UnsupportedOperationException.class)
public void testFindRange() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir);
try {
ExcerptAppender appender = chronicle.createAppender();
List<Integer> ints = new ArrayList<Integer>();
for (int i = 0; i < 1000; i += 10) {
appender.startExcerpt();
appender.writeInt(i);
appender.finish();
ints.add(i);
}
appender.close();
Excerpt excerpt = chronicle.createExcerpt();
final MyExcerptComparator mec = new MyExcerptComparator();
// exact matches at a the start
mec.lo = mec.hi = -1;
assertEquals(~0, excerpt.findMatch(mec));
mec.lo = mec.hi = 0;
assertEquals(0, excerpt.findMatch(mec));
mec.lo = mec.hi = 9;
assertEquals(~1, excerpt.findMatch(mec));
mec.lo = mec.hi = 10;
assertEquals(1, excerpt.findMatch(mec));
// exact matches at a the end
mec.lo = mec.hi = 980;
assertEquals(98, excerpt.findMatch(mec));
mec.lo = mec.hi = 981;
assertEquals(~99, excerpt.findMatch(mec));
mec.lo = mec.hi = 990;
assertEquals(99, excerpt.findMatch(mec));
mec.lo = mec.hi = 1000;
assertEquals(~100, excerpt.findMatch(mec));
// range match near the start
long[] startEnd = new long[2];
mec.lo = 0;
mec.hi = 3;
excerpt.findRange(startEnd, mec);
assertEquals("[0, 1]", Arrays.toString(startEnd));
mec.lo = 21;
mec.hi = 29;
excerpt.findRange(startEnd, mec);
assertEquals("[3, 3]", Arrays.toString(startEnd));
/*
* mec.lo = 129; mec.hi = 631; testSearchRange(ints, excerpt, mec,
* startEnd);
*/
Random rand = new Random(1);
for (int i = 0; i < 1000; i++) {
int x = rand.nextInt(1010) - 5;
int y = rand.nextInt(1010) - 5;
mec.lo = Math.min(x, y);
mec.hi = Math.max(x, y);
testSearchRange(ints, excerpt, mec, startEnd);
}
excerpt.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:78,代码来源:VanillaChronicleTest.java
示例15: testTailerToStart
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerToStart() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
VanillaChronicle chronicle = new VanillaChronicle(baseDir);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
ExcerptTailer tailer = null;
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
// test a vanilla tailer, no rewind
tailer = chronicle.createTailer();
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
// test a vanilla tailer, rewind
tailer = chronicle.createTailer().toStart();
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:46,代码来源:VanillaChronicleTest.java
示例16: testTailerEndStart1
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerEndStart1() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
// test a vanilla tailer, wind to end on an empty chronicle
ExcerptTailer tailer = chronicle.createTailer().toEnd();
assertFalse(tailer.nextIndex());
// add some data to the chronicle
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
// test that the tailer now can tail
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
// test a vanilla tailer, wind to end
tailer = chronicle.createTailer().toEnd();
assertEquals(2, tailer.readLong());
assertFalse(tailer.nextIndex());
tailer.finish();
// test a vanilla tailer, rewind
tailer = chronicle.createTailer().toStart();
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:55,代码来源:VanillaChronicleTest.java
示例17: testTailerEndStart2
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testTailerEndStart2() throws IOException {
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicle wchronicle = new VanillaChronicle(baseDir);
final VanillaChronicle rchronicle = new VanillaChronicle(baseDir);
wchronicle.clear();
try {
ExcerptAppender appender = wchronicle.createAppender();
// test a vanilla tailer, wind to end on an empty chronicle
ExcerptTailer tailer = rchronicle.createTailer().toEnd();
assertFalse(tailer.nextIndex());
// add some data to the chronicle
for (long i = 0; i < 3; i++) {
appender.startExcerpt();
appender.writeLong(i);
appender.finish();
}
// test that the tailer now can tail
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
// test a vanilla tailer, wind to end
tailer = rchronicle.createTailer().toEnd();
assertEquals(2, tailer.readLong());
assertFalse(tailer.nextIndex());
tailer.finish();
// test a vanilla tailer, rewind
tailer = rchronicle.createTailer().toStart();
for (long i = 0; i < 3; i++) {
assertTrue(tailer.nextIndex());
assertEquals(i, tailer.readLong());
tailer.finish();
}
appender.close();
tailer.close();
rchronicle.checkCounts(1, 1);
wchronicle.checkCounts(1, 1);
} finally {
rchronicle.close();
wchronicle.close();
wchronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:60,代码来源:VanillaChronicleTest.java
示例18: testReplicationWithRollingFilesEverySecond
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testReplicationWithRollingFilesEverySecond() throws Exception {
// TODO int RUNS = 100000;
final int RUNS = 5 * 1000;
final String baseDir = getTestPath();
assertNotNull(baseDir);
final VanillaChronicleConfig config = new VanillaChronicleConfig();
config.entriesPerCycle(1L << 16);
config.cycleLength(1000, false);
config.cycleFormat("yyyyMMddHHmmss");
config.indexBlockSize(16L << 10);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir, config);
chronicle.clear();
try {
ExcerptAppender appender = chronicle.createAppender();
ExcerptTailer tailer = chronicle.createTailer();
long lastMajor = 0;
for (int i = 0; i < RUNS; i++) {
appender.startExcerpt();
long value = 1000000000 + i;
appender.append(value).append(' ');
appender.finish();
// System.out.println("Sleeping " +i );
Thread.sleep(1);
assertTrue(tailer.nextIndex());
long major = tailer.index() / config.entriesPerCycle();
if (lastMajor == 0 || lastMajor == major) {
// ok.
} else if (lastMajor + 1 == major) {
System.out.println("Major: " + major);
} else {
assertEquals("major jumped", lastMajor + 1, major);
}
lastMajor = major;
// System.out.printf("Index: %x%n", major);
assertEquals("i: " + i, value, tailer.parseLong());
assertEquals("i: " + i, 0, tailer.remaining());
tailer.finish();
}
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:57,代码来源:VanillaChronicleTest.java
示例19: testMultipleCycles
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testMultipleCycles() throws Exception {
final String baseDir = getTestPath();
System.out.println("base dir: " + baseDir);
assertNotNull(baseDir);
// Create with small data and index sizes so that the test frequently
// generates new files
final VanillaChronicleConfig config = new VanillaChronicleConfig();
config.entriesPerCycle(1L << 20); // avoid overflow of the entry indexes
config.cycleLength(1000, false); // 1 second
config.cycleFormat("yyyyMMddHHmmss");
config.dataBlockSize(128);
config.indexBlockSize(64);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir, config);
chronicle.clear();
try {
final ExcerptAppender appender = chronicle.createAppender();
appendValues(appender, 1, 20);
// Ensure the appender writes in another cycle from the initial writes
Thread.sleep(2000L);
appendValues(appender, 20, 40);
// Verify that all values are read by the tailer
final ExcerptTailer tailer = chronicle.createTailer();
assertEquals(createRangeDataSet(1, 40), readAvailableValues(tailer));
// Verify that the tailer reads no new data from a new cycle
Thread.sleep(2000L);
assertTrue(!tailer.nextIndex());
// ### Throws java.lang.NullPointerException
// - lastIndexFile is set to null by the previous call to nextIndex
assertTrue(!tailer.nextIndex());
// Append data in this new cycle
appendValues(appender, 41, 60);
// Verify that the tailer can read the new data
assertEquals(createRangeDataSet(41, 60), readAvailableValues(tailer));
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:56,代码来源:VanillaChronicleTest.java
示例20: testMultipleCycles2
import net.openhft.chronicle.ExcerptAppender; //导入依赖的package包/类
@Test
public void testMultipleCycles2() throws Exception {
final String baseDir = getTestPath();
assertNotNull(baseDir);
// Create with small data and index sizes so that the test frequently
// generates new files
final VanillaChronicleConfig config = new VanillaChronicleConfig();
config.entriesPerCycle(1L << 20); // avoid overflow of the entry indexes
config.cycleLength(1000, false); // 1 second
config.cycleFormat("yyyyMMddHHmmss");
config.dataBlockSize(128);
config.indexBlockSize(64);
final VanillaChronicle chronicle = new VanillaChronicle(baseDir, config);
chronicle.clear();
try {
final ExcerptAppender appender = chronicle.createAppender();
final ExcerptTailer tailer = chronicle.createTailer();
// Append a small number of events in this cycle
appendValues(appender, 1, 5);
// Ensure the appender writes in another cycle from the initial writes
Thread.sleep(2000L);
appendValues(appender, 5, 50);
// ### Fails because it only reads the values written in the first cycle
assertEquals(createRangeDataSet(1, 50), readAvailableValues(tailer));
appender.close();
tailer.close();
chronicle.checkCounts(1, 1);
} finally {
chronicle.close();
chronicle.clear();
assertFalse(new File(baseDir).exists());
}
}
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:44,代码来源:VanillaChronicleTest.java
注:本文中的net.openhft.chronicle.ExcerptAppender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论