提交 af352d51 编写于 作者: S suiyuzeng

code style

上级 da73a1d1
...@@ -66,7 +66,7 @@ public class CommitLog { ...@@ -66,7 +66,7 @@ public class CommitLog {
public CommitLog(final DefaultMessageStore defaultMessageStore) { public CommitLog(final DefaultMessageStore defaultMessageStore) {
this.mappedFileQueue = new MappedFileQueue(defaultMessageStore.getMessageStoreConfig().getStorePathCommitLog(), this.mappedFileQueue = new MappedFileQueue(defaultMessageStore.getMessageStoreConfig().getStorePathCommitLog(),
defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog(), defaultMessageStore.getAllocateMappedFileService()); defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog(), defaultMessageStore.getAllocateMappedFileService());
this.defaultMessageStore = defaultMessageStore; this.defaultMessageStore = defaultMessageStore;
if (FlushDiskType.SYNC_FLUSH == defaultMessageStore.getMessageStoreConfig().getFlushDiskType()) { if (FlushDiskType.SYNC_FLUSH == defaultMessageStore.getMessageStoreConfig().getFlushDiskType()) {
...@@ -129,10 +129,10 @@ public class CommitLog { ...@@ -129,10 +129,10 @@ public class CommitLog {
} }
public int deleteExpiredFile( public int deleteExpiredFile(
final long expiredTime, final long expiredTime,
final int deleteFilesInterval, final int deleteFilesInterval,
final long intervalForcibly, final long intervalForcibly,
final boolean cleanImmediately final boolean cleanImmediately
) { ) {
return this.mappedFileQueue.deleteExpiredFileByTime(expiredTime, deleteFilesInterval, intervalForcibly, cleanImmediately); return this.mappedFileQueue.deleteExpiredFileByTime(expiredTime, deleteFilesInterval, intervalForcibly, cleanImmediately);
} }
...@@ -234,7 +234,7 @@ public class CommitLog { ...@@ -234,7 +234,7 @@ public class CommitLog {
* @return 0 Come the end of the file // >0 Normal messages // -1 Message checksum failure * @return 0 Come the end of the file // >0 Normal messages // -1 Message checksum failure
*/ */
public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer, final boolean checkCRC, public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer, final boolean checkCRC,
final boolean readBody) { final boolean readBody) {
try { try {
// 1 TOTAL SIZE // 1 TOTAL SIZE
int totalSize = byteBuffer.getInt(); int totalSize = byteBuffer.getInt();
...@@ -330,7 +330,7 @@ public class CommitLog { ...@@ -330,7 +330,7 @@ public class CommitLog {
if (delayLevel > 0) { if (delayLevel > 0) {
tagsCode = this.defaultMessageStore.getScheduleMessageService().computeDeliverTimestamp(delayLevel, tagsCode = this.defaultMessageStore.getScheduleMessageService().computeDeliverTimestamp(delayLevel,
storeTimestamp); storeTimestamp);
} }
} }
} }
...@@ -344,24 +344,24 @@ public class CommitLog { ...@@ -344,24 +344,24 @@ public class CommitLog {
doNothingForDeadCode(byteBuffer1); doNothingForDeadCode(byteBuffer1);
doNothingForDeadCode(byteBuffer2); doNothingForDeadCode(byteBuffer2);
log.error( log.error(
"[BUG]read total count not equals msg total size. totalSize={}, readTotalCount={}, bodyLen={}, topicLen={}, propertiesLength={}", "[BUG]read total count not equals msg total size. totalSize={}, readTotalCount={}, bodyLen={}, topicLen={}, propertiesLength={}",
totalSize, readLength, bodyLen, topicLen, propertiesLength); totalSize, readLength, bodyLen, topicLen, propertiesLength);
return new DispatchRequest(totalSize, false/* success */); return new DispatchRequest(totalSize, false/* success */);
} }
return new DispatchRequest( return new DispatchRequest(
topic, topic,
queueId, queueId,
physicOffset, physicOffset,
totalSize, totalSize,
tagsCode, tagsCode,
storeTimestamp, storeTimestamp,
queueOffset, queueOffset,
keys, keys,
uniqKey, uniqKey,
sysFlag, sysFlag,
preparedTransactionOffset, preparedTransactionOffset,
propertiesMap propertiesMap
); );
} catch (Exception e) { } catch (Exception e) {
} }
...@@ -371,23 +371,23 @@ public class CommitLog { ...@@ -371,23 +371,23 @@ public class CommitLog {
private static int calMsgLength(int bodyLength, int topicLength, int propertiesLength) { private static int calMsgLength(int bodyLength, int topicLength, int propertiesLength) {
final int msgLen = 4 //TOTALSIZE final int msgLen = 4 //TOTALSIZE
+ 4 //MAGICCODE + 4 //MAGICCODE
+ 4 //BODYCRC + 4 //BODYCRC
+ 4 //QUEUEID + 4 //QUEUEID
+ 4 //FLAG + 4 //FLAG
+ 8 //QUEUEOFFSET + 8 //QUEUEOFFSET
+ 8 //PHYSICALOFFSET + 8 //PHYSICALOFFSET
+ 4 //SYSFLAG + 4 //SYSFLAG
+ 8 //BORNTIMESTAMP + 8 //BORNTIMESTAMP
+ 8 //BORNHOST + 8 //BORNHOST
+ 8 //STORETIMESTAMP + 8 //STORETIMESTAMP
+ 8 //STOREHOSTADDRESS + 8 //STOREHOSTADDRESS
+ 4 //RECONSUMETIMES + 4 //RECONSUMETIMES
+ 8 //Prepared Transaction Offset + 8 //Prepared Transaction Offset
+ 4 + (bodyLength > 0 ? bodyLength : 0) //BODY + 4 + (bodyLength > 0 ? bodyLength : 0) //BODY
+ 1 + topicLength //TOPIC + 1 + topicLength //TOPIC
+ 2 + (propertiesLength > 0 ? propertiesLength : 0) //propertiesLength + 2 + (propertiesLength > 0 ? propertiesLength : 0) //propertiesLength
+ 0; + 0;
return msgLen; return msgLen;
} }
...@@ -497,18 +497,18 @@ public class CommitLog { ...@@ -497,18 +497,18 @@ public class CommitLog {
} }
if (this.defaultMessageStore.getMessageStoreConfig().isMessageIndexEnable() if (this.defaultMessageStore.getMessageStoreConfig().isMessageIndexEnable()
&& this.defaultMessageStore.getMessageStoreConfig().isMessageIndexSafe()) { && this.defaultMessageStore.getMessageStoreConfig().isMessageIndexSafe()) {
if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestampIndex()) { if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestampIndex()) {
log.info("find check timestamp, {} {}", log.info("find check timestamp, {} {}",
storeTimestamp, storeTimestamp,
UtilAll.timeMillisToHumanString(storeTimestamp)); UtilAll.timeMillisToHumanString(storeTimestamp));
return true; return true;
} }
} else { } else {
if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestamp()) { if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestamp()) {
log.info("find check timestamp, {} {}", log.info("find check timestamp, {} {}",
storeTimestamp, storeTimestamp,
UtilAll.timeMillisToHumanString(storeTimestamp)); UtilAll.timeMillisToHumanString(storeTimestamp));
return true; return true;
} }
} }
...@@ -544,7 +544,7 @@ public class CommitLog { ...@@ -544,7 +544,7 @@ public class CommitLog {
final int tranType = MessageSysFlag.getTransactionValue(msg.getSysFlag()); final int tranType = MessageSysFlag.getTransactionValue(msg.getSysFlag());
if (tranType == MessageSysFlag.TRANSACTION_NOT_TYPE if (tranType == MessageSysFlag.TRANSACTION_NOT_TYPE
|| tranType == MessageSysFlag.TRANSACTION_COMMIT_TYPE) { || tranType == MessageSysFlag.TRANSACTION_COMMIT_TYPE) {
// Delay Delivery // Delay Delivery
if (msg.getDelayTimeLevel() > 0) { if (msg.getDelayTimeLevel() > 0) {
if (msg.getDelayTimeLevel() > this.defaultMessageStore.getScheduleMessageService().getMaxDelayLevel()) { if (msg.getDelayTimeLevel() > this.defaultMessageStore.getScheduleMessageService().getMaxDelayLevel()) {
...@@ -650,7 +650,7 @@ public class CommitLog { ...@@ -650,7 +650,7 @@ public class CommitLog {
boolean flushOK = request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout()); boolean flushOK = request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout());
if (!flushOK) { if (!flushOK) {
log.error("do groupcommit, wait for flush failed, topic: " + messageExt.getTopic() + " tags: " + messageExt.getTags() log.error("do groupcommit, wait for flush failed, topic: " + messageExt.getTopic() + " tags: " + messageExt.getTags()
+ " client address: " + messageExt.getBornHostString()); + " client address: " + messageExt.getBornHostString());
putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_DISK_TIMEOUT); putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_DISK_TIMEOUT);
} }
} else { } else {
...@@ -677,10 +677,10 @@ public class CommitLog { ...@@ -677,10 +677,10 @@ public class CommitLog {
service.putRequest(request); service.putRequest(request);
service.getWaitNotifyObject().wakeupAll(); service.getWaitNotifyObject().wakeupAll();
boolean flushOK = boolean flushOK =
request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout()); request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout());
if (!flushOK) { if (!flushOK) {
log.error("do sync transfer other node, wait return, but failed, topic: " + messageExt.getTopic() + " tags: " log.error("do sync transfer other node, wait return, but failed, topic: " + messageExt.getTopic() + " tags: "
+ messageExt.getTags() + " client address: " + messageExt.getBornHostNameString()); + messageExt.getTags() + " client address: " + messageExt.getBornHostNameString());
putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_SLAVE_TIMEOUT); putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_SLAVE_TIMEOUT);
} }
} }
...@@ -917,7 +917,7 @@ public class CommitLog { ...@@ -917,7 +917,7 @@ public class CommitLog {
int commitDataLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogLeastPages(); int commitDataLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogLeastPages();
int commitDataThoroughInterval = int commitDataThoroughInterval =
CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogThoroughInterval(); CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogThoroughInterval();
long begin = System.currentTimeMillis(); long begin = System.currentTimeMillis();
if (begin >= (this.lastCommitTimestamp + commitDataThoroughInterval)) { if (begin >= (this.lastCommitTimestamp + commitDataThoroughInterval)) {
...@@ -966,7 +966,7 @@ public class CommitLog { ...@@ -966,7 +966,7 @@ public class CommitLog {
int flushPhysicQueueLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogLeastPages(); int flushPhysicQueueLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogLeastPages();
int flushPhysicQueueThoroughInterval = int flushPhysicQueueThoroughInterval =
CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogThoroughInterval(); CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogThoroughInterval();
boolean printFlushProgress = false; boolean printFlushProgress = false;
...@@ -1187,7 +1187,7 @@ public class CommitLog { ...@@ -1187,7 +1187,7 @@ public class CommitLog {
} }
public AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer, final int maxBlank, public AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer, final int maxBlank,
final MessageExtBrokerInner msgInner) { final MessageExtBrokerInner msgInner) {
// STORETIMESTAMP + STOREHOSTADDRESS + OFFSET <br> // STORETIMESTAMP + STOREHOSTADDRESS + OFFSET <br>
// PHY OFFSET // PHY OFFSET
...@@ -1227,7 +1227,7 @@ public class CommitLog { ...@@ -1227,7 +1227,7 @@ public class CommitLog {
* Serialize message * Serialize message
*/ */
final byte[] propertiesData = final byte[] propertiesData =
msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8); msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8);
final int propertiesLength = propertiesData == null ? 0 : propertiesData.length; final int propertiesLength = propertiesData == null ? 0 : propertiesData.length;
...@@ -1246,7 +1246,7 @@ public class CommitLog { ...@@ -1246,7 +1246,7 @@ public class CommitLog {
// Exceeds the maximum message // Exceeds the maximum message
if (msgLen > this.maxMessageSize) { if (msgLen > this.maxMessageSize) {
CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLength CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLength
+ ", maxMessageSize: " + this.maxMessageSize); + ", maxMessageSize: " + this.maxMessageSize);
return new AppendMessageResult(AppendMessageStatus.MESSAGE_SIZE_EXCEEDED); return new AppendMessageResult(AppendMessageStatus.MESSAGE_SIZE_EXCEEDED);
} }
...@@ -1262,7 +1262,7 @@ public class CommitLog { ...@@ -1262,7 +1262,7 @@ public class CommitLog {
final long beginTimeMills = CommitLog.this.defaultMessageStore.now(); final long beginTimeMills = CommitLog.this.defaultMessageStore.now();
byteBuffer.put(this.msgStoreItemMemory.array(), 0, maxBlank); byteBuffer.put(this.msgStoreItemMemory.array(), 0, maxBlank);
return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgId, msgInner.getStoreTimestamp(), return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgId, msgInner.getStoreTimestamp(),
queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
} }
// Initialization of storage space // Initialization of storage space
...@@ -1315,7 +1315,7 @@ public class CommitLog { ...@@ -1315,7 +1315,7 @@ public class CommitLog {
byteBuffer.put(this.msgStoreItemMemory.array(), 0, msgLen); byteBuffer.put(this.msgStoreItemMemory.array(), 0, msgLen);
AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.PUT_OK, wroteOffset, msgLen, msgId, AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.PUT_OK, wroteOffset, msgLen, msgId,
msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
switch (tranType) { switch (tranType) {
case MessageSysFlag.TRANSACTION_PREPARED_TYPE: case MessageSysFlag.TRANSACTION_PREPARED_TYPE:
...@@ -1333,7 +1333,7 @@ public class CommitLog { ...@@ -1333,7 +1333,7 @@ public class CommitLog {
} }
public AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer, final int maxBlank, public AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer, final int maxBlank,
final MessageExtBatch messageExtBatch) { final MessageExtBatch messageExtBatch) {
byteBuffer.mark(); byteBuffer.mark();
//physical offset //physical offset
long wroteOffset = fileFromOffset + byteBuffer.position(); long wroteOffset = fileFromOffset + byteBuffer.position();
...@@ -1365,7 +1365,7 @@ public class CommitLog { ...@@ -1365,7 +1365,7 @@ public class CommitLog {
// Exceeds the maximum message // Exceeds the maximum message
if (msgLen > this.maxMessageSize) { if (msgLen > this.maxMessageSize) {
CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLen CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLen
+ ", maxMessageSize: " + this.maxMessageSize); + ", maxMessageSize: " + this.maxMessageSize);
return new AppendMessageResult(AppendMessageStatus.MESSAGE_SIZE_EXCEEDED); return new AppendMessageResult(AppendMessageStatus.MESSAGE_SIZE_EXCEEDED);
} }
totalMsgLen += msgLen; totalMsgLen += msgLen;
...@@ -1383,7 +1383,7 @@ public class CommitLog { ...@@ -1383,7 +1383,7 @@ public class CommitLog {
byteBuffer.reset(); //ignore the previous appended messages byteBuffer.reset(); //ignore the previous appended messages
byteBuffer.put(this.msgStoreItemMemory.array(), 0, 8); byteBuffer.put(this.msgStoreItemMemory.array(), 0, 8);
return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgIdBuilder.toString(), messageExtBatch.getStoreTimestamp(), return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgIdBuilder.toString(), messageExtBatch.getStoreTimestamp(),
beginQueueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); beginQueueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
} }
//move to add queue offset and commitlog offset //move to add queue offset and commitlog offset
messagesByteBuff.position(msgPos + 20); messagesByteBuff.position(msgPos + 20);
...@@ -1407,7 +1407,7 @@ public class CommitLog { ...@@ -1407,7 +1407,7 @@ public class CommitLog {
byteBuffer.put(messagesByteBuff); byteBuffer.put(messagesByteBuff);
messageExtBatch.setEncodedBuff(null); messageExtBatch.setEncodedBuff(null);
AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.PUT_OK, wroteOffset, totalMsgLen, msgIdBuilder.toString(), AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.PUT_OK, wroteOffset, totalMsgLen, msgIdBuilder.toString(),
messageExtBatch.getStoreTimestamp(), beginQueueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); messageExtBatch.getStoreTimestamp(), beginQueueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
result.setMsgNum(msgNum); result.setMsgNum(msgNum);
CommitLog.this.topicQueueTable.put(key, queueOffset); CommitLog.this.topicQueueTable.put(key, queueOffset);
...@@ -1466,7 +1466,7 @@ public class CommitLog { ...@@ -1466,7 +1466,7 @@ public class CommitLog {
// Exceeds the maximum message // Exceeds the maximum message
if (msgLen > this.maxMessageSize) { if (msgLen > this.maxMessageSize) {
CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLen CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLen
+ ", maxMessageSize: " + this.maxMessageSize); + ", maxMessageSize: " + this.maxMessageSize);
throw new RuntimeException("message size exceeded"); throw new RuntimeException("message size exceeded");
} }
......
...@@ -292,7 +292,7 @@ public class DefaultMessageStoreTest { ...@@ -292,7 +292,7 @@ public class DefaultMessageStoreTest {
private class MyMessageArrivingListener implements MessageArrivingListener { private class MyMessageArrivingListener implements MessageArrivingListener {
@Override @Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode, long msgStoreTime, public void arriving(String topic, int queueId, long logicOffset, long tagsCode, long msgStoreTime,
byte[] filterBitMap, Map<String, String> properties) { byte[] filterBitMap, Map<String, String> properties) {
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册