final AtomicBoolean replayed = new AtomicBoolean(false);
final AtomicInteger counter = new AtomicInteger();
if (ids != null && !ids.isEmpty()) {
for (final Map.Entry<MessageStore, List<Long>> entry : ids.entrySet()) {
final MessageStore msgStore = entry.getKey();
final AddMsgLocation addedLocation = locations.get(msgStore.getDescription());
// û�������Ϣ����Ҫ�������
final List<Long> idList = entry.getValue();
final List<PutCommand> cmdList = putCmds.get(msgStore);
if (addedLocation == null) {
counter.incrementAndGet();
msgStore.append(idList, cmdList, new AppendCallback() {
@Override
public void appendComplete(final Location newLocation) {
replayed.set(true);
final int checksum =
CheckSum.crc32(MessageUtils.makeMessageBuffer(idList, cmdList).array());
locations.put(msgStore.getDescription(),
new AddMsgLocation(newLocation.getOffset(), newLocation.getLength(), checksum,
msgStore.getDescription()));
counter.decrementAndGet();
}
});
}
else {
// �����ط�
counter.incrementAndGet();
msgStore.replayAppend(addedLocation.getOffset(), addedLocation.getLength(),
addedLocation.checksum, idList, cmdList, new AppendCallback() {
@Override
public void appendComplete(final Location newLocation) {
// ����طŵ�ʱ�������λ�ã�����Ҫ����λ����Ϣ
if (newLocation != null) {
replayed.set(true);
locations.put(msgStore.getDescription(),
new AddMsgLocation(newLocation.getOffset(), newLocation.getLength(),
addedLocation.checksum, addedLocation.storeDesc));
}
counter.decrementAndGet();
}
});