git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@785525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-06-17 09:31:54 +00:00
parent 78e7221d3e
commit 2cdb51bb74
2 changed files with 36 additions and 0 deletions

View File

@ -48,6 +48,8 @@ public class ReadOnlyAsyncDataManager extends AsyncDataManager {
}
started = true;
accessorPool = new DataFileAccessorPool(this);
ArrayList<File> files = new ArrayList<File>();
for (File directory : dirs) {

View File

@ -18,6 +18,7 @@ package org.apache.activemq.kaha.impl.async;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import junit.framework.TestCase;
@ -26,6 +27,8 @@ import org.apache.activeio.journal.RecordLocation;
import org.apache.activeio.packet.ByteArrayPacket;
import org.apache.activeio.packet.Packet;
import org.apache.activemq.kaha.impl.async.JournalFacade.RecordLocationFacade;
import org.apache.activemq.kaha.impl.async.ReadOnlyAsyncDataManager;
import org.apache.activemq.util.ByteSequence;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -126,6 +129,37 @@ public class JournalImplTest extends TestCase {
log.info(journal);
}
public void testReadOnlyRead() throws InvalidRecordLocationException, InterruptedException, IOException {
Packet data1 = createPacket("Hello World 1");
RecordLocation location1 = journal.write(data1, false);
Packet data2 = createPacket("Hello World 2");
RecordLocation location2 = journal.write(data2, false);
Packet data3 = createPacket("Hello World 3");
RecordLocation location3 = journal.write(data3, false);
Packet packet;
packet = journal.read(location2);
assertEquals(data2, packet);
packet = journal.read(location1);
assertEquals(data1, packet);
packet = journal.read(location3);
assertEquals(data3, packet);
ArrayList<File> data = new ArrayList<File>();
data.add(logDirectory);
ReadOnlyAsyncDataManager rodm = new ReadOnlyAsyncDataManager(data);
rodm.start();
try {
for (Location curr = rodm.getFirstLocation(); curr != null; curr = rodm.getNextLocation(curr)) {
ByteSequence bs = rodm.read(curr);
assertNotNull(bs);
}
} finally {
rodm.close();
}
}
public void testCanReadFromArchivedLogFile() throws InvalidRecordLocationException, InterruptedException, IOException {
Packet data1 = createPacket("Hello World 1");