Java Code Examples for com.alibaba.rocketmq.common.MixAll#string2File()

The following examples show how to use com.alibaba.rocketmq.common.MixAll#string2File() . 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: LocalFileOffsetStore.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void persistAll(Set<MessageQueue> mqs) {
    if (null == mqs || mqs.isEmpty())
        return;

    OffsetSerializeWrapper offsetSerializeWrapper = new OffsetSerializeWrapper();
    for (MessageQueue mq : this.offsetTable.keySet()) {
        if (mqs.contains(mq)) {
            AtomicLong offset = this.offsetTable.get(mq);
            offsetSerializeWrapper.getOffsetTable().put(mq, offset);
        }
    }

    String jsonString = offsetSerializeWrapper.toJson(true);
    if (jsonString != null) {
        try {
            MixAll.string2File(jsonString, this.storePath);
        } catch (IOException e) {
            log.error("persistAll consumer offset Exception, " + this.storePath, e);
        }
    }
}
 
Example 2
Source File: LocalFileOffsetStore.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void persistAll(Set<MessageQueue> mqs) {
    if (null == mqs || mqs.isEmpty())
        return;

    OffsetSerializeWrapper offsetSerializeWrapper = new OffsetSerializeWrapper();
    for(Map.Entry<MessageQueue, AtomicLong> entry: this.offsetTable.entrySet()){
        if (mqs.contains(entry.getKey())) {
            AtomicLong offset = entry.getValue();
            offsetSerializeWrapper.getOffsetTable().put(entry.getKey(), offset);
        }
    }

    String jsonString = offsetSerializeWrapper.toJson(true);
    if (jsonString != null) {
        try {
            MixAll.string2File(jsonString, this.storePath);
        } catch (IOException e) {
            log.error("persistAll consumer offset Exception, " + this.storePath, e);
        }
    }
}
 
Example 3
Source File: LocalFileOffsetStore.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void persistAll(Set<MessageQueue> mqs) {
    if (null == mqs || mqs.isEmpty())
        return;

    OffsetSerializeWrapper offsetSerializeWrapper = new OffsetSerializeWrapper();
    for (MessageQueue mq : this.offsetTable.keySet()) {
        if (mqs.contains(mq)) {
            AtomicLong offset = this.offsetTable.get(mq);
            offsetSerializeWrapper.getOffsetTable().put(mq, offset);
        }
    }

    String jsonString = offsetSerializeWrapper.toJson(true);
    if (jsonString != null) {
        try {
            MixAll.string2File(jsonString, this.storePath);
        }
        catch (IOException e) {
            log.error("persistAll consumer offset Exception, " + this.storePath, e);
        }
    }
}