public MessageStore(final String topic, final int partition, final MetaConfig metaConfig,
final DeletePolicy deletePolicy, final long offsetIfCreate) throws IOException {
this.metaConfig = metaConfig;
this.topic = topic;
final TopicConfig topicConfig = this.metaConfig.getTopicConfig(this.topic);
String dataPath = metaConfig.getDataPath();
if (topicConfig != null) {
dataPath = topicConfig.getDataPath();
}
final File parentDir = new File(dataPath);
this.checkDir(parentDir);
this.partitionDir = new File(dataPath + File.separator + topic + "-" + partition);
this.checkDir(this.partitionDir);
// this.topic = topic;
this.partition = partition;
this.unflushed = new AtomicInteger(0);
this.lastFlushTime = new AtomicLong(SystemTimer.currentTimeMillis());
this.unflushThreshold = topicConfig.getUnflushThreshold();
this.deletePolicy = deletePolicy;
// Make a copy to avoid getting it again and again.
this.maxTransferSize = metaConfig.getMaxTransferSize();
this.maxTransferSize = this.maxTransferSize > ONE_M_BYTES ? ONE_M_BYTES : this.maxTransferSize;