Java Code Examples for org.apache.rocketmq.store.config.StorePathConfigHelper#getAbortFile()

The following examples show how to use org.apache.rocketmq.store.config.StorePathConfigHelper#getAbortFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageStoreTestBase.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
protected DefaultMessageStore createMessageStore(String base, boolean createAbort) throws Exception {
    baseDirs.add(base);
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    storeConfig.setMappedFileSizeCommitLog(1024 * 100);
    storeConfig.setMappedFileSizeConsumeQueue(1024);
    storeConfig.setMaxHashSlotNum(100);
    storeConfig.setMaxIndexNum(100 * 10);
    storeConfig.setStorePathRootDir(base);
    storeConfig.setStorePathCommitLog(base + File.separator + "commitlog");
    storeConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH);
    DefaultMessageStore defaultMessageStore = new DefaultMessageStore(storeConfig,  new BrokerStatsManager("CommitlogTest"), (topic, queueId, logicOffset, tagsCode, msgStoreTime, filterBitMap, properties) -> {

    }, new BrokerConfig());

    if (createAbort) {
        String fileName = StorePathConfigHelper.getAbortFile(storeConfig.getStorePathRootDir());
        makeSureFileExists(fileName);
    }
    Assert.assertTrue(defaultMessageStore.load());
    defaultMessageStore.start();
    return defaultMessageStore;
}
 
Example 2
Source File: DefaultMessageStoreShuwDownTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testDispatchBehindWhenShutDown() {
    messageStore.shutdown();
    assertTrue(!messageStore.shutDownNormal);
    File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
    assertTrue(file.exists());
}
 
Example 3
Source File: DefaultMessageStore.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
/**
     * @throws IOException
     */
//
    private void createTempFile() throws IOException {
        String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
        File file = new File(fileName);
        MappedFile.ensureDirOK(file.getParent());
        boolean result = file.createNewFile();
        log.info(fileName + (result ? " create OK" : " already exists"));
    }
 
Example 4
Source File: DefaultMessageStore.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 5
Source File: DefaultMessageStoreShutDownTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDispatchBehindWhenShutdown() {
    messageStore.shutdown();
    assertTrue(!messageStore.shutDownNormal);
    File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
    assertTrue(file.exists());
}
 
Example 6
Source File: DefaultMessageStoreShutDownTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testDispatchBehindWhenShutdown() {
    messageStore.shutdown();
    assertTrue(!messageStore.shutDownNormal);
    File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
    assertTrue(file.exists());
}
 
Example 7
Source File: DefaultMessageStore.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 8
Source File: DefaultMessageStore.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 9
Source File: DefaultMessageStore.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 10
Source File: DefaultMessageStore.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 11
Source File: DefaultMessageStoreShuwDownTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testDispatchBehindWhenShutDown() {
    messageStore.shutdown();
    assertTrue(!messageStore.shutDownNormal);
    File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
    assertTrue(file.exists());
}
 
Example 12
Source File: DefaultMessageStore.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
/**
 *  启动服务后,在存储根目录创建临时文件,类似于 UNIX VI编辑工具
 */
private void createTempFile() throws IOException {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    MappedFile.ensureDirOK(file.getParent());
    boolean result = file.createNewFile();
    log.info(fileName + (result ? " create OK" : " already exists"));
}
 
Example 13
Source File: DefaultMessageStore.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}
 
Example 14
Source File: DefaultMessageStore.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}
 
Example 15
Source File: DefaultMessageStore.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}
 
Example 16
Source File: DefaultMessageStore.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}
 
Example 17
Source File: DefaultMessageStore.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
/**
 * 临时文件abortFile是否存在
 * @return ;
 */
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}
 
Example 18
Source File: MessageStoreTestBase.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
protected DefaultMessageStore createDledgerMessageStore(String base, String group, String selfId, String peers, String leaderId, boolean createAbort, int deleteFileNum) throws Exception {
    System.setProperty("dledger.disk.ratio.check", "0.95");
    System.setProperty("dledger.disk.ratio.clean", "0.95");
    baseDirs.add(base);
    MessageStoreConfig storeConfig = new MessageStoreConfig();
    storeConfig.setMappedFileSizeCommitLog(1024 * 100);
    storeConfig.setMappedFileSizeConsumeQueue(1024);
    storeConfig.setMaxHashSlotNum(100);
    storeConfig.setMaxIndexNum(100 * 10);
    storeConfig.setStorePathRootDir(base);
    storeConfig.setStorePathCommitLog(base + File.separator + "commitlog");
    storeConfig.setFlushDiskType(FlushDiskType.ASYNC_FLUSH);

    storeConfig.setEnableDLegerCommitLog(true);
    storeConfig.setdLegerGroup(group);
    storeConfig.setdLegerPeers(peers);
    storeConfig.setdLegerSelfId(selfId);
    DefaultMessageStore defaultMessageStore = new DefaultMessageStore(storeConfig,  new BrokerStatsManager("DLedgerCommitlogTest"), (topic, queueId, logicOffset, tagsCode, msgStoreTime, filterBitMap, properties) -> {

    }, new BrokerConfig());
    DLedgerServer dLegerServer = ((DLedgerCommitLog) defaultMessageStore.getCommitLog()).getdLedgerServer();
    if (leaderId != null) {
        dLegerServer.getdLedgerConfig().setEnableLeaderElector(false);
        if (selfId.equals(leaderId)) {
            dLegerServer.getMemberState().changeToLeader(-1);
        } else {
            dLegerServer.getMemberState().changeToFollower(-1, leaderId);
        }

    }
    if (createAbort) {
        String fileName = StorePathConfigHelper.getAbortFile(storeConfig.getStorePathRootDir());
        makeSureFileExists(fileName);
    }
    if (deleteFileNum > 0) {
        DLedgerConfig config = dLegerServer.getdLedgerConfig();
        if (deleteFileNum > 0) {
            File dir = new File(config.getDataStorePath());
            File[] files = dir.listFiles();
            if (files != null) {
                Arrays.sort(files);
                for (int i = files.length - 1; i >= 0; i--) {
                    File file = files[i];
                    file.delete();
                    if (files.length - i >= deleteFileNum) {
                        break;
                    }
                }
            }
        }
    }
    Assert.assertTrue(defaultMessageStore.load());
    defaultMessageStore.start();
    return defaultMessageStore;
}
 
Example 19
Source File: DefaultMessageStore.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
//        System.getProperty("user.home") + File.separator + "store" File.separator + "abort 判断临时文件存在不存在
        String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
        File file = new File(fileName);
        return file.exists();
    }
 
Example 20
Source File: DefaultMessageStore.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
private boolean isTempFileExist() {
    String fileName = StorePathConfigHelper.getAbortFile(this.messageStoreConfig.getStorePathRootDir());
    File file = new File(fileName);
    return file.exists();
}