diff --git a/kahadb/src/main/java/org/apache/kahadb/journal/DataFileAppender.java b/kahadb/src/main/java/org/apache/kahadb/journal/DataFileAppender.java index 9ef6fae554..c1d9e5b82c 100644 --- a/kahadb/src/main/java/org/apache/kahadb/journal/DataFileAppender.java +++ b/kahadb/src/main/java/org/apache/kahadb/journal/DataFileAppender.java @@ -38,8 +38,6 @@ import org.apache.kahadb.util.LinkedNodeList; */ class DataFileAppender { - protected static final int DEFAULT_MAX_BATCH_SIZE = 1024 * 1024 * 4; - protected final Journal journal; protected final Map inflightWrites; protected final Object enqueueMutex = new Object() { @@ -49,7 +47,7 @@ class DataFileAppender { protected boolean shutdown; protected IOException firstAsyncException; protected final CountDownLatch shutdownDone = new CountDownLatch(1); - protected int maxWriteBatchSize = DEFAULT_MAX_BATCH_SIZE; + protected int maxWriteBatchSize; private boolean running; private Thread thread; @@ -145,6 +143,7 @@ class DataFileAppender { public DataFileAppender(Journal dataManager) { this.journal = dataManager; this.inflightWrites = this.journal.getInflightWrites(); + this.maxWriteBatchSize = this.journal.getWriteBatchSize(); } /** diff --git a/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java b/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java index ee2ed50a47..6170d40a39 100644 --- a/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java +++ b/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java @@ -73,7 +73,8 @@ public class Journal { public static final int DEFAULT_MAX_FILE_LENGTH = 1024 * 1024 * 32; public static final int DEFAULT_CLEANUP_INTERVAL = 1000 * 30; public static final int PREFERED_DIFF = 1024 * 512; - + public static final int DEFAULT_MAX_WRITE_BATCH_SIZE = 1024 * 1024 * 4; + private static final Log LOG = LogFactory.getLog(Journal.class); protected final Map inflightWrites = new ConcurrentHashMap(); @@ -86,7 +87,8 @@ public class Journal { protected int maxFileLength = DEFAULT_MAX_FILE_LENGTH; protected int preferedFileLength = DEFAULT_MAX_FILE_LENGTH - PREFERED_DIFF; - + protected int writeBatchSize = DEFAULT_MAX_WRITE_BATCH_SIZE; + protected DataFileAppender appender; protected DataFileAccessorPool accessorPool; @@ -102,6 +104,8 @@ public class Journal { protected boolean checksum; protected boolean checkForCorruptionOnStartup; + + public synchronized void start() throws IOException { if (started) { return; @@ -175,9 +179,6 @@ public class Journal { } protected Location recoveryCheck(DataFile dataFile) throws IOException { - byte controlRecord[] = new byte[BATCH_CONTROL_RECORD_SIZE]; - DataByteArrayInputStream controlIs = new DataByteArrayInputStream(controlRecord); - Location location = new Location(); location.setDataFileId(dataFile.getDataFileId()); location.setOffset(0); @@ -707,4 +708,12 @@ public class Journal { public void setCheckForCorruptionOnStartup(boolean checkForCorruptionOnStartup) { this.checkForCorruptionOnStartup = checkForCorruptionOnStartup; } + + public void setWriteBatchSize(int writeBatchSize) { + this.writeBatchSize = writeBatchSize; + } + + public int getWriteBatchSize() { + return writeBatchSize; + } }