Tabnine Logo
CommitLog
Code IndexAdd Tabnine to your IDE (free)

How to use
CommitLog
in
org.apache.rocketmq.store

Best Java code snippets using org.apache.rocketmq.store.CommitLog (Showing top 20 results out of 315)

origin: apache/rocketmq

public DefaultMessageStore(final MessageStoreConfig messageStoreConfig, final BrokerStatsManager brokerStatsManager,
  final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException {
  this.messageArrivingListener = messageArrivingListener;
  this.brokerConfig = brokerConfig;
  this.messageStoreConfig = messageStoreConfig;
  this.brokerStatsManager = brokerStatsManager;
  this.allocateMappedFileService = new AllocateMappedFileService(this);
  this.commitLog = new CommitLog(this);
  this.consumeQueueTable = new ConcurrentHashMap<>(32);
  this.flushConsumeQueueService = new FlushConsumeQueueService();
  this.cleanCommitLogService = new CleanCommitLogService();
  this.cleanConsumeQueueService = new CleanConsumeQueueService();
  this.storeStatsService = new StoreStatsService();
  this.indexService = new IndexService(this);
  this.haService = new HAService(this);
  this.reputMessageService = new ReputMessageService();
  this.scheduleMessageService = new ScheduleMessageService(this);
  this.transientStorePool = new TransientStorePool(messageStoreConfig);
  if (messageStoreConfig.isTransientStorePoolEnable()) {
    this.transientStorePool.init();
  }
  this.allocateMappedFileService.start();
  this.indexService.start();
  this.dispatcherList = new LinkedList<>();
  this.dispatcherList.addLast(new CommitLogDispatcherBuildConsumeQueue());
  this.dispatcherList.addLast(new CommitLogDispatcherBuildIndex());
  File file = new File(StorePathConfigHelper.getLockFile(messageStoreConfig.getStorePathRootDir()));
  MappedFile.ensureDirOK(file.getParent());
  lockFile = new RandomAccessFile(file, "rw");
}
origin: apache/rocketmq

@Override
public boolean appendToCommitLog(long startOffset, byte[] data) {
  if (this.shutdown) {
    log.warn("message store has shutdown, so appendToPhyQueue is forbidden");
    return false;
  }
  boolean result = this.commitLog.appendData(startOffset, data);
  if (result) {
    this.reputMessageService.wakeup();
  } else {
    log.error("appendToPhyQueue failed " + startOffset + " " + data.length);
  }
  return result;
}
origin: apache/rocketmq

int readLength = calMsgLength(bodyLen, topicLen, propertiesLength);
if (totalSize != readLength) {
  doNothingForDeadCode(reconsumeTimes);
  doNothingForDeadCode(flag);
  doNothingForDeadCode(bornTimeStamp);
  doNothingForDeadCode(byteBuffer1);
  doNothingForDeadCode(byteBuffer2);
  log.error(
    "[BUG]read total count not equals msg total size. totalSize={}, readTotalCount={}, bodyLen={}, topicLen={}, propertiesLength={}",
origin: apache/rocketmq

SelectMappedBufferResult result = DefaultMessageStore.this.commitLog.getData(reputFromOffset);
if (result != null) {
  try {
        DefaultMessageStore.this.commitLog.checkMessageAndReturnSize(result.getByteBuffer(), false, false);
      int size = dispatchRequest.getMsgSize();
          this.reputFromOffset = DefaultMessageStore.this.commitLog.rollNextFile(this.reputFromOffset);
          readSize = result.getSize();
origin: apache/rocketmq

for (; index >= 0; index--) {
  mappedFile = mappedFiles.get(index);
  if (this.isMappedFileMatchedRecover(mappedFile)) {
    log.info("recover from this mapped file " + mappedFile.getFileName());
    break;
long mappedFileOffset = 0;
while (true) {
  DispatchRequest dispatchRequest = this.checkMessageAndReturnSize(byteBuffer, checkCRCOnRecover);
  int size = dispatchRequest.getMsgSize();
origin: apache/rocketmq

  @Override
  public void run() {
    if (DefaultMessageStore.this.getMessageStoreConfig().isDebugLockEnable()) {
      try {
        if (DefaultMessageStore.this.commitLog.getBeginTimeInLock() != 0) {
          long lockTime = System.currentTimeMillis() - DefaultMessageStore.this.commitLog.getBeginTimeInLock();
          if (lockTime > 1000 && lockTime < 10000000) {
            String stack = UtilAll.jstack();
            final String fileName = System.getProperty("user.home") + File.separator + "debug/lock/stack-"
              + DefaultMessageStore.this.commitLog.getBeginTimeInLock() + "-" + lockTime;
            MixAll.string2FileNotSafe(stack, fileName);
          }
        }
      } catch (Exception e) {
      }
    }
  }
}, 1, 1, TimeUnit.SECONDS);
origin: apache/rocketmq

public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer, final boolean checkCRC) {
  return this.checkMessageAndReturnSize(byteBuffer, checkCRC, true);
}
origin: apache/rocketmq

private void checkSelf() {
  this.commitLog.checkSelf();
  Iterator<Entry<String, ConcurrentMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
  while (it.hasNext()) {
    Entry<String, ConcurrentMap<Integer, ConsumeQueue>> next = it.next();
    Iterator<Entry<Integer, ConsumeQueue>> itNext = next.getValue().entrySet().iterator();
    while (itNext.hasNext()) {
      Entry<Integer, ConsumeQueue> cq = itNext.next();
      cq.getValue().checkSelf();
    }
  }
}
origin: apache/rocketmq

public void destroy() {
  this.destroyLogics();
  this.commitLog.destroy();
  this.indexService.destroy();
  this.deleteFile(StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir()));
  this.deleteFile(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));
}
origin: apache/rocketmq

@Override
public long flush() {
  return this.commitLog.flush();
}
origin: apache/rocketmq

private void deleteExpiredFiles() {
  int deleteCount = 0;
  long fileReservedTime = DefaultMessageStore.this.getMessageStoreConfig().getFileReservedTime();
  int deletePhysicFilesInterval = DefaultMessageStore.this.getMessageStoreConfig().getDeleteCommitLogFilesInterval();
  int destroyMapedFileIntervalForcibly = DefaultMessageStore.this.getMessageStoreConfig().getDestroyMapedFileIntervalForcibly();
  boolean timeup = this.isTimeToDelete();
  boolean spacefull = this.isSpaceToDelete();
  boolean manualDelete = this.manualDeleteFileSeveralTimes > 0;
  if (timeup || spacefull || manualDelete) {
    if (manualDelete)
      this.manualDeleteFileSeveralTimes--;
    boolean cleanAtOnce = DefaultMessageStore.this.getMessageStoreConfig().isCleanFileForciblyEnable() && this.cleanImmediately;
    log.info("begin to delete before {} hours file. timeup: {} spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}",
      fileReservedTime,
      timeup,
      spacefull,
      manualDeleteFileSeveralTimes,
      cleanAtOnce);
    fileReservedTime *= 60 * 60 * 1000;
    deleteCount = DefaultMessageStore.this.commitLog.deleteExpiredFile(fileReservedTime, deletePhysicFilesInterval,
      destroyMapedFileIntervalForcibly, cleanAtOnce);
    if (deleteCount > 0) {
    } else if (spacefull) {
      log.warn("disk space will be full soon, but delete file failed.");
    }
  }
}
origin: didi/DDMQ

SelectMappedBufferResult result = DefaultMessageStore.this.commitLog.getData(reputFromOffset);
if (result != null) {
  try {
        DefaultMessageStore.this.commitLog.checkMessageAndReturnSize(result.getByteBuffer(), false, false);
      int size = dispatchRequest.getMsgSize();
          this.reputFromOffset = DefaultMessageStore.this.commitLog.rollNextFile(this.reputFromOffset);
          readSize = result.getSize();
origin: didi/DDMQ

for (; index >= 0; index--) {
  mappedFile = mappedFiles.get(index);
  if (this.isMappedFileMatchedRecover(mappedFile)) {
    log.info("recover from this mapped file " + mappedFile.getFileName());
    break;
long mappedFileOffset = 0;
while (true) {
  DispatchRequest dispatchRequest = this.checkMessageAndReturnSize(byteBuffer, checkCRCOnRecover);
  int size = dispatchRequest.getMsgSize();
origin: apache/rocketmq

@Override
public boolean isOSPageCacheBusy() {
  long begin = this.getCommitLog().getBeginTimeInLock();
  long diff = this.systemClock.now() - begin;
  return diff < 10000000
      && diff > this.messageStoreConfig.getOsPageCacheBusyTimeOutMills();
}
origin: apache/rocketmq

long mappedFileOffset = 0;
while (true) {
  DispatchRequest dispatchRequest = this.checkMessageAndReturnSize(byteBuffer, checkCRCOnRecover);
  int size = dispatchRequest.getMsgSize();
origin: didi/DDMQ

private void checkSelf() {
  this.commitLog.checkSelf();
  Iterator<Entry<String, ConcurrentMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
  while (it.hasNext()) {
    Entry<String, ConcurrentMap<Integer, ConsumeQueue>> next = it.next();
    Iterator<Entry<Integer, ConsumeQueue>> itNext = next.getValue().entrySet().iterator();
    while (itNext.hasNext()) {
      Entry<Integer, ConsumeQueue> cq = itNext.next();
      cq.getValue().checkSelf();
    }
  }
}
origin: didi/DDMQ

public void destroy() {
  this.destroyLogics();
  this.commitLog.destroy();
  this.indexService.destroy();
  this.deleteFile(StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir()));
  this.deleteFile(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));
}
origin: didi/DDMQ

@Override
public long flush() {
  return this.commitLog.flush();
}
origin: didi/DDMQ

private void deleteExpiredFiles() {
  int deleteCount = 0;
  long fileReservedTime = DefaultMessageStore.this.getMessageStoreConfig().getFileReservedTime();
  int deletePhysicFilesInterval = DefaultMessageStore.this.getMessageStoreConfig().getDeleteCommitLogFilesInterval();
  int destroyMapedFileIntervalForcibly = DefaultMessageStore.this.getMessageStoreConfig().getDestroyMapedFileIntervalForcibly();
  boolean timeup = this.isTimeToDelete();
  boolean spacefull = this.isSpaceToDelete();
  boolean manualDelete = this.manualDeleteFileSeveralTimes > 0;
  if (timeup || spacefull || manualDelete) {
    if (manualDelete)
      this.manualDeleteFileSeveralTimes--;
    boolean cleanAtOnce = DefaultMessageStore.this.getMessageStoreConfig().isCleanFileForciblyEnable() && this.cleanImmediately;
    log.info("begin to delete before {} hours file. timeup: {} spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}",
      fileReservedTime,
      timeup,
      spacefull,
      manualDeleteFileSeveralTimes,
      cleanAtOnce);
    fileReservedTime *= 60 * 60 * 1000;
    deleteCount = DefaultMessageStore.this.commitLog.deleteExpiredFile(fileReservedTime, deletePhysicFilesInterval,
      destroyMapedFileIntervalForcibly, cleanAtOnce);
    if (deleteCount > 0) {
    } else if (spacefull) {
      log.warn("disk space will be full soon, but delete file failed.");
    }
  }
}
origin: org.apache.rocketmq/rocketmq-store

SelectMappedBufferResult result = DefaultMessageStore.this.commitLog.getData(reputFromOffset);
if (result != null) {
  try {
        DefaultMessageStore.this.commitLog.checkMessageAndReturnSize(result.getByteBuffer(), false, false);
      int size = dispatchRequest.getMsgSize();
          this.reputFromOffset = DefaultMessageStore.this.commitLog.rollNextFile(this.reputFromOffset);
          readSize = result.getSize();
org.apache.rocketmq.storeCommitLog

Javadoc

Store all metadata downtime for recovery, data protection reliability

Most used methods

  • <init>
  • appendData
  • calMsgLength
  • checkMessageAndReturnSize
    check the message and returns the message size
  • checkSelf
  • deleteExpiredFile
  • destroy
  • doNothingForDeadCode
  • flush
  • getBeginTimeInLock
  • getConfirmOffset
  • getData
  • getConfirmOffset,
  • getData,
  • getMaxOffset,
  • getMessage,
  • getMinOffset,
  • handleDiskFlush,
  • handleHA,
  • isMappedFileMatchedRecover,
  • load,
  • lockTimeMills

Popular in Java

  • Finding current android device location
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • onRequestPermissionsResult (Fragment)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now